SUMMARY: mail_aliases.org_dir hiccups

From: Stuart Kendrick (sbk@fhcrc.org)
Date: Mon Apr 21 1997 - 13:14:51 CDT


I noticed that entries in the NIS+ aliases table were vanishing
intermittently. I wrote a script, attached below, which dumped the
aliases table periodically and compared it to the master text file; I ran
the script form cron every ten minutes. On a
couple of occasions, the script noticed reoccurrence of the phenomenon. I
repaired the problem by manually importing the master text file into the
NIS+ space.

Simultaneously, I started having trouble with one of the replica servers.
I removed the replica server, rebuilt it, and have had no reoccurrences
since.

--sk

Stuart Kendrick
Network Services
FHCRC

Original post:

I've recently noted discrepancies between the text file which I feed into
mail_aliases.org_dir and the table itself. This looks like a nightmare:
intermittent loss of entries in a NIS+ table.

I create my aliases file from an extract from our HR database. Every
hour, a cron job on one of the NIS+ boxes runs "nisaddent -mf
aliases.master aliases.org_dir" If the HR people have modded any mail
aliases, then the change gets imported into the NIS+ space automatically.

I've been receiving scattered reports of intermittent mail bouncing ...
which normally I would dismiss, except that the users are high profile and
provided me with headers showing the bounces.

In an utterly random experience this morning, I sent a message to a
co-worker ... and it bounced. Repeated typing of "nisgrep name
mail_aliases.org_dir" confirmed that indeed, this alias did not exist in
the NIS+ mail_aliases table.

I verified that this entry existed in aliases.master. I verified that the
NIS+ logs were checkpointed. (A cron job runs "nisping -C" every hour;
in fact, the logs were checkpointed.)

I imported the master text file into the NIS+ space by hand -- "nisaddent
-mvf /files/aliases.master aliases.org_dir" -- 0 entries added/updated, 0
entries removed.

I dumped the aliases table "niscat mail_aliases.org_dir > aliases.dump",
cleaned up the text master and the aliases.dump file ... typed "diff
aliases.master aliases.dump" ... and discovered indeed that there was a
single difference between the two files: the entry corresponding to
my co-worker.

I touched the master text file "touch aliases.master" and let the cron job
(which uses make) import aliases.master into the NIS+ space ... and this
time it worked, e.g. my co-worker's alias appeared. I dumped the NIS+
table, cleaned it up, and "diff aliases.master aliases.dump" -- they were
identical.

This looks like a nightmare. Intermittent loss af random entries in the
mail_aliases table. I shall write a cron job which dumps the alias table
periodically, compares it to the master text file, and screams if it
notices a difference.

Has anyone else experienced this?

Solaris 2.5.1 with identical selection of the latest patches on all boxes.
About 4000 aliases. One root master, four replica servers, two clients.

--sk

Stuart Kendrick
Network Services
FHCRC

#!/usr/local/bin/perl
# If aliases.org_dir is not identical to
# bug1:/home/mailops/etc/aliases.nisplus then scream. --sk 4-11-97

use Sys::Syslog;
use POSIX;
use File::Copy 'cp';

$dumpfile = "aliases.dump";
$lockfile = "monitor_aliases.lock";
$logdir = "/home/nisops/log";
$logfile = "aliases.log";
$masterdir = "/home/mailops/etc";
$masterfile = "aliases.nisplus";
$tmpdir = "/home/nisops/tmp";

# Dump aliases.org_dir to a text file and compare to the master on bug0.
# If they are different, scream.

# If master text file isn't there, bail
if (! -r "$masterdir/$masterfile") { exit; }

# If lock file exists, bail
if (-e "$tmpdir/$lockfile") { exit; }

# Dump aliases.org_dir to a file
system ("/usr/lib/nis/nisaddent -d aliases > '$tmpdir/$dumpfile'");
cp ("$masterdir/$masterfile", "$tmpdir/$masterfile");

# Clean the dump file
open (DUMP, "<$tmpdir/$dumpfile");
open (OUT, ">$tmpdir/aliases.dump1");
while (<DUMP>) {
  s/.*#.*\n//; # Strip comments
  s/:\s*\n/: /; # Join lines which end with ":"
  s/:\s*/:\$\$\$/; # Save colon plus space combinations
  s/,\s*\n/,/; # Join lines which end with ","
  s/\(.*?\)//g; # Strip parens and their contents
  s/\t//g; # Strip tabs
  s/ //g; # Strip spaces
  s/^\n//; # Strip blank lines
  s/:\$\$\$/: /; # Restore space after colon
  print (OUT $_);
}
close DUMP;
close OUT;
system ("/usr/bin/sort '$tmpdir/aliases.dump1' > '$tmpdir/aliases.dump2'");

# Clean the master file
open (MASTER, "<$tmpdir/$masterfile");
open (OUT, "> $tmpdir/aliases.nisplus1");
while (<MASTER>) {
  s/.*#.*\n//; # Strip comments
  s/:\s*\n/: /; # Join lines which end with ":"
  s/:\s*/:\$\$\$/; # Save colon plus space combinations
  s/,\s*\n/,/; # Join lines which end with ","
  s/\(.*?\)//g; # Strip parens and their contents
  s/\t//g; # Strip tabs
  s/ //g; # Strip spaces
  s/^\n//; # Strip blank lines
  s/:\$\$\$/: /; # Restore space after colon
  print (OUT $_);
}
close MASTER;
close OUT;
system ("/usr/bin/sort '$tmpdir/aliases.nisplus1' > '$tmpdir/aliases.nisplus2'");

# If there are differences, scream
$diff = (system ("/usr/bin/diff $tmpdir/aliases.dump2 $tmpdir/aliases.nisplus2"))/256;
if ($diff == 1) {
  $diff = `/usr/bin/diff $tmpdir/aliases.dump2 $tmpdir/aliases.nisplus2`;
  open FILE, ">$tmpdir/nisplus.msg";
  print FILE "NIS+ not the same as files. --monitor_nisplus";
  close FILE;
  system "/usr/bin/mailx -s 'NIS+ not the same as files' skendric\@fhcrc.org < $tmpdir/nisplus.msg";
  system ("/usr/bin/touch $tmpdir/$lockfile");
  open LOG, ">>$logdir/$logfile";
  print LOG scalar localtime, "\n";
  print LOG $diff, "\n";
  close LOG;
}

if ( ! -e "$tmpdir/$lockfile") {
  unlink "$tmpdir/$dumpfile", "$tmpdir/aliases.dump1", "$tmpdir/aliases.dump2", "/$tmpdir/aliases.nisplus", "/$tmpdir/aliases.nisplus1", "/$tmpdir/aliases.nisplus2", "/$tmpdir/nisplus.msg";
}



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:51 CDT