aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/sendmail/contrib/passwd-to-alias.pl
blob: 05a51b93496fb35e2f7d291b46d7b83ca556e7e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/perl

#
#  Convert GECOS information in password files to alias syntax.
#
#  Contributed by Kari E. Hurtta <Kari.Hurtta@ozone.fmi.fi>
#

print "# Generated from passwd by $0\n";

while (@a = getpwent) {
    ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = @a;

    ($fullname = $gcos) =~ s/,.*$//;

    if (!-d $dir || !-x $shell) {
	print "$name: root\n";
    }

    $fullname =~ s/\.*[ _]+\.*/./g;
    $fullname =~ tr [åäöÅÄÖé] [aaoAAOe];  # <hakan@af.lu.se> 1997-06-15
    if ($fullname =~ /^[a-zA-Z][a-zA-Z-]+(\.[a-zA-Z][a-zA-Z-]+)+$/) {  
#   if ($fullname =~ /^[a-zA-Z]+(\.[a-zA-Z]+)+$/) {    # Kari E. Hurtta
	print "$fullname: $name\n";
    } else {
	print "# $fullname: $name\n";
    }
};

endpwent;