]> git.pld-linux.org Git - packages/sendmail.git/blob - passwd-to-alias
2017ed7f595b20850d85dd9ea0aa1cd4 passwd-to-alias
[packages/sendmail.git] / passwd-to-alias
1 #!/usr/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
9 print "# Generated from passwd by $0\n";
10
11 $wordpat = '([a-zA-Z]+?[a-zA-Z0-9-]*)?[a-zA-Z0-9]';     # 'DB2'
12 while (@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
31 endpwent;
This page took 0.065153 seconds and 3 git commands to generate.