in reply to Public Access Linux Box

Managed to solve the problem with much hair-pulling. For some reason (perhaps platform dependant), perl (or probably more correctly passwd itself) refuses to accept a change of password when run
system "/usr/bin/passwd", $username;
I am happy enough leaving this fact alone, and have rather manually taken in the passwd and encrypted it with crypt. This is probably superfluous, but I may as well show you what I did in case someone has this problem in the future.
print "Password: "; chomp(my $passwd = <STDIN>); $passwd = crypt($passwd, time()); $uid=($max+1); system '/usr/sbin/useradd', "-u $uid", '-s', $shell, '-p', $passwd, '-g 100', '-m', $username;
So simple in hindsight. Perl really humbles me!

Replies are listed 'Best First'.
Re^2: Public Access Linux Box
by Aristotle (Chancellor) on Mar 15, 2003 at 12:52 UTC
    Or maybe in more Perlish lingo:
    print "Password: "; chomp(my $passwd = <STDIN>); system( '/usr/sbin/useradd', -u => $max + 1, -s => $shell, -p => crypt($passwd, time), -g => 100, '-m', $username, );
    :-) Btw, I recommend removing the setuid bit from useradd ASAP. Otherwise, anyone can do something like
    $ /usr/sbin/useradd -u 0 -g 0 -s /bin/bash -p crypted_passwd_here -m root2
    which 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/useradd
    and then your code changes to
    system( '/usr/bin/sudo', '/usr/sbin/useradd', -u => $max + 1, -s => $shell, -p => crypt($passwd, time), -g => 100, '-m', $username, );
    That way only newuser, whom only root has control of, may add new users.

    Makeshifts last the longest.