Want more timely Centmin Mod News Updates?
Become a Member

Beta Branch fix addsudousers.sh sudoers validation, username checks and failure h…

Discussion in 'Centmin Mod Github Commits' started by eva2000, Nov 21, 2026 at 7:04 PM.

  1. eva2000

    eva2000 Administrator Staff Member

    60,588
    12,631
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,298
    Local Time:
    10:44 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    fix addsudousers.sh sudoers validation, username checks and failure handling in 140.00beta01


    tools/addsudousers.sh wrote the sudoers rule straight into /etc/sudoers.d
    and ignored the visudo result, did not validate the username, carried on
    after useradd/passwd failures and always exited 0. Running it for an
    existing account added it to wheel, reset its password and granted it
    ALL. Running it for "addpaths" overwrote Centmin's own secure_path file,
    a username like "../sudoers" truncated /etc/sudoers, and a dotted
    username produced a file that sudo's includedir silently skips.

    Changes:
    - require root, at least one username and an existing /etc/sudoers.d
    - only accept usernames matching ^[a-z_][a-z0-9_-]{0,31}$
    - skip users that already exist and existing /etc/sudoers.d/<user> files
    - useradd -m and usermod -aG wheel abort on failure; a failed passwd
    warns and makes the script exit 1
    - write the rule to a dotted temp file, set root:root 0440, check it with
    visudo -cqf, move it into place, then check the whole policy with
    visudo -cq; remove it and show visudo's error if either check fails
    - append each shell alias only once, to the real home dir from getent,
    and make the dotfiles owned by the new user
    - drop the misleading "with password: ... created" line
    - exit 0 only when every user was set up, else exit 1

    Continue reading...

    140.00beta01 branch