in reply to Re: Public Access Linux Box
in thread Public Access Linux Box
:-) Btw, I recommend removing the setuid bit from useradd ASAP. Otherwise, anyone can do something likeprint "Password: "; chomp(my $passwd = <STDIN>); system( '/usr/sbin/useradd', -u => $max + 1, -s => $shell, -p => crypt($passwd, time), -g => 100, '-m', $username, );
$ /usr/sbin/useradd -u 0 -g 0 -s /bin/bash -p crypted_passwd_here -m root2which is a classic escalation of privileges attack. Instead, you want to look into sudo. Your /etc/sudoers should have a line like this:
newuser ALL = (root) NOPASSWD: /usr/sbin/useraddand then your code changes to
That way only newuser, whom only root has control of, may add new users.system( '/usr/bin/sudo', '/usr/sbin/useradd', -u => $max + 1, -s => $shell, -p => crypt($passwd, time), -g => 100, '-m', $username, );
Makeshifts last the longest.
|
|---|