Adduser - tool for adding new users to the system

This package consists of two programs, mkpwent and adduser.  The first is a
C program which simply puts a new entry into /etc/passwd.  You have to
supply all the values on the command line, and it does a few simple checks
to make sure the login shell exists and is executable, for example, then writes
a new /etc/passwd file, backing up the old one in /etc/passwd.OLD.

The second program, adduser, is a (BASH) shell script which has all the system-
dependent bits encoded in it.  Essentially what it does is call mkpwent
and then create all the directories and miscellaneous files required in
setting up a user account.  It is intended to be straightforward to modify
the shell commands after the mkpwent program succeeds for individual systems.


INSTALLATION

1.  Compile mkpwent: 'gcc mkpwent.c -o mkpwent'.  There should be no warnings
even if you compile with '-Wall'.

2.  Edit the adduser script.  I put both the programs in /usr/adm; if you 
don't, you will need to change the ADM variable.  You might change MAIL_DIR 
if you set up mail differently.  Then edit the commands after 'Setup the home 
directory...' to suit your taste.

3.  Move both mkpwent and adduser to a suitable directory (/usr/adm).


RUNNING

Obviously, both these programs must be run as root.

Mkpwent is pretty simpleminded: you invoke it with

	mkpwent name password userid groupid gecos-info home-dir login-shell

All the parameters are required, and they are put into a new entry at the end
of the passwd file, with the following exceptions.

The password is encrypted, unless it begins with a '*' to disable logins.

The userid can be a decimal number, or a '-', in which case the userid is
one greater than the last entry currently in passwd.  This works well only
if you keep passwd sorted, so if you add a new user with a low userid, you
will have to edit passwd by hand to move it near the front.  I didn't use the
highest entry in the file in case a 'nobody' entry exists with the highest
possible uid.  (This should also be near the front, if it does exist)

The groupid can be a number or a symbolic name (from the /etc/group) file.

If the gecos info contains spaces, remember to quote it.

If and only if the home directory exists, it will be checked for proper
ownership, permissions, and to make sure it *is* a directory.

The shell is always checked to make sure it is an executable file.

Finally, a check for duplicate name and uid is made before passwd is updated.
If you really want two logins with the same uid, you have to edit passwd by
hand.

The way you normally want to add new users, however, is to run the adduser 
script, which has only one parameter required: the login name.  Everything else
has defaults which can be overridden by commandline options.  The defaults
can be easily modified to suit your own system.

Here's how to invoke adduser:

#  usage: adduser name [options]
#	options are:
#	-p password (not encrypted if it starts with '*')
#	-u userid (numeric or '-')
#	-g groupid (numeric or symbolic)
#	-n real name (gecos field)
#	-d home directory (checked iff it exists)
#	-s login shell (must exist and be executable)

The script has two parts.  First it sets up the parameters for the mkpwent
call, from defaults or the command line.  Then if mkpwent succeeds, the
home directory and related files are created, so it should be easy to
modify this for your own system as well.


Steve Robbins
steve@nyongwa.cam.org
10 August 1992
