diff options
-rw-r--r-- | usr.sbin/sendmail/contrib/passwd-to-alias.pl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/usr.sbin/sendmail/contrib/passwd-to-alias.pl b/usr.sbin/sendmail/contrib/passwd-to-alias.pl new file mode 100644 index 00000000000..b2bbab541f8 --- /dev/null +++ b/usr.sbin/sendmail/contrib/passwd-to-alias.pl @@ -0,0 +1,28 @@ +#!/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; + if ($fullname =~ /^[a-zA-Z]+(\.[a-zA-Z]+)+$/) { + print "$fullname: $name\n"; + } else { + print "# $fullname: $name\n"; + } +}; + +endpwent; |