[net.unix-wizards] recovering clobbered aliases file

chris@umcp-cs.UUCP (07/21/83)

We're running MMDF here at U of MD, and I added a dbm-based
pre-expanded alias file to submit to speed it up.  I have essentially
the same thing (print out the aliases file from the dbm version), but
it's built into the new "newaliases" as the -l option.  Maybe that
should become standard?  (-l is for "list", by the way.)  There is one
problem -- the expanded version of the alias file is *much* larger than
the original, because of things like

msgs:msgs_local,...
msgs_local:/usr/local/post system 7@shell,...

and would need to be compressed after regeneration.

					- Chris
-- 
In-Real-Life:	Chris Torek, Univ of MD Comp Sci
UUCP:		{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:		chris@umcp-cs
ARPA:		chris.umcp-cs@UDel-Relay

jfw%mit-ccc@BRL.ARPA@sri-unix.UUCP (07/21/83)

Well, since my little program has been sent out, I might as well add some
caveats to it:  when my program recreates the alias file, you will need to
massage the results in the following manner:  all characters which were quoted
in the original by \ will have the 0200 bit set (as in:
mp: mp@mit-vax \mp
), and all characters which were in strings will also have the 0200 bit on
the quotation marks will be there; I can't remember if the \ appears.  I think
so.  If your editor cannot handle such files, a simple repair to my program
would be to replace the printf with something smarter.  Also note that comments
are stripped out, and the lines are in random (one hopes) order.
Your woes are minimized; they are not over...
Have fun,
	jfw @ mit-ccc (John Woods)
	i.e., I admit it.  I wrote it.  Thanks, Mark...

smh@mit-eddie.UUCP (Steven M. Haflich) (07/25/83)

Perhaps a more useful way for protecting files which are edited by
a large population is to make safety copies every day, week, and month,
with the obvious crontab entries:

0 1 * * * cd /usr/lib; cp aliases aliases.daily; chmod 444 aliases.daily
0 2 * * 1 cd /usr/lib; cp aliases aliases.weekly; chmod 444 aliases.weekly
0 3 1 * * cd /usr/lib; cp aliases aliases.monthly; chmod 444 aliases.monthly

To avoid clutter in crontab, such daily, weekly, and monthly commands can
be collected into single shell scripts executed by cron.

This is useful for /etc/passwd, /usr/lib/aliases, and perhaps /etc/motd.
It uses little disk space, and provides a useful checkpointing facility
in conjunction with diff when strange changes are not recognized immediately.

						Steve Haflich

MP%mit-xx@sri-unix.UUCP (07/26/83)

From:  Mark Plotnick <MP@mit-xx>

If your system runs out of disk space frequently (we do), or if you
have butterfingered typists (we do), you may wind up clobbering
certain files such as /usr/lib/aliases.  Well, it happened to us once
too often, and John Woods wrote this little program that reconstructs
/usr/lib/aliases from /usr/lib/aliases.{dir,pag} :

#include <stdio.h>

typedef struct {
	char *dptr;
	int dsize;
} datum;

main()
{
	datum Key, firstkey(), nextkey(), Datum, fetch();

	dbminit("/usr/lib/aliases");
	for (Key = firstkey(); Key.dptr != NULL; Key = nextkey(Key))
	{	Datum = fetch(Key);
		printf("%s: %s\n",Key.dptr,Datum.dptr);
	}
}
-------