usermatic is a collection of Perl scripts to automate maintenance of the
user database on Linux and FreeBSD. Originally it was developed for
FreeBSD, but it should work on Linux as well. These scripts compare the
passwd database to the current list of employees/students/etc. which has
to be supplied in a suitable format. This package was designed to work
together with userneu.pl (http://freshmeat.net/projects/userneu/) and
contains no facilities to do the actual account creation work, instead
it outputs a list suitable for processing with userneu. Stale accounts
can be deleted using the reaper.pl script.



Requirements:

-The Digest::MD5 Perl Module
-The userneu package (recommended, of course you can use anything that
can create user accounts from the output of digestion.pl and
newusers.pl)



How it works:

The digestion.pl script parses a tab-delimited list and creates a MD5
sum over two or more fields that can be arbitrarily chosen (For example
the full name and the birthdate, which should lower the possibility of
collisions, i.e. maybe there are two people named John Doe but most
likely they were not born on exactly the same day). This MD5 sum is then
written in the GECOS (aka comment) field in /etc/passwd. Every time the
scripts hunter-seeker.pl newusers.pl run they check the MD5 sums in
passwd(5) against the MD5 sums in the list of current
employees/students/whatever. Those scripts output lists of users to be
created and lists of users to be deleted which in turn can be processed
by userneu.pl (or whatever you use for creating user accounts) and
reaper.pl.



Example Scenario:

You have a tab separated list (named list_raw from now on) in the
following format:

username	full name	class	birth date

Now you run digestion.pl to create MD5 sums. By default digestion
creates an MD5 sum over the second and fourth field in it's input so 

% digestion.pl -i list_raw -o list_digested -d 4

yields the following output (from now on called list_digested):

username	full name	class	MD5 sum

By default digestion.pl simply appends the MD5 sum to the original line.
This behaviour can be customized using the -d option. Refer to the
manual page digestion.pl(1) for details.

Now you can use userneu(8) to create user accounts from the output of
digestion.pl. Refer to the documentation of userneu if you don't know
how to do it already.

After the initial creation of user accounts is completed the main task
of usermatic is the periodical maintenance of the user database. For
that purpose hunter-seeker.pl and newusers.pl are used to determine
stale accounts and accounts to be created newly:

First we create the MD5 hashes over the current list_raw file:

% digestion.pl -i list_raw -o list_digested

Then

% hunter-seeker.pl -i list_digested -o list_delete -G 1000

checks the MD5 sums of all the users in the group with GID 1000 against
the list output by digestion.pl iterating over the current list_raw
file. It outputs a list of stale accounts that can be deleted using the
reaper.pl script:

% reaper.pl -i list_delete

Now we check list_digested against the passwd database to determine the
accounts to be created:

% newusers.pl -i list_digested -o list_create -G 1000

Now we use userneu(8) to create the new accounts:

% userneu.pl -i list_create -G users

These steps can be repeated periodically any time there is a significant
user fluctuation to keep the user database in sync with the
students/employees/whatever


Contact information:

Johannes Grassler <johannes.grassler@freenet.de>

My GPG key fingerprint:

pub  1024D/1FCB4CF3 2002-07-03 Johannes Grassler <johannes.grassler@freenet.de>
     Key fingerprint = 5CAF DF5C A5E8 69EA B7C9  2FD9 ADD9 6BF3 1FCB 4CF3

Copyright (c) 2003 Johannes Grassler. All rights reserved. This program
is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License (GPL)..
