]> git.pld-linux.org Git - packages/sendmail.git/commitdiff
2017ed7f595b20850d85dd9ea0aa1cd4 passwd-to-alias
authorankry <ankry@pld-linux.org>
Wed, 17 Apr 2002 17:58:58 +0000 (17:58 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    passwd-to-alias -> 1.1

passwd-to-alias [new file with mode: 0644]

diff --git a/passwd-to-alias b/passwd-to-alias
new file mode 100644 (file)
index 0000000..4b635b3
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/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";
+
+$wordpat = '([a-zA-Z]+?[a-zA-Z0-9-]*)?[a-zA-Z0-9]';    # 'DB2'
+while (@a = getpwent) {
+    ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = @a;
+
+    ($fullname = $gcos) =~ s/,.*$//;
+
+    if (!-d $dir || !-x $shell || $shell =~ m!/bin/(false|true)$!) {
+       print "$name: root\n";                          # handle pseudo user
+    }
+
+    $fullname =~ s/\.*[ _]+\.*/./g;
+    $fullname =~ tr [åäéöüÅÄÖÜ] [aaeouAAOU];  # <hakan@af.lu.se> 1997-06-15
+    next if (!$fullname || lc($fullname) eq $name);    # avoid nonsense
+    if ($fullname =~ /^$wordpat(\.$wordpat)*$/o) {     # Ulrich Windl
+       print "$fullname: $name\n";
+    } else {
+       print "# $fullname: $name\n";                   # avoid strange names
+    }
+};
+
+endpwent;
This page took 0.041437 seconds and 4 git commands to generate.