-
Notifications
You must be signed in to change notification settings - Fork 0
/
e-smith-ldap-5.2.0-add_www_move_nobody.patch
161 lines (155 loc) · 7.15 KB
/
e-smith-ldap-5.2.0-add_www_move_nobody.patch
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
diff -up e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update.add_www_move_nobody e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update
--- e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update.add_www_move_nobody 2010-10-27 10:22:53.000000000 -0600
+++ e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update 2010-10-27 10:34:49.000000000 -0600
@@ -164,6 +164,69 @@ foreach my $obj ( qw(Users Groups Comput
}
#------------------------------------------------------------
+# Ensure nobody, shared, www objects are there
+#------------------------------------------------------------
+foreach my $user (qw/www/){
+ my $dn = "cn=$group,ou=Users,$base";
+ utf8::upgrade($dn);
+ $updates->{$dn}->{objectClass} = ['account', 'posixAccount', 'shadowAccount'];
+
+ # Read information from getent passwd
+ @{$updates->{$dn}}{'uid','userPassword','uidNumber','gidNumber','junk','junk','gecos','homeDirectory','loginShell'} = getpwnam($key);
+ $updates->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $updates->{$dn}->{userPassword} =~ m/^{/;
+ $desc = $updates->{$dn}->{cn} = $updates->{$dn}->{gecos};
+
+ # Samba parameters if we find the samba.schema
+ if ( -f "$schema" and -x '/usr/bin/pdbedit' )
+ {
+ my $line = `/usr/bin/pdbedit -wu '$key' 2> /dev/null`;
+ chomp($line);
+ if ($line)
+ {
+ @{$updates->{$dn}}{'junk','junk','sambaLMPassword','sambaNTPassword'} = split(/:/,$line);
+ foreach $line (`/usr/bin/pdbedit -vu '$key' 2> /dev/null`)
+ {
+ chomp($line);
+ $updates->{$dn}->{sambaSID} = $1 if $line =~ m{User SID:\s+(S-.*)$};
+ $updates->{$dn}->{displayName} = $1 if $line =~ m{Full Name:\s+(.*)$};
+ $updates->{$dn}->{sambaPrimaryGroupSID} = $1 if $line =~ m{Primary Group SID:\s+(S-.*)$};
+ $updates->{$dn}->{sambaAcctFlags} = $1 if $line =~ m{Account Flags:\s+(.*)$};
+ $updates->{$dn}->{sambaPwdLastSet} = str2time($1) if $line =~ m{Password last set:\s+(.*)$};
+ }
+ push @{$updates->{$dn}->{objectClass}}, 'sambaSamAccount';
+ }
+ }
+}
+endpwent();
+
+foreach my $group (qw/nobody shared www/){
+ my $dn = "cn=$group,ou=Groups,$base";
+ utf8::upgrade($dn);
+ $updates->{$dn}->{objectClass} = ['posixGroup'];
+
+ # Read information from getent group
+ @{$updates->{$dn}}{'cn','userPassword','gidNumber','memberUid'} = getgrnam($group);
+ $updates->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $updates->{$dn}->{userPassword} =~ m/^{/;
+ $updates->{$dn}->{memberUid} = [ split /\s+/, $updates->{$dn}->{memberUid} ];
+
+ # Ensure groups have the needed properties
+ if ($group eq 'shared'){
+ push @{$updates->{$dn}->{objectClass}}, 'mailboxRelatedObject';
+ $updates->{$dn}->{mail} = "everyone\@$domain";
+ }
+
+ # Samba parameters if we find the samba.schema
+ if ( -f "$schema" and exists $groupmap->{$group} )
+ {
+ push @{$updates->{$dn}->{objectClass}}, 'sambaGroupMapping';
+ $updates->{$dn}->{displayName} = $groupmap->{$group}->{name};
+ $updates->{$dn}->{sambaSID} = $groupmap->{$group}->{sid};
+ $updates->{$dn}->{sambaGroupType} = '2';
+ }
+}
+endgrent();
+
+#------------------------------------------------------------
# Create a list of updates that need to happen
#------------------------------------------------------------
my $updates;
@@ -274,29 +337,6 @@ endpwent();
endgrent();
-# Nobody and shared are special groups used by samba
-foreach my $group (qw/nobody shared/){
- my $dn = "cn=$group,ou=Groups,$base";
- @{$updates->{$dn}}{'cn','userPassword','gidNumber','memberUid'} = getgrnam($group);
- utf8::upgrade($dn);
- $updates->{$dn}->{objectClass} = ['posixGroup'];
- if ($group eq 'shared'){
- push @{$updates->{$dn}->{objectClass}}, 'mailboxRelatedObject';
- $updates->{$dn}->{mail} = "everyone\@$domain";
- }
- $updates->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $updates->{$dn}->{userPassword} =~ m/^{/;
- $updates->{$dn}->{memberUid} = [ split /\s+/, $updates->{$dn}->{memberUid} ];
- if ( -f "$schema" and exists $groupmap->{$group} )
- {
- push @{$updates->{$dn}->{objectClass}}, 'sambaGroupMapping';
- $updates->{$dn}->{displayName} = $groupmap->{$group}->{name};
- $updates->{$dn}->{sambaSID} = $groupmap->{$group}->{sid};
- $updates->{$dn}->{sambaGroupType} = '2';
- }
-}
-endgrent();
-
-
#------------------------------------------------------------
# Update LDAP database entry.
#------------------------------------------------------------
diff -up e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin.add_www_move_nobody e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin
--- e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin.add_www_move_nobody 2010-10-27 10:22:53.000000000 -0600
+++ e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin 2010-10-27 10:48:06.000000000 -0600
@@ -81,6 +81,21 @@
}
endpwent();
+ # www is a special user for all accounts
+ foreach my $user (qw/www/)
+ {
+ $dn = "uid=$key,ou=Users,$ldapBase";
+ utf8::upgrade($dn);
+
+ $dnmap->{$user}->{user} = $dn;
+
+ $ldif->{$dn}->{objectClass} = [ qw(account posixAccount shadowAccount) ];
+ @{$ldif->{$dn}}{'uid','userPassword','uidNumber','gidNumber','junk','junk','gecos','homeDirectory','loginShell'} = getpwnam($key);
+ $ldif->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $ldif->{$dn}->{userPassword} =~ m/^{/;
+ $ldif->{$dn}->{cn} = $ldif->{$dn}->{gecos} || '';
+ }
+ endpwent();
+
# Read in group details
while(my ($key,$pwd,$gid,$members) = getgrent())
{
@@ -110,23 +125,26 @@
endgrent();
# Nobody and shared are special groups used by samba
- foreach my $group (qw/nobody shared/)
+ foreach my $group (qw/nobody shared www/)
{
- my $dn = "cn=$group,ou=Groups,$ldapBase";
+ $dn = "cn=$group,ou=Groups,$ldapBase";
utf8::upgrade($dn);
+
$dnmap->{$group}->{group} = $dn;
+
+ $ldif->{$dn}->{objectClass} = [ qw(posixGroup) ];
@{$ldif->{$dn}}{'cn','userPassword','gidNumber','memberUid'} = getgrnam($group);
- push @{$ldif->{$dn}->{objectClass}}, 'posixGroup';
+ $ldif->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $ldif->{$dn}->{userPassword} =~ m/^\{/;
+ $ldif->{$dn}->{description} = $ldif->{$dnmap->{$key}->{user}}->{cn} if exists $ldif->{$dnmap->{$key}->{user}}->{cn};
+ $ldif->{$dn}->{memberUid} = [ split /\s+/, $ldif->{$dn}->{memberUid} ];
+
if ($group eq 'shared'){
push @{$ldif->{$dn}->{objectClass}}, 'mailboxRelatedObject';
$ldif->{$dn}->{mail} = "everyone\@$DomainName";
}
- $ldif->{$dn}->{userPassword} =~ s/^/{CRYPT}/ unless $ldif->{$dn}->{userPassword} =~ m/^\{/;
- $ldif->{$dn}->{memberUid} = [ split /\s+/, $ldif->{$dn}->{memberUid} ];
}
endgrent();
-
# Read in samba user details
if ( -f "$schema" and -x '/usr/bin/pdbedit' )
{