source: trunk/third/sendmail/contrib/passwd-to-alias.pl @ 19204

Revision 19204, 867 bytes checked in by zacheiss, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19203, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/perl
2
3#
4#  Convert GECOS information in password files to alias syntax.
5#
6#  Contributed by Kari E. Hurtta <Kari.Hurtta@ozone.fmi.fi>
7#
8
9print "# Generated from passwd by $0\n";
10
11$wordpat = '([a-zA-Z]+?[a-zA-Z0-9-]*)?[a-zA-Z0-9]';     # 'DB2'
12while (@a = getpwent) {
13    ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = @a;
14
15    ($fullname = $gcos) =~ s/,.*$//;
16
17    if (!-d $dir || !-x $shell || $shell =~ m!/bin/(false|true)$!) {
18        print "$name: root\n";                          # handle pseudo user
19    }
20
21    $fullname =~ s/\.*[ _]+\.*/./g;
22    $fullname =~ tr [åäéöüÅÄÖÜ] [aaeouAAOU];  # <hakan@af.lu.se> 1997-06-15
23    next if (!$fullname || lc($fullname) eq $name);     # avoid nonsense
24    if ($fullname =~ /^$wordpat(\.$wordpat)*$/o) {      # Ulrich Windl
25        print "$fullname: $name\n";
26    } else {
27        print "# $fullname: $name\n";                   # avoid strange names
28    }
29};
30
31endpwent;
Note: See TracBrowser for help on using the repository browser.