summaryrefslogtreecommitdiff
path: root/databases/courier-authlib-usergdbm/files/patch-userdb::pw2userdb.in
blob: 7cb79aa49b02d70873ebcaf0a30f9b8abeedc756 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--- userdb/pw2userdb.in.orig	Wed Jul 19 13:55:15 2000
+++ userdb/pw2userdb.in	Tue Mar  1 21:58:51 2005
@@ -7,6 +7,8 @@
 # Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
 # distribution information.
 
+# Adapted to BSD master.passwd
+
 use Getopt::Long;
 
 #
@@ -22,42 +24,66 @@
 	if $vpopuid;
 
 $passwd="/etc/passwd" unless $passwd =~ /./;
-$shadow="/etc/shadow" unless $shadow =~ /./;
+$shadow="/etc/master.passwd" unless $shadow =~ /./;
 
 $domain="" unless $domain =~ /./;
 $domain="\@$domain" if $domain =~ /./;
 
-open(PASSWD, $passwd) || die "$!\n";
-
-while (<PASSWD>)
+if (! $noshadow && $shadow =~ /master.passwd$/)
 {
-	chop if /\n$/;
-	next if /^#/;
-	($acct,$passwd,$uid,$gid,$name,$home,$shell)=split( /:/ );
-
-	($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
-
-	$PASSWORD{$acct}=$passwd if $passwd ne "x";
-	$UID{$acct}=$uid;
-	$GID{$acct}=$gid;
-	$HOME{$acct}=$home;
-	$SHELL{$acct}=$shell;
-
-	$name =~ s/\|/./g;	# Just in case
-	$GECOS{$acct}=$name;
-}
-close (PASSWD);
+	open(PASSWD, $shadow) || die "$!\n";
 
-if ( -f $shadow && ! $noshadow)
-{
-	open (SHADOW, $shadow) || die "$!\n";
-	while (<SHADOW>)
+	while (<PASSWD>)
 	{
+		chop if /\n$/;
 		next if /^#/;
-		($acct,$passwd,$dummy)=split(/:/);
+		($acct,$passwd,$uid,$gid,$class,$change,$expire,$name,$home,$shell)=split( /:/ );
+
+		($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
+		$name =~ s/\|/./g;      # Just in case
+
 		$PASSWORD{$acct}=$passwd;
+		$UID{$acct}=$uid;
+		$GID{$acct}=$gid;
+		$HOME{$acct}=$home;
+		$SHELL{$acct}=$shell;
+		$GECOS{$acct}=$name;
+	}
+	close (PASSWD);
+} else {
+	open(PASSWD, $passwd) || die "$!\n";
+
+	while (<PASSWD>)
+	{
+		chop if /\n$/;
+		next if /^#/;
+		($acct,$passwd,$uid,$gid,$name,$home,$shell)=split( /:/ );
+
+		($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
+
+		$PASSWORD{$acct}=$passwd if $passwd ne "x";
+		$UID{$acct}=$uid;
+		$GID{$acct}=$gid;
+		$HOME{$acct}=$home;
+		$SHELL{$acct}=$shell;
+
+		$name =~ s/\|/./g;	# Just in case
+		$GECOS{$acct}=$name;
+	}
+	close (PASSWD);
+
+	if ( -f $shadow && ! $noshadow)
+	{
+		open (SHADOW, $shadow) || die "$!\n";
+		while (<SHADOW>)
+		{
+		
+			next if /^#/;
+			($acct,$passwd,$dummy)=split(/:/);
+			$PASSWORD{$acct}=$passwd;
+		}
+		close (SHADOW);
 	}
-	close (SHADOW);
 }
 
 while ( defined ($key=each %UID))