1 |
jpp |
1.1 |
diff -Nur -x '*.orig' -x '*.rej' e-smith-loginscript-0.2/root/etc/e-smith/events/actions/conf-loginscript mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/events/actions/conf-loginscript |
2 |
|
|
--- e-smith-loginscript-0.2/root/etc/e-smith/events/actions/conf-loginscript 2001-08-30 02:41:39.000000000 -0500 |
3 |
|
|
+++ mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/events/actions/conf-loginscript 2006-05-08 21:29:52.000000000 -0500 |
4 |
|
|
@@ -30,7 +30,7 @@ |
5 |
|
|
# Configure login script |
6 |
|
|
#------------------------------------------------------------ |
7 |
|
|
|
8 |
|
|
-esmith::util::processTemplate (\%conf, "/home/netlogon/netlogon.bat"); |
9 |
|
|
+esmith::util::processTemplate (\%conf, "/home/e-smith/files/samba/netlogon/netlogon.bat"); |
10 |
|
|
|
11 |
|
|
exit (0); |
12 |
|
|
|
13 |
|
|
diff -Nur -x '*.orig' -x '*.rej' e-smith-loginscript-0.2/root/etc/e-smith/templates/etc/smb.conf/50homes-preexec mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/templates/etc/smb.conf/50homes-preexec |
14 |
|
|
--- e-smith-loginscript-0.2/root/etc/e-smith/templates/etc/smb.conf/50homes-preexec 2001-08-30 02:52:27.000000000 -0500 |
15 |
|
|
+++ mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/templates/etc/smb.conf/50homes-preexec 2006-05-08 21:36:42.000000000 -0500 |
16 |
|
|
@@ -1,2 +1 @@ |
17 |
|
|
- root preexec = "/usr/local/bin/generate_netlogon /home/netlogon/netlogon.template /home/e-smith/files/users/%U/home/netlogon.bat %U %m %a %T" |
18 |
|
|
- |
19 |
|
|
+ root preexec = "/usr/local/bin/generate_netlogon /home/e-smith/files/samba/netlogon/netlogon.template /home/e-smith/files/users/%U/home/netlogon.bat %U %m %a %T" |
20 |
|
|
diff -Nur -x '*.orig' -x '*.rej' e-smith-loginscript-0.2/root/etc/e-smith/web/functions/loginscript mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/web/functions/loginscript |
21 |
|
|
--- e-smith-loginscript-0.2/root/etc/e-smith/web/functions/loginscript 2001-08-30 03:15:06.000000000 -0500 |
22 |
|
|
+++ mezzanine_patched_e-smith-loginscript-0.2/root/etc/e-smith/web/functions/loginscript 2006-05-08 21:40:17.000000000 -0500 |
23 |
|
|
@@ -91,10 +91,10 @@ |
24 |
|
|
|
25 |
|
|
if ( $netlogon eq '' ) |
26 |
|
|
{ |
27 |
|
|
- if ( -e '/home/netlogon/netlogon.template' ) |
28 |
|
|
+ if ( -e '/home/e-smith/files/samba/netlogon/netlogon.template' ) |
29 |
|
|
{ |
30 |
|
|
- open ( NETLOGON, '< /home/netlogon/netlogon.template' ) |
31 |
|
|
- || die 'Couldn\'t open /home/netlogon/netlogon.template file!'; |
32 |
|
|
+ open ( NETLOGON, '< /home/e-smith/files/samba/netlogon/netlogon.template' ) |
33 |
|
|
+ || die 'Couldn\'t open /home/e-smith/files/samba/netlogon/netlogon.template file!'; |
34 |
|
|
my @netlogon = <NETLOGON>; |
35 |
|
|
close NETLOGON; |
36 |
|
|
|
37 |
|
|
@@ -226,8 +226,8 @@ |
38 |
|
|
# Write the new netlogon file (if there were no errors) |
39 |
|
|
#------------------------------------------------------ |
40 |
|
|
|
41 |
|
|
- open ( NETLOGON, '> /home/netlogon/netlogon.template' ) |
42 |
|
|
- || die 'Couldn\'t open /home/netlogon/netlogon.template file!'; |
43 |
|
|
+ open ( NETLOGON, '> /home/e-smith/files/samba/netlogon/netlogon.template' ) |
44 |
|
|
+ || die 'Couldn\'t open /home/e-smith/files/samba/netlogon/netlogon.template file!'; |
45 |
|
|
|
46 |
|
|
print NETLOGON $netlogon; |
47 |
|
|
|
48 |
|
|
diff -Nur -x '*.orig' -x '*.rej' e-smith-loginscript-0.2/root/usr/local/bin/generate_netlogon mezzanine_patched_e-smith-loginscript-0.2/root/usr/local/bin/generate_netlogon |
49 |
|
|
--- e-smith-loginscript-0.2/root/usr/local/bin/generate_netlogon 2001-08-30 02:51:54.000000000 -0500 |
50 |
|
|
+++ mezzanine_patched_e-smith-loginscript-0.2/root/usr/local/bin/generate_netlogon 2006-05-08 21:41:15.000000000 -0500 |
51 |
|
|
@@ -1,239 +1,239 @@ |
52 |
|
|
-#!/usr/bin/perl -w |
53 |
|
|
- |
54 |
|
|
-my $netlogonTemplate = $ARGV[0]; |
55 |
|
|
-my $netlogonFile = $ARGV[1]; |
56 |
|
|
-my $curUser = $ARGV[2]; |
57 |
|
|
-my $curMachine = $ARGV[3]; |
58 |
|
|
-my $curArch = $ARGV[4]; |
59 |
|
|
-my $time = $ARGV[5]; |
60 |
|
|
- |
61 |
|
|
-die "Netlogon template argument missing.\n" unless defined ($netlogonTemplate); |
62 |
|
|
-die "Netlogon file argument missing.\n" unless defined ($netlogonFile); |
63 |
|
|
-die "User argument missing.\n" unless defined ($curUser); |
64 |
|
|
-die "Machine argument missing.\n" unless defined ($curMachine); |
65 |
|
|
-die "Arch argument missing.\n" unless defined ($curArch); |
66 |
|
|
-die "Time argument missing.\n" unless defined ($time); |
67 |
|
|
- |
68 |
|
|
-package esmith; |
69 |
|
|
- |
70 |
|
|
-use strict; |
71 |
|
|
- |
72 |
|
|
-use esmith::util; |
73 |
|
|
- |
74 |
|
|
-BEGIN |
75 |
|
|
-{ |
76 |
|
|
- # Clear PATH and related environment variables so that calls to |
77 |
|
|
- # external programs do not cause results to be tainted. See |
78 |
|
|
- # "perlsec" manual page for details. |
79 |
|
|
- |
80 |
|
|
- $ENV {'PATH'} = ''; |
81 |
|
|
- $ENV {'SHELL'} = '/bin/bash'; |
82 |
|
|
- delete $ENV {'ENV'}; |
83 |
|
|
-} |
84 |
|
|
- |
85 |
|
|
-esmith::util::setRealToEffective (); |
86 |
|
|
- |
87 |
|
|
-my %accounts; |
88 |
|
|
-tie %accounts, 'esmith::config', '/home/e-smith/accounts'; |
89 |
|
|
- |
90 |
|
|
- |
91 |
|
|
-# ------------------------------------------------ |
92 |
|
|
-# Open and read in the template netlogon.bat file. |
93 |
|
|
-# ------------------------------------------------ |
94 |
|
|
- |
95 |
|
|
-open ( INFILE, "< $netlogonTemplate" ) || |
96 |
|
|
- die "Couldn't open the input file '$netlogonTemplate' : $!\n"; |
97 |
|
|
- |
98 |
|
|
-my @infile = <INFILE>; |
99 |
|
|
- |
100 |
|
|
-close ( INFILE ); |
101 |
|
|
- |
102 |
|
|
-# -------------------------------------------------- |
103 |
|
|
-# Open an output file for the generated batch script |
104 |
|
|
-# -------------------------------------------------- |
105 |
|
|
- |
106 |
|
|
-open ( NETLOGON, "> $netlogonFile" ) || |
107 |
|
|
- die "Couldn't open the output batch file: '$netlogonFile' : $!\n"; |
108 |
|
|
- |
109 |
|
|
-print NETLOGON "\@REM $curUser logging in from a $curArch box \015\n"; |
110 |
|
|
-print NETLOGON "\@REM called $curMachine on $time\015\n"; |
111 |
|
|
- |
112 |
|
|
-my $line; |
113 |
|
|
-my @activelevels = ( 1 ); |
114 |
|
|
-my $level = 0; |
115 |
|
|
- |
116 |
|
|
-foreach $line ( @infile ) |
117 |
|
|
-{ |
118 |
|
|
- if ( ( index $line, '#if' ) == 0 ) |
119 |
|
|
- { |
120 |
|
|
- if ( $activelevels[ $level ] ) |
121 |
|
|
- { |
122 |
|
|
- if ( ( index $line, '#ifg' ) == 0 ) |
123 |
|
|
- { |
124 |
|
|
- $level++; |
125 |
|
|
- my $grouplist = $line; |
126 |
|
|
- |
127 |
|
|
- ### Clean the line and get a list of groups: |
128 |
|
|
- $grouplist =~ s/\#ifg|\s|\n|\015//g; |
129 |
|
|
- my @groups = split ( ',', $grouplist ); |
130 |
|
|
- |
131 |
|
|
- ### Check if the curUser is in any of the groups: |
132 |
|
|
- $activelevels[ $level ] = 0; |
133 |
|
|
- my $group; |
134 |
|
|
- foreach $group ( @groups ) |
135 |
|
|
- { |
136 |
|
|
- if ( !$activelevels[ $level ] ) |
137 |
|
|
- { |
138 |
|
|
- $activelevels[ $level ] = isInGroup($curUser, $group); |
139 |
|
|
- } |
140 |
|
|
- } |
141 |
|
|
- |
142 |
|
|
- ### If the user is in the list, add a comment to the batch file: |
143 |
|
|
- if ( $activelevels[ $level ] ) |
144 |
|
|
- { |
145 |
|
|
- print NETLOGON "REM $line"; |
146 |
|
|
- } |
147 |
|
|
- } |
148 |
|
|
- elsif ( ( index $line, '#ifu' ) == 0 ) |
149 |
|
|
- { |
150 |
|
|
- $level++; |
151 |
|
|
- my $userlist = $line; |
152 |
|
|
- |
153 |
|
|
- ### Clean the line and get a list of users: |
154 |
|
|
- $userlist =~ s/\#ifu|\s|\n|\015//g; |
155 |
|
|
- my @users = split ( ',', $userlist ); |
156 |
|
|
- |
157 |
|
|
- ### Check if the curUser matches any in the list: |
158 |
|
|
- $activelevels[ $level ] = 0; |
159 |
|
|
- my $user; |
160 |
|
|
- foreach $user ( @users ) |
161 |
|
|
- { |
162 |
|
|
- if ( !$activelevels[ $level ] ) |
163 |
|
|
- { |
164 |
|
|
- $activelevels[ $level ] = ( $curUser eq $user ); |
165 |
|
|
- } |
166 |
|
|
- } |
167 |
|
|
- |
168 |
|
|
- ### If the user is in the list, add a comment to the batch file: |
169 |
|
|
- if ( $activelevels[ $level ] ) |
170 |
|
|
- { |
171 |
|
|
- print NETLOGON "REM $line"; |
172 |
|
|
- } |
173 |
|
|
- } |
174 |
|
|
- elsif ( ( index $line, '#ifm' ) == 0 ) |
175 |
|
|
- { |
176 |
|
|
- $level++; |
177 |
|
|
- my $machinelist = $line; |
178 |
|
|
- |
179 |
|
|
- ### Clean the line and get a list of machines: |
180 |
|
|
- $machinelist =~ s/\#ifm|\s|\n|\015//g; |
181 |
|
|
- my @machines = split ( ',', $machinelist ); |
182 |
|
|
- |
183 |
|
|
- ### Check if the curMachine matches any in the list: |
184 |
|
|
- $activelevels[ $level ] = 0; |
185 |
|
|
- my $machine; |
186 |
|
|
- foreach $machine ( @machines ) |
187 |
|
|
- { |
188 |
|
|
- if ( !$activelevels[ $level ] ) |
189 |
|
|
- { |
190 |
|
|
- $activelevels[ $level ] = ( $curMachine eq $machine ); |
191 |
|
|
- } |
192 |
|
|
- } |
193 |
|
|
- |
194 |
|
|
- ### If the machine is in the list, add a comment to the batch file: |
195 |
|
|
- if ( $activelevels[ $level ] ) |
196 |
|
|
- { |
197 |
|
|
- print NETLOGON "REM $line"; |
198 |
|
|
- } |
199 |
|
|
- } |
200 |
|
|
- elsif ( ( index $line, '#ifa' ) == 0 ) |
201 |
|
|
- { |
202 |
|
|
- $level++; |
203 |
|
|
- my $archlist = $line; |
204 |
|
|
- |
205 |
|
|
- ### Clean the line and get a list of architectures: |
206 |
|
|
- $archlist =~ s/\#ifa|\s|\n|\015//g; |
207 |
|
|
- my @archs = split ( ',', $archlist ); |
208 |
|
|
- |
209 |
|
|
- ### Check if the curArch matches any in the list: |
210 |
|
|
- $activelevels[ $level ] = 0; |
211 |
|
|
- my $arch; |
212 |
|
|
- foreach $arch ( @archs ) |
213 |
|
|
- { |
214 |
|
|
- if ( !$activelevels[ $level ] ) |
215 |
|
|
- { |
216 |
|
|
- $activelevels[ $level ] = ( $curArch eq $arch ); |
217 |
|
|
- } |
218 |
|
|
- } |
219 |
|
|
- |
220 |
|
|
- ### If the arch is in the list, add a comment to the batch file: |
221 |
|
|
- if ( $activelevels[ $level ] ) |
222 |
|
|
- { |
223 |
|
|
- print NETLOGON "REM $line"; |
224 |
|
|
- } |
225 |
|
|
- } |
226 |
|
|
- else |
227 |
|
|
- { |
228 |
|
|
- die "Unknown '#if' statement found!\n"; |
229 |
|
|
- } |
230 |
|
|
- |
231 |
|
|
- } |
232 |
|
|
- else |
233 |
|
|
- { |
234 |
|
|
- $level++; |
235 |
|
|
- $activelevels[ $level ] = 0; |
236 |
|
|
- } |
237 |
|
|
- } |
238 |
|
|
- elsif ( ( index $line, '#endif' ) == 0 ) |
239 |
|
|
- { |
240 |
|
|
- die "Stray '#endif' found!\n" unless ( $level > 0 ); |
241 |
|
|
- if ( $activelevels[ $level ] ) |
242 |
|
|
- { |
243 |
|
|
- print NETLOGON "REM $line"; |
244 |
|
|
- } |
245 |
|
|
- $level--; |
246 |
|
|
- } |
247 |
|
|
- elsif ( $activelevels[ $level ] ) |
248 |
|
|
- { |
249 |
|
|
- print NETLOGON "$line"; |
250 |
|
|
- } |
251 |
|
|
-} |
252 |
|
|
- |
253 |
|
|
-die "Not enough '#endif' lines in template!\n" unless $level == 0; |
254 |
|
|
- |
255 |
|
|
-close ( NETLOGON ); |
256 |
|
|
- |
257 |
|
|
-chmod ( 0744, "$netlogonFile" ); |
258 |
|
|
- |
259 |
|
|
-exit (0); |
260 |
|
|
- |
261 |
|
|
-# -------------------------------------------------- |
262 |
|
|
-# Subroutine to check if a given user is in a group: |
263 |
|
|
-# -------------------------------------------------- |
264 |
|
|
- |
265 |
|
|
-sub isInGroup($$) |
266 |
|
|
-{ |
267 |
|
|
- my ($user, $group) = @_; |
268 |
|
|
- |
269 |
|
|
- my $value = $accounts{$group}; |
270 |
|
|
- |
271 |
|
|
- if ( defined ($value) ) |
272 |
|
|
- { |
273 |
|
|
- my ($type, %properties) = split (/\|/, $value); |
274 |
|
|
- if ($type eq 'group') |
275 |
|
|
- { |
276 |
|
|
- my @members = split (/,/, $properties {'Members'}); |
277 |
|
|
- my $member; |
278 |
|
|
- # TODO: grep (/^$user$/, @members) |
279 |
|
|
- foreach $member ( @members ) |
280 |
|
|
- { |
281 |
|
|
- if ( $member eq $user ) |
282 |
|
|
- { |
283 |
|
|
- return 1; |
284 |
|
|
- } |
285 |
|
|
- } |
286 |
|
|
- } |
287 |
|
|
- } |
288 |
|
|
- return 0; |
289 |
|
|
-} |
290 |
|
|
- |
291 |
|
|
+#!/usr/bin/perl -w |
292 |
|
|
+ |
293 |
|
|
+my $netlogonTemplate = $ARGV[0]; |
294 |
|
|
+my $netlogonFile = $ARGV[1]; |
295 |
|
|
+my $curUser = $ARGV[2]; |
296 |
|
|
+my $curMachine = $ARGV[3]; |
297 |
|
|
+my $curArch = $ARGV[4]; |
298 |
|
|
+my $time = $ARGV[5]; |
299 |
|
|
+ |
300 |
|
|
+die "Netlogon template argument missing.\n" unless defined ($netlogonTemplate); |
301 |
|
|
+die "Netlogon file argument missing.\n" unless defined ($netlogonFile); |
302 |
|
|
+die "User argument missing.\n" unless defined ($curUser); |
303 |
|
|
+die "Machine argument missing.\n" unless defined ($curMachine); |
304 |
|
|
+die "Arch argument missing.\n" unless defined ($curArch); |
305 |
|
|
+die "Time argument missing.\n" unless defined ($time); |
306 |
|
|
+ |
307 |
|
|
+package esmith; |
308 |
|
|
+ |
309 |
|
|
+use strict; |
310 |
|
|
+ |
311 |
|
|
+use esmith::util; |
312 |
|
|
+ |
313 |
|
|
+BEGIN |
314 |
|
|
+{ |
315 |
|
|
+ # Clear PATH and related environment variables so that calls to |
316 |
|
|
+ # external programs do not cause results to be tainted. See |
317 |
|
|
+ # "perlsec" manual page for details. |
318 |
|
|
+ |
319 |
|
|
+ $ENV {'PATH'} = ''; |
320 |
|
|
+ $ENV {'SHELL'} = '/bin/bash'; |
321 |
|
|
+ delete $ENV {'ENV'}; |
322 |
|
|
+} |
323 |
|
|
+ |
324 |
|
|
+esmith::util::setRealToEffective (); |
325 |
|
|
+ |
326 |
|
|
+my %accounts; |
327 |
|
|
+tie %accounts, 'esmith::config', '/home/e-smith/db/accounts'; |
328 |
|
|
+ |
329 |
|
|
+ |
330 |
|
|
+# ------------------------------------------------ |
331 |
|
|
+# Open and read in the template netlogon.bat file. |
332 |
|
|
+# ------------------------------------------------ |
333 |
|
|
+ |
334 |
|
|
+open ( INFILE, "< $netlogonTemplate" ) || |
335 |
|
|
+ die "Couldn't open the input file '$netlogonTemplate' : $!\n"; |
336 |
|
|
+ |
337 |
|
|
+my @infile = <INFILE>; |
338 |
|
|
+ |
339 |
|
|
+close ( INFILE ); |
340 |
|
|
+ |
341 |
|
|
+# -------------------------------------------------- |
342 |
|
|
+# Open an output file for the generated batch script |
343 |
|
|
+# -------------------------------------------------- |
344 |
|
|
+ |
345 |
|
|
+open ( NETLOGON, "> $netlogonFile" ) || |
346 |
|
|
+ die "Couldn't open the output batch file: '$netlogonFile' : $!\n"; |
347 |
|
|
+ |
348 |
|
|
+print NETLOGON "\@REM $curUser logging in from a $curArch box \015\n"; |
349 |
|
|
+print NETLOGON "\@REM called $curMachine on $time\015\n"; |
350 |
|
|
+ |
351 |
|
|
+my $line; |
352 |
|
|
+my @activelevels = ( 1 ); |
353 |
|
|
+my $level = 0; |
354 |
|
|
+ |
355 |
|
|
+foreach $line ( @infile ) |
356 |
|
|
+{ |
357 |
|
|
+ if ( ( index $line, '#if' ) == 0 ) |
358 |
|
|
+ { |
359 |
|
|
+ if ( $activelevels[ $level ] ) |
360 |
|
|
+ { |
361 |
|
|
+ if ( ( index $line, '#ifg' ) == 0 ) |
362 |
|
|
+ { |
363 |
|
|
+ $level++; |
364 |
|
|
+ my $grouplist = $line; |
365 |
|
|
+ |
366 |
|
|
+ ### Clean the line and get a list of groups: |
367 |
|
|
+ $grouplist =~ s/\#ifg|\s|\n|\015//g; |
368 |
|
|
+ my @groups = split ( ',', $grouplist ); |
369 |
|
|
+ |
370 |
|
|
+ ### Check if the curUser is in any of the groups: |
371 |
|
|
+ $activelevels[ $level ] = 0; |
372 |
|
|
+ my $group; |
373 |
|
|
+ foreach $group ( @groups ) |
374 |
|
|
+ { |
375 |
|
|
+ if ( !$activelevels[ $level ] ) |
376 |
|
|
+ { |
377 |
|
|
+ $activelevels[ $level ] = isInGroup($curUser, $group); |
378 |
|
|
+ } |
379 |
|
|
+ } |
380 |
|
|
+ |
381 |
|
|
+ ### If the user is in the list, add a comment to the batch file: |
382 |
|
|
+ if ( $activelevels[ $level ] ) |
383 |
|
|
+ { |
384 |
|
|
+ print NETLOGON "REM $line"; |
385 |
|
|
+ } |
386 |
|
|
+ } |
387 |
|
|
+ elsif ( ( index $line, '#ifu' ) == 0 ) |
388 |
|
|
+ { |
389 |
|
|
+ $level++; |
390 |
|
|
+ my $userlist = $line; |
391 |
|
|
+ |
392 |
|
|
+ ### Clean the line and get a list of users: |
393 |
|
|
+ $userlist =~ s/\#ifu|\s|\n|\015//g; |
394 |
|
|
+ my @users = split ( ',', $userlist ); |
395 |
|
|
+ |
396 |
|
|
+ ### Check if the curUser matches any in the list: |
397 |
|
|
+ $activelevels[ $level ] = 0; |
398 |
|
|
+ my $user; |
399 |
|
|
+ foreach $user ( @users ) |
400 |
|
|
+ { |
401 |
|
|
+ if ( !$activelevels[ $level ] ) |
402 |
|
|
+ { |
403 |
|
|
+ $activelevels[ $level ] = ( $curUser eq $user ); |
404 |
|
|
+ } |
405 |
|
|
+ } |
406 |
|
|
+ |
407 |
|
|
+ ### If the user is in the list, add a comment to the batch file: |
408 |
|
|
+ if ( $activelevels[ $level ] ) |
409 |
|
|
+ { |
410 |
|
|
+ print NETLOGON "REM $line"; |
411 |
|
|
+ } |
412 |
|
|
+ } |
413 |
|
|
+ elsif ( ( index $line, '#ifm' ) == 0 ) |
414 |
|
|
+ { |
415 |
|
|
+ $level++; |
416 |
|
|
+ my $machinelist = $line; |
417 |
|
|
+ |
418 |
|
|
+ ### Clean the line and get a list of machines: |
419 |
|
|
+ $machinelist =~ s/\#ifm|\s|\n|\015//g; |
420 |
|
|
+ my @machines = split ( ',', $machinelist ); |
421 |
|
|
+ |
422 |
|
|
+ ### Check if the curMachine matches any in the list: |
423 |
|
|
+ $activelevels[ $level ] = 0; |
424 |
|
|
+ my $machine; |
425 |
|
|
+ foreach $machine ( @machines ) |
426 |
|
|
+ { |
427 |
|
|
+ if ( !$activelevels[ $level ] ) |
428 |
|
|
+ { |
429 |
|
|
+ $activelevels[ $level ] = ( $curMachine eq $machine ); |
430 |
|
|
+ } |
431 |
|
|
+ } |
432 |
|
|
+ |
433 |
|
|
+ ### If the machine is in the list, add a comment to the batch file: |
434 |
|
|
+ if ( $activelevels[ $level ] ) |
435 |
|
|
+ { |
436 |
|
|
+ print NETLOGON "REM $line"; |
437 |
|
|
+ } |
438 |
|
|
+ } |
439 |
|
|
+ elsif ( ( index $line, '#ifa' ) == 0 ) |
440 |
|
|
+ { |
441 |
|
|
+ $level++; |
442 |
|
|
+ my $archlist = $line; |
443 |
|
|
+ |
444 |
|
|
+ ### Clean the line and get a list of architectures: |
445 |
|
|
+ $archlist =~ s/\#ifa|\s|\n|\015//g; |
446 |
|
|
+ my @archs = split ( ',', $archlist ); |
447 |
|
|
+ |
448 |
|
|
+ ### Check if the curArch matches any in the list: |
449 |
|
|
+ $activelevels[ $level ] = 0; |
450 |
|
|
+ my $arch; |
451 |
|
|
+ foreach $arch ( @archs ) |
452 |
|
|
+ { |
453 |
|
|
+ if ( !$activelevels[ $level ] ) |
454 |
|
|
+ { |
455 |
|
|
+ $activelevels[ $level ] = ( $curArch eq $arch ); |
456 |
|
|
+ } |
457 |
|
|
+ } |
458 |
|
|
+ |
459 |
|
|
+ ### If the arch is in the list, add a comment to the batch file: |
460 |
|
|
+ if ( $activelevels[ $level ] ) |
461 |
|
|
+ { |
462 |
|
|
+ print NETLOGON "REM $line"; |
463 |
|
|
+ } |
464 |
|
|
+ } |
465 |
|
|
+ else |
466 |
|
|
+ { |
467 |
|
|
+ die "Unknown '#if' statement found!\n"; |
468 |
|
|
+ } |
469 |
|
|
+ |
470 |
|
|
+ } |
471 |
|
|
+ else |
472 |
|
|
+ { |
473 |
|
|
+ $level++; |
474 |
|
|
+ $activelevels[ $level ] = 0; |
475 |
|
|
+ } |
476 |
|
|
+ } |
477 |
|
|
+ elsif ( ( index $line, '#endif' ) == 0 ) |
478 |
|
|
+ { |
479 |
|
|
+ die "Stray '#endif' found!\n" unless ( $level > 0 ); |
480 |
|
|
+ if ( $activelevels[ $level ] ) |
481 |
|
|
+ { |
482 |
|
|
+ print NETLOGON "REM $line"; |
483 |
|
|
+ } |
484 |
|
|
+ $level--; |
485 |
|
|
+ } |
486 |
|
|
+ elsif ( $activelevels[ $level ] ) |
487 |
|
|
+ { |
488 |
|
|
+ print NETLOGON "$line"; |
489 |
|
|
+ } |
490 |
|
|
+} |
491 |
|
|
+ |
492 |
|
|
+die "Not enough '#endif' lines in template!\n" unless $level == 0; |
493 |
|
|
+ |
494 |
|
|
+close ( NETLOGON ); |
495 |
|
|
+ |
496 |
|
|
+chmod ( 0744, "$netlogonFile" ); |
497 |
|
|
+ |
498 |
|
|
+exit (0); |
499 |
|
|
+ |
500 |
|
|
+# -------------------------------------------------- |
501 |
|
|
+# Subroutine to check if a given user is in a group: |
502 |
|
|
+# -------------------------------------------------- |
503 |
|
|
+ |
504 |
|
|
+sub isInGroup($$) |
505 |
|
|
+{ |
506 |
|
|
+ my ($user, $group) = @_; |
507 |
|
|
+ |
508 |
|
|
+ my $value = $accounts{$group}; |
509 |
|
|
+ |
510 |
|
|
+ if ( defined ($value) ) |
511 |
|
|
+ { |
512 |
|
|
+ my ($type, %properties) = split (/\|/, $value); |
513 |
|
|
+ if ($type eq 'group') |
514 |
|
|
+ { |
515 |
|
|
+ my @members = split (/,/, $properties {'Members'}); |
516 |
|
|
+ my $member; |
517 |
|
|
+ # TODO: grep (/^$user$/, @members) |
518 |
|
|
+ foreach $member ( @members ) |
519 |
|
|
+ { |
520 |
|
|
+ if ( $member eq $user ) |
521 |
|
|
+ { |
522 |
|
|
+ return 1; |
523 |
|
|
+ } |
524 |
|
|
+ } |
525 |
|
|
+ } |
526 |
|
|
+ } |
527 |
|
|
+ return 0; |
528 |
|
|
+} |
529 |
|
|
+ |