in reply to Re: How do I add a new Unix user?
in thread How do I add a new Unix user?

Some comments: My opinion at adding users: use useradd/adduser since it can automatically do most tasks (like autoguessing UID to use, creating homedir with /etc/skel, add *optional* personal name, encode the password correctly {even if it is crypt'ed}, set the correct permissions, etc). Don't roll your own !

If you're not used to doing stuff like that (let me repeat *if you're not used to doing stuff like that*) don't do it on a live box...

my $0.02

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
Re: Re: Re: How do I add a new Unix user?
by blue_cowdawg (Monsignor) on May 25, 2001 at 00:20 UTC

    There are a few good reasons I can think of for writing your own script for generating accounts on a Unix box.

    • In one environment where I did create a custom script for doing this I had a requirement that clericals were going to be adding in new accounts.

      To accomplish this I created a CGI that asked a few questions and used business rules to create the account.

    • As in above if there are policies that you want to enforce that an adduser command has not been set up to deal with. For instance, spreading user accounts across multiple servers, putting users home directories across multiple mount points based on initials, etc. etc.
    • In one case I administred a system where the adduser command was capricious, cantankerous, and downright unreliable.


    Peter L. BergholdSchooner Technology Consulting, Inc.
    Peter@Berghold.Netwww.berghold.net
      My entire point was that you should call adduser from a Perl script (since it's glue), as this is perlmonks :)
      IIRC you can pass a parameter to adduser where to create the homedir... You can have your perl code create mount points, spread it on different servers, etc.
      I doubt you'll be able to mimic the adduser behaviour with a few lines of Perl. Each platform probably has a somewhat tweaked version of adduser. If you can't guarantee the reliability of some system tools, you shouldn't have 'clericals' adding user accounts in the first place.

      Greetz
      Beatnik
      ... Quidquid perl dictum sit, altum viditur.