/[smeserver]/rpms/e-smith-base+ldap/sme8/e-smith-base+ldap-4.19.1-import_fixes.patch
ViewVC logotype

Contents of /rpms/e-smith-base+ldap/sme8/e-smith-base+ldap-4.19.1-import_fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Tue Oct 7 19:21:54 2008 UTC (16 years, 1 month ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New streams

1 diff -Nur -x '*.orig' -x '*.rej' e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups
2 --- e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups 2008-04-21 16:15:45.000000000 +0200
3 +++ mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups 2008-04-16 15:53:18.000000000 +0200
4 @@ -7,12 +7,12 @@
5 next unless ($group_info->{$group});
6
7 my ($name, $passwd, $gid, $members) = @{$group_info->{$group}};
8 -
9 +
10 $OUT .= "dn: cn=$group,ou=Groups,$ldapBase\n";
11
12 if ($mapping{$group})
13 {
14 - my ($dname, $rid) = @{$mapping{$group}};
15 + my ($dname, $sid) = @{$mapping{$group}};
16
17 $OUT .= utf8("objectClass: posixGroup\n");
18 $OUT .= utf8("objectClass: sambaGroupMapping\n");
19 @@ -21,12 +21,17 @@
20 $OUT .= utf8("gidNumber: $gid\n");
21 foreach (split(/,/, $members || ""))
22 {
23 - $OUT .= utf8("memberUid: $_\n");
24 + $OUT .= utf8("memberUid: $_\n");
25 + }
26 + if ($name eq 'nobody'){
27 + foreach(@machines){
28 + $OUT .= utf8("memberUid: $_\n");
29 + }
30 }
31 $OUT .= utf8("description: Local Unix group\n");
32 $OUT .= utf8("displayName: $dname\n");
33 $OUT .= utf8("sambaGroupType: 2\n");
34 - $OUT .= utf8("sambaSID: $local_sid" . "-" . "$rid\n\n");
35 + $OUT .= utf8("sambaSID: $sid\n\n");
36 }
37 else
38 {
39 @@ -36,9 +41,10 @@
40 $OUT .= utf8("gidNumber: $gid\n");
41 foreach (split(/,/, $members || ""))
42 {
43 - $OUT .= utf8("memberUid: $_\n");
44 + $OUT .= utf8("memberUid: $_\n");
45 }
46 $OUT .= "\n";
47 }
48 }
49 }
50 +
51 diff -Nur -x '*.orig' -x '*.rej' e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50machines mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50machines
52 --- e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50machines 1970-01-01 01:00:00.000000000 +0100
53 +++ mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50machines 2008-04-21 16:14:40.000000000 +0200
54 @@ -0,0 +1,49 @@
55 +{
56 + my $passwd_info = parse_file("/etc/passwd", @machines);
57 +
58 + foreach my $machine (@machines)
59 + {
60 + # Skip machine in db but not in /etc/passwd.
61 + next unless ($passwd_info->{$machine});
62 +
63 + my ($name, undef, $uid, $gid, $comment, $home, $shell)
64 + = @{$passwd_info->{$machine}};
65 +
66 + my $smbpasswd_info = parse_file("/etc/smbpasswd", uc($machine));
67 +
68 + my (undef, undef, $sambaLMPassword, $sambaNTPassword, $sambaAcctFlags, undef)
69 + = @{$smbpasswd_info->{uc($machine)}};
70 +
71 + my $sambaSID = `/usr/bin/net sam show $name -s /etc/samba/smb-pre-ldap.conf`;
72 + $sambaSID =~ s/(.*) is a (.*) with SID (.+)/$3/;
73 + chomp($sambaSID);
74 +
75 + $OUT .= utf8("dn: uid=$name,ou=Computers,$ldapBase\n");
76 + $OUT .= utf8("objectClass: account\n");
77 + $OUT .= utf8("objectClass: posixAccount\n");
78 + $OUT .= utf8("objectClass: shadowAccount\n");
79 + $OUT .= utf8("objectClass: sambaSamAccount\n") if ($sambaSID ne '');
80 + $OUT .= utf8("objectClass: top\n");
81 + $OUT .= utf8("cn: $name\n");
82 + $OUT .= utf8("uid: $name\n");
83 + $OUT .= utf8("gecos: " . ($comment || "Hostname account for $name") . "\n");
84 + $OUT .= utf8("uidNumber: $uid\n");
85 + $OUT .= utf8("gidNumber: $gid\n");
86 + $OUT .= utf8("userPassword: {crypt}" . ($passwd || "*") . "\n");
87 + $OUT .= utf8("homeDirectory: " . ($home || '/noexistingpath') . "\n");
88 + $OUT .= utf8("loginShell: " . ($shell || "/bin/false") . "\n");
89 + $OUT .= utf8("shadowLastChange: " . ($lastchange || int(time / (24 * 3600))) . "\n");
90 + $OUT .= utf8("shadowMin: " . ($min || "-1") . "\n");
91 + $OUT .= utf8("shadowMax: " . ($max || "99999") . "\n");
92 + $OUT .= utf8("shadowWarning: " . ($warning || "7") . "\n");
93 + $OUT .= utf8("shadowInactive: " . ($inactive || "-1") . "\n");
94 + $OUT .= utf8("shadowExpire: " . ($expire || "-1") . "\n");
95 + $OUT .= utf8("sambaSID: $sambaSID\n") if ($sambaSID ne '');
96 + $OUT .= utf8("sambaLMPassword: $sambaLMPassword\n") if $sambaLMPassword;
97 + $OUT .= utf8("sambaNTPassword: $sambaNTPassword\n") if $sambaNTPassword;
98 + $OUT .= utf8("sambaPwdLastSet: 1207907915\n") if ($sambaLMPassword && $sambaNTPassword); # sambaPwdLastSet needs to be not null
99 + $OUT .= utf8("sambaAcctFlags: $sambaAcctFlags\n") if $sambaAcctFlags;
100 + $OUT .= utf8("shadowFlag: " . ($flag || "-1") . "\n\n");
101 + }
102 +}
103 +
104 diff -Nur -x '*.orig' -x '*.rej' e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users
105 --- e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users 2008-04-21 16:15:45.000000000 +0200
106 +++ mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users 2008-04-21 16:14:25.000000000 +0200
107 @@ -1,21 +1,32 @@
108 {
109 my $passwd_info = parse_file("/etc/passwd", @users);
110 my $shadow_info = parse_file("/etc/shadow", @users);
111 -
112 + my $smbpasswd_info = parse_file("/etc/smbpasswd", @users);
113 +
114 foreach my $user (@users)
115 {
116 # Skip users in db but not in /etc/passwd.
117 - next unless ($passwd_info->{$user});
118 + next unless ($passwd_info->{$user});
119
120 my ($name, undef, $uid, $gid, $comment, $home, $shell)
121 = @{$passwd_info->{$user}};
122 my (undef, $passwd, $lastchange, $min, $max, $warning, $inactive,
123 $expire, $flag) = @{$shadow_info->{$user}};
124
125 + # Import the sambaSID of the user
126 + my $sambaSID = `/usr/bin/net sam show $user -s /etc/samba/smb-pre-ldap.conf 2> /dev/null`;
127 + $sambaSID =~ s/(.*)\\$user is a (.*) with SID (.+)/$3/;
128 + chomp($sambaSID);
129 +
130 + # Import smb passwords (NT and LM) from smbpasswd
131 + my (undef, undef, $sambaLMPassword, $sambaNTPassword, $sambaAcctFlags, undef)
132 + = @{$smbpasswd_info->{$user}} if ($sambaSID ne '');
133 +
134 $OUT .= utf8("dn: uid=$user,ou=Users,$ldapBase\n");
135 $OUT .= utf8("objectClass: account\n");
136 $OUT .= utf8("objectClass: posixAccount\n");
137 $OUT .= utf8("objectClass: shadowAccount\n");
138 + $OUT .= utf8("objectClass: sambaSamAccount\n") if ($sambaSID ne '');
139 $OUT .= utf8("objectClass: top\n");
140 $OUT .= utf8("cn: $name\n");
141 $OUT .= utf8("uid: $name\n");
142 @@ -31,6 +42,11 @@
143 $OUT .= utf8("shadowWarning: " . ($warning || "7") . "\n");
144 $OUT .= utf8("shadowInactive: " . ($inactive || "-1") . "\n");
145 $OUT .= utf8("shadowExpire: " . ($expire || "-1") . "\n");
146 + $OUT .= utf8("sambaSID: $sambaSID\n") if ($sambaSID ne '');
147 + $OUT .= utf8("sambaLMPassword: $sambaLMPassword\n") if $sambaLMPassword;
148 + $OUT .= utf8("sambaNTPassword: $sambaNTPassword\n") if $sambaNTPassword;
149 + $OUT .= utf8("sambaPwdLastSet: 1207907915\n") if ($sambaLMPassword && $sambaNTPassword); # sambaPwdLastSet needs to be not null
150 + $OUT .= utf8("sambaAcctFlags: $sambaAcctFlags\n") if $sambaAcctFlags;
151 $OUT .= utf8("shadowFlag: " . ($flag || "-1") . "\n\n");
152 }
153 }
154 diff -Nur -x '*.orig' -x '*.rej' e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin
155 --- e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin 2008-04-21 16:15:45.000000000 +0200
156 +++ mezzanine_patched_e-smith-base+ldap-4.19.1/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/template-begin 2008-04-21 16:13:59.000000000 +0200
157 @@ -5,28 +5,45 @@
158
159 $a = esmith::AccountsDB->open_ro;
160 $c = esmith::ConfigDB->open_ro;
161 +
162 + # Create a minimal config file for migration
163 + $domain_master = $smb{DomainMaster} || "no";
164 + $workgroup = $smb{Workgroup};
165 +
166 + open(PRELDAPCONF,">/etc/samba/smb-pre-ldap.conf");
167 + print PRELDAPCONF "domain logons = $smb{DomainMaster}\nworkgroup = $smb{Workgroup}";
168 + close(PRELDAPCONF);
169 +
170 $ldapBase = esmith::util::ldapBase ($DomainName);
171 - $local_sid = `/usr/bin/net getlocalsid -s /dev/null -n $smb{ServerName}`;
172 + $local_sid = `/usr/bin/net getlocalsid -s /etc/samba/smb-pre-ldap.conf -n $smb{ServerName}`;
173 $local_sid =~ s/SID.*is: (.+)/$1/;
174 chomp($local_sid);
175 sub utf8
176 {
177 - my $t = shift;
178 - utf8::encode($t);
179 - return $t;
180 + my $t = shift;
181 + utf8::encode($t);
182 + return $t;
183 }
184 # Basic entries to init.
185 - @ous = ("Groups", "People", "Users"); # ous for Organizational Units.
186 + @ous = ("Groups", "People", "Users", "Computers"); # ous for Organizational Units.
187 @users = ("root", "ntp", "www", "admin", "public");
188 @groups = ("shared", "slocate", "nobody", @users);
189 + @machines = ();
190 +
191 + # Create list of group to map
192 + my @groupmap = `/usr/bin/net groupmap list -s /etc/samba/smb-pre-ldap.conf`;
193 + %mapping = ();
194
195 - # Groups to map with samba, their names and their rids.
196 - %mapping =
197 - (
198 - 'admin' => ['Domain Admins', "512"],
199 - 'shared' => ['Domain Users', "513"],
200 - 'nobody' => ['Domain Guests', "514"]
201 - );
202 + foreach (@groupmap)
203 + {
204 + chomp($_);
205 + my $g = $_;
206 + $g =~ /(.+) \((.+)\) -> (.+)/;
207 + my $dname = $1;
208 + my $sid = $2;
209 + my $name = $3;
210 + $mapping{$name} = ["$dname","$sid"];
211 + }
212
213 # Add users and groups from db.
214 foreach my $account ($a->users, $a->groups)
215 @@ -34,17 +51,22 @@
216 @users = (@users, $account->key);
217 @groups = (@groups, $account->key);
218 }
219 -
220 +
221 + #Add machines
222 + foreach ($a->get_all_by_prop('type'=>'machine')){
223 + @machines = (@machines,$_->key);
224 + }
225 +
226 # Parse a file with fields separated by ':' (ie /etc/{group,passwd,shadow}).
227 sub parse_file
228 {
229 - # We are only interested in @keep accounts.
230 + # We are only interested in @keep accounts.
231 my ($file, @keep) = @_;
232 -
233 +
234 my %result = ();
235 -
236 +
237 open(FILE, $file) or die("open: $!");
238 -
239 +
240 my @line;
241 while(<FILE>)
242 {
243 @@ -56,7 +78,7 @@
244 if ($line[0] eq $_);
245 }
246 }
247 -
248 +
249 return \%result;
250 }
251 $OUT = "";

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed