Korrekturen im Code, es wird langsam ....
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / samba.cgi
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The IPFire Team
8
9 use strict;
10 # enable only the following on debugging purpose
11 use warnings;
12 use CGI::Carp 'fatalsToBrowser';
13
14 require '/var/ipfire/general-functions.pl';
15 require "${General::swroot}/lang.pl";
16 require "${General::swroot}/header.pl";
17
18 my %sambasettings = ();
19 my %cgisettings = ();
20 my %checked = ();
21 my %netsettings = ();
22 my %ovpnsettings = ();
23 my $message = "";
24 my $errormessage = "";
25 my $defaultoption= "[Share]\npath = /var/samba/share1\ncomment = Share - Public Access\nbrowseable = yes\nwriteable = yes\ncreate mask = 0777\ndirectory mask = 0777\nguest ok = yes\npublic = yes\nforce user = samba";
26 my $userentry = "";
27 my @user = ();
28 my @userline = ();
29 my @proto = ();
30 my %selected= () ;
31 my $userfile = "/var/ipfire/samba/private/smbpasswd";
32 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
33 &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
34
35 ############################################################################################################################
36 ############################################# Samba Dienste fr Statusberprfung ##########################################
37
38 my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd','Winbind Daemon' => 'winbindd');
39
40 &Header::showhttpheaders();
41
42 ############################################################################################################################
43 #################################### Initialisierung von Samba Sharess fr die Verarbeitung ################################
44
45 my @Zeilen= ();
46 my @Shares= ();
47 my $shareentry = "";
48 my $shareconfigentry = "";
49 my @shareconfigline = ();
50 my $shareoption = '';
51 my @shares = ();
52 my @shareline = ();
53 my $sharefile = "/var/ipfire/samba/shares";
54 my $EOF = qx(cat $sharefile | wc -l);
55 my $Status = qx(/usr/local/bin/sambactrl smbstatus);
56
57 @shares = `grep -n '^\\[' $sharefile`;
58 foreach $shareentry (@shares)
59 {
60 @shareline = split( /\:/, $shareentry );
61 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
62 }
63
64 ############################################################################################################################
65 #################################### Initialisierung von Samba Variablen fr global Settings ###############################
66
67 $sambasettings{'WORKGRP'} = 'homeip.net';
68 $sambasettings{'NETBIOSNAME'} = 'IPFIRE';
69 $sambasettings{'SRVSTRING'} = 'Samba Server running on IPFire 2.0';
70 $sambasettings{'INTERFACES'} = '';
71 $sambasettings{'SECURITY'} = 'share';
72 $sambasettings{'OSLEVEL'} = '65';
73 $sambasettings{'GREEN'} = 'on';
74 $sambasettings{'BLUE'} = 'off';
75 $sambasettings{'ORANGE'} = 'off';
76 $sambasettings{'VPN'} = 'off';
77 $sambasettings{'WINSSRV'} = "$netsettings{'GREEN_NETADDRESS'}";
78 $sambasettings{'WINSSUPPORT'} = 'off';
79 $sambasettings{'PASSWORDSYNC'} = 'off';
80 $sambasettings{'OTHERINTERFACES'} = '';
81 $sambasettings{'GUESTACCOUNT'} = 'samba';
82 $sambasettings{'MAPTOGUEST'} = 'Never';
83 ### Values that have to be initialized
84 $cgisettings{'ACTION'} = '';
85
86 ################################################## Samba PDC Variablen #####################################################
87
88 $sambasettings{'LOCALMASTER'} = 'off';
89 $sambasettings{'DOMAINMASTER'} = 'off';
90 $sambasettings{'PREFERREDMASTER'} = 'off';
91 my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
92
93
94 ############################################################################################################################
95
96 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
97 &Header::getcgihash(\%sambasettings);
98
99 &Header::openpage('Samba', 1, '');
100 &Header::openbigbox('100%', 'left', '', $errormessage);
101
102 ############################################################################################################################
103 ############################################# Samba Rootskript aufrufe fr SU-Actions ######################################
104
105 if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");}
106 if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");}
107 if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
108 if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
109 if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");}
110 if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");}
111 if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");}
112 if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");}
113 if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");}
114 if ($sambasettings{'ACTION'} eq 'globalreset'){system("/usr/local/bin/sambactrl smbglobalreset");}
115
116 # smbsafeconf is directly called by the if clause
117
118 if ($sambasettings{'ACTION'} eq 'sharesreset')
119 {
120 system('/usr/local/bin/sambactrl smbsharesreset');
121 @Zeilen = ();
122 @Shares = ();
123 $shareentry = "";
124 @shares = ();
125 @shareline = ();
126 $EOF = qx(cat $sharefile | wc -l);
127
128 @shares = `grep -n '^\\[' $sharefile`;
129 foreach $shareentry (@shares)
130 {
131 @shareline = split( /\:/, $shareentry );
132 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
133 }
134 }
135
136 ############################################################################################################################
137 ########################################### Samba Benutzer oder PC l�chen #################################################
138
139 if ($sambasettings{'ACTION'} eq 'userdelete' && $sambasettings{'NAME'} =~ /\$/)
140 {
141 system("/usr/local/bin/sambactrl smbpcdelete $sambasettings{'NAME'}");
142 }
143 elsif ($sambasettings{'ACTION'} eq 'userdelete')
144 {
145 system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");
146 }
147
148 ############################################################################################################################
149 ############################################## Samba Share neu anlegen #####################################################
150
151 if ($sambasettings{'ACTION'} eq 'smbshareadd')
152 {
153 my $emptyline= "";
154 open (FILE, ">>${General::swroot}/samba/shares") or die "Can't save the shares settings: $!";
155 flock (FILE, 2);
156
157 print FILE <<END
158 $sambasettings{'SHAREOPTION'}
159 $emptyline
160 END
161 ;
162 close FILE;
163 system("/usr/local/bin/sambactrl smbsafeconf");
164
165 @Zeilen = ();
166 @Shares = ();
167 $shareentry = "";
168 @shares = ();
169 @shareline = ();
170 $EOF = qx(cat $sharefile | wc -l);
171
172 @shares = `grep -n '^\\[' $sharefile`;
173 foreach $shareentry (@shares)
174 {
175 @shareline = split( /\:/, $shareentry );
176 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
177 }
178 }
179
180 ############################################################################################################################
181 ################################################## Samba Share l�chen #####################################################
182
183 if ($sambasettings{'ACTION'} eq 'smbsharedel')
184 {
185 my $sharebody = '';
186 my $sharehead = '';
187 my $sharetext = '';
188 my $sharename = "$sambasettings{'NAME'}";
189 chomp $sharename;
190 $sharename=~s/\s//g;
191
192 for(my $i = 0; $i <= $#Shares; $i++)
193 {
194 chomp $Shares[$i];
195 $Shares[$i]=~s/\s//g;
196 if ( "$Shares[$i]" eq "$sharename" )
197 {
198 my $Zeilenbegin = $Zeilen[$i]-2;
199 my $Zeilenende = $EOF-$Zeilen[$i+1]+1;
200 my $Zeilenende2 = $Zeilenende-1;
201
202 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
203 {
204 $sharehead = qx(head -$Zeilenbegin $sharefile);
205 $sharetext = $sharehead;
206 }
207 elsif ($Zeilen[$i] eq 1 )
208 {
209 $sharehead = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
210 $sharetext = $sharehead;
211 }
212 else
213 {
214 $sharehead = qx(head -$Zeilenbegin $sharefile);$sharebody = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
215 $sharetext = "$sharehead\n$sharebody";
216 }
217 }
218 }
219
220 open (FILE, ">${General::swroot}/samba/shares") or die "Can't delete the share settings: $!";
221 flock (FILE, 2);
222 print FILE <<END
223 $sharetext
224 END
225 ;
226 close FILE;
227 system("/usr/local/bin/sambactrl smbsafeconf");
228
229 @Zeilen = ();
230 @Shares = ();
231 $shareentry = "";
232 @shares = ();
233 @shareline = ();
234 $EOF = qx(cat $sharefile | wc -l);
235
236 @shares = `grep -n '^\\[' $sharefile`;
237 foreach $shareentry (@shares)
238 {
239 @shareline = split( /\:/, $shareentry );
240 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
241 }
242 }
243 ############################################################################################################################
244 ################################################## Sambashare �dern #######################################################
245
246 if ($sambasettings{'ACTION'} eq 'smbsharechange')
247 {
248 my $sharebody = '';
249 my $sharehead = '';
250 my $sharename = "$sambasettings{'NAME'}";
251 my $sharetext = '';
252 $sharename=~s/\s//g;
253
254 for(my $i = 0; $i <= $#Shares; $i++)
255 {
256 chomp $Shares[$i];
257 $Shares[$i]=~s/\s//g;
258 if ( "$Shares[$i]" eq "$sharename" )
259 {
260 my $Zeilenbegin = $Zeilen[$i]-2;
261 my $Zeilenende = $EOF-$Zeilen[$i+1]+1;
262 my $Zeilenende2 = $Zeilenende-1;
263
264 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
265 {
266 $sharehead = qx(head -$Zeilenbegin $sharefile);
267 $sharetext = $sharehead;
268 }
269 elsif ($Zeilen[$i] eq 1 )
270 {
271 $sharehead = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
272 $sharetext = $sharehead;
273 }
274 else
275 {
276 $sharehead = qx(head -$Zeilenbegin $sharefile);$sharebody = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
277 $sharetext = "$sharehead\n$sharebody";
278 }
279 }
280 }
281
282 open (FILE, ">${General::swroot}/samba/shares") or die "Can't delete the share settings: $!";
283 flock (FILE, 2);
284 print FILE <<END
285 $sharetext
286 $sambasettings{'SHAREOPTION'}
287 END
288 ;
289 close FILE;
290 system("/usr/local/bin/sambactrl smbsafeconf");
291
292 @Zeilen = ();
293 @Shares = ();
294 @shares = `grep -n '^\\[' $sharefile`;
295 foreach $shareentry (@shares)
296 {
297 @shareline = split( /\:/, $shareentry );
298 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
299 }
300 }
301
302 ############################################################################################################################
303 ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
304
305 if ($sambasettings{'ACTION'} eq $Lang::tr{'save'})
306 {
307 $sambasettings{'INTERFACES'} = '';
308 if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
309 if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
310 if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
311 if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DDEVICE'}";}
312 if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
313
314 ############################################################################################################################
315 ##################################### Schreiben settings und bersetzen fr smb.conf #######################################
316
317 &General::writehash("${General::swroot}/samba/settings", \%sambasettings);
318
319 if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
320 if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "true";} else { $sambasettings{'WINSSUPPORT'} = "false";}
321 if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";}
322 if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";}
323 if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";}
324 if ($sambasettings{'MAPTOGUEST'} eq 'on'){ $sambasettings{'MAPTOGUEST'} = "true";} else { $sambasettings{'MAPTOGUEST'} = "false";}
325
326 ############################################################################################################################
327 ############################################# Schreiben der Samba globals ##################################################
328
329 open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
330 flock (FILE, 2);
331
332 print FILE <<END
333 # global.settings by IPFire Project
334
335 [global]
336 netbios name = $sambasettings{'NETBIOSNAME'}
337 server string = $sambasettings{'SRVSTRING'}
338 workgroup = $sambasettings{'WORKGRP'}
339
340 keep alive = 30
341 os level = $sambasettings{'OSLEVEL'}
342 fstype = NTFS
343
344 kernel oplocks = false
345 map to guest = $sambasettings{'MAPTOGUEST'}
346 smb ports = 445 139
347 unix charset = CP850
348
349 security = $sambasettings{'SECURITY'}
350 encrypt passwords = yes
351 guest account = $sambasettings{'GUESTACCOUNT'}
352 unix password sync = $sambasettings{'PASSWORDSYNC'}
353 null passwords = yes
354
355 bind interfaces only = true
356 interfaces = $sambasettings{'INTERFACES'}
357 socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE
358
359 username level = 1
360 wins support = $sambasettings{'WINSSUPPORT'}
361
362 log file = /var/log/samba/samba-log.%m
363 lock directory = /var/lock/samba
364 pid directory = /var/run/
365
366 preferred master = $sambasettings{'PREFERREDMASTER'}
367 domain master = $sambasettings{'DOMAINMASTER'}
368 local master = $sambasettings{'LOCALMASTER'}
369
370 END
371 ;
372 close FILE;
373
374 if ($sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' )
375 {
376 open (FILE, ">${General::swroot}/samba/pdc") or die "Can't save the pdc settings: $!";
377 flock (FILE, 2);
378 print FILE <<END
379 $sambasettings{'PDCOPTIONS'}
380 END
381 ;
382 close FILE;
383 system('/usr/local/bin/sambactrl smbsafeconfpdc');
384 }
385 else
386 {
387 system('/usr/local/bin/sambactrl smbsafeconf');
388 }
389 }
390 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
391
392 if ($errormessage) {
393 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
394 print "<class name='base'>$errormessage\n";
395 print "&nbsp;</class>\n";
396 &Header::closebox();
397 }
398
399 ############################################################################################################################
400 ########################################## Aktivieren von Checkboxen und Dropdowns #########################################
401
402 $checked{'WINSSUPPORT'}{'off'} = '';
403 $checked{'WINSSUPPORT'}{'on'} = '';
404 $checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'";
405 $checked{'PASSWORDSYNC'}{'off'} = '';
406 $checked{'PASSWORDSYNC'}{'on'} = '';
407 $checked{'PASSWORDSYNC'}{$sambasettings{'PASSWORDSYNC'}} = "checked='checked'";
408 $checked{'LOCALMASTER'}{'off'} = '';
409 $checked{'LOCALMASTER'}{'on'} = '';
410 $checked{'LOCALMASTER'}{$sambasettings{'LOCALMASTER'}} = "checked='checked'";
411 $checked{'DOMAINMASTER'}{'off'} = '';
412 $checked{'DOMAINMASTER'}{'on'} = '';
413 $checked{'DOMAINMASTER'}{$sambasettings{'DOMAINMASTER'}} = "checked='checked'";
414 $checked{'PREFERREDMASTER'}{'off'} = '';
415 $checked{'PREFERREDMASTER'}{'on'} = '';
416 $checked{'PREFERREDMASTER'}{$sambasettings{'PREFERREDMASTER'}} = "checked='checked'";
417 $checked{'GREEN'}{'off'} = '';
418 $checked{'GREEN'}{'on'} = '';
419 $checked{'GREEN'}{$sambasettings{'GREEN'}} = "checked='checked'";
420 $checked{'BLUE'}{'off'} = '';
421 $checked{'BLUE'}{'on'} = '';
422 $checked{'BLUE'}{$sambasettings{'BLUE'}} = "checked='checked'";
423 $checked{'ORANGE'}{'off'} = '';
424 $checked{'ORANGE'}{'on'} = '';
425 $checked{'ORANGE'}{$sambasettings{'ORANGE'}} = "checked='checked'";
426 $checked{'VPN'}{'off'} = '';
427 $checked{'VPN'}{'on'} = '';
428 $checked{'VPN'}{$sambasettings{'VPN'}} = "checked='checked'";
429
430 $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
431 $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
432
433 ############################################################################################################################
434 ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
435
436 &Header::openbox('100%', 'center', 'Samba');
437 print <<END
438 <hr />
439 <table width='95%' cellspacing='0'>
440 END
441 ;
442 if ( $message ne "" )
443 {
444 print "<tr><td colspan='2' align='left'><font color='red'>$message</font>";
445 }
446
447 print <<END
448 <tr><td colspan='2'><br /></td></tr>
449 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Alle Dienste</b></td></tr>
450 </table><table width='95%' cellspacing='0'>
451 END
452 ;
453
454 my $key = '';
455 foreach $key (sort keys %servicenames)
456 {
457 print "<tr><td align='left'>$key";
458 my $shortname = $servicenames{$key};
459 my $status = &isrunning($shortname);
460 print "$status";
461 print <<END
462 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
463 <input type='hidden' name='ACTION' value='restart $shortname' />
464 <input type='image' src='/images/reload.gif' />
465 </form></td>
466 END
467 ;
468 }
469
470 print <<END
471 <tr><td colspan='2'><br /></td></tr>
472 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
473 <input type='submit' name='ACTION' value='Start' />
474 <input type='submit' name='ACTION' value='Stop' />
475 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
476 </form></td></tr>
477 </table>
478
479
480 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
481 <table width='95%' cellspacing='0'>
482 <tr><td colspan='2'><br /></td></tr>
483 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Basisoptionen</b></td></tr>
484 <tr><td align='left'>Workgroup:</td><td><input type='text' name='WORKGRP' value='$sambasettings{'WORKGRP'}' size="30" /></td></tr>
485 <tr><td align='left'>NetBIOS-Name:</td><td><input type='text' name='NETBIOSNAME' value='$sambasettings{'NETBIOSNAME'}' size="30" /></td></tr>
486 <tr><td align='left'>Server-String:</td><td><input type='text' name='SRVSTRING' value='$sambasettings{'SRVSTRING'}' size="30" /></td></tr>
487 <tr><td align='left'>Interfaces:</td><td>on <input type='radio' name='VPN' value='on' $checked{'VPN'}{'on'} />/
488 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
489 <font size='2' color='$Header::colourovpn'><b> OpenVpn - $ovpnsettings{'DDEVICE'}</b></font></td></tr>
490 <tr><td align='left'></td><td>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
491 <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
492 <font size='2' color='$Header::colourgreen'><b> $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font></td></tr>
493 END
494 ;
495
496 if (&Header::blue_used())
497 {
498 print <<END
499 <tr><td align='left'></td><td>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
500 <input type='radio' name='BLUE' value='off' $checked{'BLUE'}{'off'} /> off |
501 <font size='2' color='$Header::colourblue'><b> $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font></td></tr>
502 END
503 ;
504 }
505
506 if (&Header::orange_used())
507 {
508 print <<END
509 <tr><td align='left'></td><td>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
510 <input type='radio' name='ORANGE' value='off' $checked{'ORANGE'}{'off'} /> off |
511 <font size='2' color='$Header::colourorange'><b> $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font></td></tr>
512 END
513 ;
514 }
515
516 print <<END
517 <tr><td align='center'>weitere</td><td><input type='text' name='OTHERINTERFACES' value='$sambasettings{'OTHERINTERFACES'}' size="30" /></td></tr>
518 <tr><td align='left'><br /></td><td></td></tr>
519 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Sicherheitsoptionen</b></td></tr>
520 <tr><td align='left'>Security:</td><td><select name='SECURITY'>
521 <option value='share' $selected{'SECURITY'}{'share'}>Share</option>
522 <option value='user' $selected{'SECURITY'}{'user'}>User</option>
523 <option value='domain' $selected{'SECURITY'}{'domain'}>Domain</option>
524 <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option>
525 <option value='server' $selected{'SECURITY'}{'server'}>Server</option>
526 </select></td></tr>
527 <tr><td align='left'>Map to guest:</td><td><select name='MAPTOGUEST'>
528 <option value='Never' $selected{'MAPTOGUEST'}{'Never'}>Never</option>
529 <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option>
530 <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option>
531 </select></td></tr>
532 <tr><td align='left'>Unix Passwort Sync:</td><td>on <input type='radio' name='PASSWORDSYNC' value='on' $checked{'PASSWORDSYNC'}{'on'} />/
533 <input type='radio' name='PASSWORDSYNC' value='off' $checked{'PASSWORDSYNC'}{'off'} /> off</td></tr>
534 <tr><td align='left'><br /></td><td></td></tr>
535 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Netzwerkoptionen</b></td></tr>
536 <tr><td align='left'>OS Level:</td><td><input type='text' name='OSLEVEL' value='$sambasettings{'OSLEVEL'}' size="30" /></td></tr>
537 <tr><td align='left'>WINS-Server:</td><td><input type='text' name='WINSSRV' value='$sambasettings{'WINSSRV'}' size="30" /></td></tr>
538 END
539 ;
540
541 if ($sambasettings{'SECURITY'} eq 'user')
542 {
543 print <<END
544 <tr><td align='left'>WINS-Support:</td><td>on <input type='radio' name='WINSSUPPORT' value='on' $checked{'WINSSUPPORT'}{'on'} />/
545 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
546 <tr><td align='left'>Local Master:</td><td>on <input type='radio' name='LOCALMASTER' value='on' $checked{'LOCALMASTER'}{'on'} />/
547 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
548 <tr><td align='left'>Domain Master:</td><td>on <input type='radio' name='DOMAINMASTER' value='on' $checked{'DOMAINMASTER'}{'on'} />/
549 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
550 <tr><td align='left'>Preferred Master:</td><td>on <input type='radio' name='PREFERREDMASTER' value='on' $checked{'PREFERREDMASTER'}{'on'} />/
551 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
552 END
553 ;
554 }
555
556 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
557 {
558 print <<END
559 <tr><td align='left'><br /></td><td></td></tr>
560 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>PDC Optionen</b></td></tr>
561 <tr><td align='left'><br /></td><td></td></tr>
562 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
563 END
564 ;
565 }
566
567 print <<END
568 </table>
569 <table width='10%' cellspacing='0'>
570 <tr><td colspan='2'><br /></td></tr>
571 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
572 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
573 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></form></td>
574 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
575 <input type='hidden' name='ACTION' value='globalreset' />
576 <input type='image' alt='Reset' src='/images/reload.gif' /></form></td>
577 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
578 <input type='hidden' name='ACTION' value='globalcaption' />
579 <input type='image' alt='Legende' src='/images/info.gif' /></form></td></tr>
580 </table>
581 END
582 ;
583
584 if ($sambasettings{'ACTION'} eq 'globalcaption')
585 {
586 print <<END
587 <table width='95%' cellspacing='0'>
588 <tr><td colspan='2'><br /></td></tr>
589 <tr><td><b>Legende:</b></td></tr>
590 <tr><td><img src='/images/floppy.gif' />Einstellungen speichern</td></tr>
591 <tr><td><img src='/images/reload.gif' />Auf default zurueck setzen</td></tr>
592 </table>
593 END
594 ;
595 }
596
597 &Header::closebox();
598
599 ############################################################################################################################
600 ########################################## Benutzerverwaltung fr Usersecurity #############################################
601
602 if ($sambasettings{'SECURITY'} eq 'user')
603 {
604 if ($sambasettings{'DOMAINMASTER'} eq 'off')
605 {
606 &Header::openbox('100%', 'center', 'accounting - user Security none PDC mode');
607 }
608 else
609 {
610 &Header::openbox('100%', 'center', 'accounting - user Security PDC mode');
611 }
612 print <<END
613 <hr />
614 <table width='95%' cellspacing='0'>
615 <tr><td colspan='6'><br /></td></tr>
616 <tr><td colspan='6' align='left'></td></tr>
617 <tr><td bgcolor='${Header::table1colour}' colspan='7' align='left'><b>Benutzerverwaltung</b></td></tr>
618 <tr><td><u>Name</u></td><td><u>Passwort</u></td>
619 END
620 ;
621
622 if ($sambasettings{'DOMAINMASTER'} eq 'off')
623 {
624 print "<td></td>";
625 }
626 else
627 {
628 print "<td><u>Typ</u></td>";
629 }
630
631 print "<td><u>Status</u></td><td colspan='3' width='5'><u>Optionen</u></td></tr>";
632 system('/usr/local/bin/sambactrl readsmbpasswd');
633 open(FILE, "</var/ipfire/samba/private/smbpasswd") or die "Can't read user file: $!";
634 @user = <FILE>;
635 close(FILE);
636 system('/usr/local/bin/sambactrl locksmbpasswd');
637 foreach $userentry (sort @user)
638 {
639 @userline = split( /\:/, $userentry );
640 print "<tr><td align='left'>$userline[0]</td><td>";
641 if ($userline[4] =~ /N/)
642 {
643 print "nicht gesetzt</td><td>";
644 }
645 else
646 {
647 print "gesetzt</td><td>";
648 }
649
650 if ($sambasettings{'DOMAINMASTER'} eq 'off')
651 {
652 print "</td><td>";
653 }
654 else
655 {
656 if ($userline[0] =~ /\$/)
657 {
658 print "PC</td><td>";
659 }
660 else
661 {
662 print "User</td><td>";
663 }
664 }
665
666 if ($userline[4] =~ /D/)
667 {
668 print <<END
669 inaktiv</td>
670 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
671 <input type='hidden' name='NAME' value='$userline[0]' />
672 <input type='hidden' name='ACTION' value='smbuserenable' />
673 <input type='image' alt='Aktivieren' src='/images/on.gif' />
674 </form></td>
675 END
676 ;
677 }
678 else
679 {
680 print <<END
681 aktiv</td>
682 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
683 <input type='hidden' name='NAME' value='$userline[0]' />
684 <input type='hidden' name='ACTION' value='smbuserdisable' />
685 <input type='image' alt='Deaktivieren' src='/images/off.gif' />
686 </form></td>
687 END
688 ;
689 }
690
691 if ($userline[0] =~ /\$/)
692 {
693 print "<td></td>";
694 }
695 else
696 {
697 print <<END
698 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
699 <input type='hidden' name='NAME' value='$userline[0]' />
700 <input type='hidden' name='ACTION' value='userchangepw' />
701 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
702 </form></td>
703 END
704 ;
705 }
706
707 print <<END
708 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
709 <input type='hidden' name='NAME' value='$userline[0]' />
710 <input type='hidden' name='ACTION' value='userdelete' />
711 <input type='image' alt='Loeschen' src='/images/delete.gif' />
712 </form></td></tr>
713 END
714 ;
715 }
716 print <<END
717 </table>
718 <table width='10%' cellspacing='0'>
719 <tr><td colspan='3'><br /></td></tr>
720 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
721 <input type='hidden' name='ACTION' value='useradd' />
722 <input type='image' alt='Benutzer anlegen' src='/images/add.gif' /></form></td>
723 END
724 ;
725
726 if ($sambasettings{'DOMAINMASTER'} eq 'on')
727 {
728 print <<END
729 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
730 <input type='hidden' name='ACTION' value='pcadd' />
731 <input type='image' alt='Legende' src='/images/comp.blue.gif' /></form>
732 END
733 ;
734 }
735 print <<END
736 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
737 <input type='hidden' name='ACTION' value='usercaption' />
738 <input type='image' alt='Legende' src='/images/info.gif' /></form>
739 </td></tr>
740 </table>
741 END
742 ;
743
744 if ($sambasettings{'ACTION'} eq 'usercaption')
745 {
746 print <<END
747 <table width='95%' cellspacing='0'>
748 <tr><td><br /></td></tr>
749 <tr><td><b>Legende:</b></td></tr>
750 <tr><td><img src='/images/add.gif' />Benutzer neu anlegen</td></tr>
751 <tr><td><img src='/images/comp.blue.gif' />Client Account neu anlegen</td></tr>
752 <tr><td><img src='/images/on.gif' />Benutzer aktivieren</td></tr>
753 <tr><td><img src='/images/off.gif' />Benutzer deaktivieren</td></tr>
754 <tr><td><img src='/images/floppy.gif' />Einstellungen speichern</td></tr>
755 <tr><td><img src='/images/edit.gif' />Passwort wechseln</td></tr>
756 <tr><td><img src='/images/delete.gif' />Benutzer loeschen</td></tr>
757 </table>
758 END
759 ;
760 }
761
762 if ($sambasettings{'ACTION'} eq 'userchangepw')
763 {
764 my $username = "$sambasettings{'NAME'}";
765 my $password = 'samba';
766 print <<END
767 <hr />
768 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
769 <table width='95%' cellspacing='0'>
770 <tr><td colspan='2'><br /></td></tr>
771 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Passwort wechseln</b></td></tr>
772 <tr><td align='left'>Benutzername</td><td><input type='text' name='USERNAME' value='$username' size="30" /></td></tr>
773 <tr><td align='left'>Passwort</td><td><input type='password' name='PASSWORD' value='$password' size="30" /></td></tr>
774 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
775 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
776 </table>
777 </form>
778 END
779 ;
780 }
781
782 if ($sambasettings{'ACTION'} eq 'useradd')
783 {
784 my $username = "user";
785 my $password = "samba";
786 chomp $username;
787 $username=~s/\s//g;
788 chomp $password;
789 $password=~s/\s//g;
790 print <<END
791 <hr />
792 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
793 <table width='95%' cellspacing='0'>
794 <tr><td colspan='2'><br /></td></tr>
795 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Benutzer neu anlegen</b></td></tr>
796 <tr><td align='left'>Benutzername</td><td><input type='text' name='USERNAME' value='$username' size="30" /></td></tr>
797 <tr><td align='left'>Passwort</td><td><input type='password' name='PASSWORD' value='$password' size="30" /></td></tr>
798 <tr><td align='left'>Unix Gruppe</td><td><input type='text' name='GROUP' value='sambauser' size="30" /></td></tr>
799 <tr><td align='left'>Unix Shell</td><td><input type='text' name='SHELL' value='/bin/false' size="30" /></td></tr>
800 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
801 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
802 </table>
803 </form>
804 END
805 ;
806 }
807
808 if ($sambasettings{'ACTION'} eq 'pcadd')
809 {
810 my $pcname = "client\$";
811 chomp $pcname;
812 $pcname=~s/\s//g;
813 print <<END
814 <hr />
815 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
816 <table width='95%' cellspacing='0'>
817 <tr><td colspan='2'><br /></td></tr>
818 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Client Account neu anlegen</b></td></tr>
819 <tr><td align='left'>Clientname</td><td><input type='text' name='PCNAME' value='$pcname' size="30" /></td></tr>
820 <tr><td align='left'>Unix Gruppe</td><td><input type='text' name='GROUP' value='sambawks' size="30" /></td></tr>
821 <tr><td align='left'>Unix Shell</td><td><input type='text' name='SHELL' value='/bin/false' size="30" /></td></tr>
822 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
823 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
824 </table>
825 </form>
826 END
827 ;
828 }
829
830 &Header::closebox();
831 }
832
833 ############################################################################################################################
834 ############################################### Verwalten von Freigaben ####################################################
835
836 &Header::openbox('100%', 'center', 'Shares');
837
838 print <<END
839 <hr />
840 <table width='95%' cellspacing='0'>
841 <tr><td colspan='3'><br /></td></tr>
842 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>Shareverwaltung</b>
843 <tr><td><u>Names des Shares</u></td><td colspan='2' width="5"><u>Optionen</u></td></tr>
844 END
845 ;
846
847 foreach $shareentry (sort @Shares)
848 {
849 print <<END
850 <tr><td align='left'>$shareentry</td>
851 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
852 <input type='hidden' name='NAME' value='$shareentry' />
853 <input type='hidden' name='ACTION' value='sharechange' />
854 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
855 </form></td>
856 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
857 <input type='hidden' name='NAME' value='$shareentry' />
858 <input type='hidden' name='ACTION' value='smbsharedel' />
859 <input type='image' alt='Loeschen' src='/images/delete.gif' />
860 </form></td></tr>
861 END
862 ;
863 }
864
865 print <<END
866 </table>
867 <table width='10%' cellspacing='0'>
868 <tr><td colspan='3'><br /></td></tr>
869 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
870 <input type='hidden' name='ACTION' value='shareadd' />
871 <input type='image' alt='neuen Share anlegen' src='/images/add.gif' />
872 </form></td>
873 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
874 <input type='hidden' name='ACTION' value='sharesreset' />
875 <input type='image' alt='Reset' src='/images/reload.gif' />
876 </form></td>
877 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
878 <input type='hidden' name='ACTION' value='sharecaption' />
879 <input type='image' alt='Legende' src='/images/info.gif' />
880 </form></td></tr>
881 </table>
882 END
883 ;
884
885 if ($sambasettings{'ACTION'} eq 'sharecaption')
886 {
887 print <<END
888 <table width='95%' cellspacing='0'>
889 <tr><td><br /></td></tr>
890 <tr><td><b>Legende:</b></td></tr>
891 <tr><td><img src='/images/add.gif' />Share neu anlegen</td></tr>
892 <tr><td><img src='/images/edit.gif' />Share bearbeiten</td></tr>
893 <tr><td><img src='/images/floppy.gif' />Einstellungen speichern</td></tr>
894 <tr><td><img src='/images/reload.gif' />Shares zurueck setzen</td></tr>
895 <tr><td><img src='/images/delete.gif' />Share loeschen</td></tr>
896 </table>
897 END
898 ;
899 }
900
901 if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
902 {
903 print <<END
904 <hr />
905 <table width='95%' cellspacing='0'>
906 <tr><td colspan='2'><br /></td></tr>
907 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>neuen Share anlegen</b></td></tr>
908 <tr><td colspan='2' align='center'></td></tr>
909 <tr><td colspan='2' align='center'>Anzeige der Optionen fuer Shares<form method='post' action='$ENV{'SCRIPT_NAME'}'>
910 <input type='hidden' name='ACTION' value='optioncaption' />
911 <input type='image' alt='Legende' src='/images/info.gif' />
912 </form></td></tr>
913 <form method='post' action='$ENV{'SCRIPT_NAME'}'><tr><td colspan='2' align='center'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$defaultoption</textarea></td></tr>
914 </table>
915 <table width='10%' cellspacing='0'>
916 <tr><td><br /></td></tr>
917 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
918 <input type='image' alt='Share hinzufuegen' src='/images/floppy.gif' /></td></tr></form>
919 </table>
920 END
921 ;
922 }
923
924 if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
925 {
926 my $sharename = "$sambasettings{'NAME'}";
927 chomp $sharename;
928 $sharename=~s/\s//g;
929
930 for(my $i = 0; $i <= $#Shares; $i++)
931 {
932 chomp $Shares[$i];
933 $Shares[$i]=~s/\s//g;
934 if ( "$Shares[$i]" eq "$sharename" )
935 {
936 my $Zeilenbegin = $Zeilen[$i+1]-2;
937 my $Zeilenende = $Zeilen[$i+1]-$Zeilen[$i];
938 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
939 {$Zeilenende = $EOF-$Zeilen[$#Shares]+1;$Zeilenbegin = $EOF-$Zeilen[$#Shares]; $shareoption = qx(tail -$Zeilenende $sharefile | head -$Zeilenbegin);}
940 else
941 {$shareoption = qx(head -$Zeilenbegin $sharefile | tail -$Zeilenende);}
942 }
943 }
944 print <<END
945 <hr />
946 <table width='95%' cellspacing='0'>
947 <tr><td colspan='2'><br /></td></tr>
948 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>Share bearbeiten</b></td></tr>
949 <tr><td colspan='2' align='center'></td></tr>
950 <tr><td colspan='2' align='center'>Anzeige der Optionen fuer Shares<form method='post' action='$ENV{'SCRIPT_NAME'}'>
951 <input type='hidden' name='ACTION' value='optioncaption2' />
952 <input type='image' alt='Legende' src='/images/info.gif' /></td></tr></form>
953 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$shareoption</textarea></td></tr>
954 </table>
955 <table width='10%' cellspacing='0'>
956 <tr><td><br /></td></tr>
957 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
958 <input type='submit' name='ACTION' value='smbsharechange' /></td></tr></form>
959 </table>
960 END
961 ;
962 }
963
964 if ($sambasettings{'ACTION'} eq 'optioncaption' || $sambasettings{'ACTION'} eq 'optioncaption2')
965 {
966 print <<END
967 <table width='95%' cellspacing='0'>
968 <tr><td><br /></td></tr>
969 <tr><td><b>Legende:</b></td></tr>
970 <tr><td><u>Option</u></td><td><u>Bedeutung</u> / <u>Beispiel</u></td></tr>
971 <tr><td>comment</td><td>Kommentar</td></tr>
972 <tr><td></td><td>comment = Mein neues Share</td></tr>
973 <tr><td><br /></td><td></td></tr>
974 <tr><td>path</td><td>Pfad zum Verzeichnis</td></tr>
975 <tr><td></td><td>path = /share/neu</td></tr>
976 <tr><td><br /></td><td></td></tr>
977 <tr><td>writeable</td><td>Verzeichnis schreibbar</td></tr>
978 <tr><td></td><td>writeable = yes</td></tr>
979 <tr><td><br /></td><td></td></tr>
980 <tr><td>browseable</td><td>sichtbar in Verzeichnisliste</td></tr>
981 <tr><td></td><td>browsable = yes</td></tr>
982 <tr><td><br /></td><td></td></tr>
983 <tr><td>user</td><td>Besitzer der Freigabe</td></tr>
984 <tr><td></td><td>user = samba</td></tr>
985 <tr><td><br /></td><td></td></tr>
986 <tr><td>valid users</td><td>Liste der Zugriffsberechtigten</td></tr>
987 <tr><td></td><td>valid users = samba, user1</td></tr>
988 <tr><td><br /></td><td></td></tr>
989 <tr><td>write list</td><td>Liste der Schreibberechtigten</td></tr>
990 <tr><td></td><td>write list = samba</td></tr>
991 <tr><td><br /></td><td></td></tr>
992 <tr><td>hosts allow</td><td>nur die angegebenen Hosts drfen das Share benutzen</td></tr>
993 <tr><td></td><td>hosts allow = localhost 192.168.1.1 192.168.2.0/24</td></tr>
994 <tr><td><br /></td><td></td></tr>
995 <tr><td>hosts deny</td><td>jede Maschine ausser diesen darf das Share benutzen</td></tr>
996 <tr><td></td><td>hosts deny = 192.168.1.2 192.168.3.0/24</td></tr>
997 <tr><td><br /></td><td></td></tr>
998 <tr><td>read list</td><td>Liste der nur Leseberechtigten</td></tr>
999 <tr><td></td><td>read list = user1</td></tr>
1000 <tr><td><br /></td><td></td></tr>
1001 <tr><td>admin users</td><td>Liste der Benutzer mit SuperUser Rechten</td></tr>
1002 <tr><td></td><td>admin users = user1</td></tr>
1003 <tr><td><br /></td><td></td></tr>
1004 <tr><td>invalid users</td><td>Liste der Benutzer denen der Zugriff verweigert wird</td></tr>
1005 <tr><td></td><td>invalid users = user2</td></tr>
1006 <tr><td><br /></td><td></td></tr>
1007 <tr><td>force user</td><td>Standartbenutzer fuer alle Dateien</td></tr>
1008 <tr><td></td><td>force user = samba</td></tr>
1009 <tr><td><br /></td><td></td></tr>
1010 <tr><td>directory mask</td><td>UNIX Verzeichnisberchtigung beim Erzeugen</td></tr>
1011 <tr><td></td><td>directory mask = 0777</td></tr>
1012 <tr><td><br /></td><td></td></tr>
1013 <tr><td>create mask</td><td>UNIX Dateiberchtigung beim Erzeugen</td></tr>
1014 <tr><td></td><td>create mask = 0777</td></tr>
1015 <tr><td><br /></td><td></td></tr>
1016 <tr><td>guest ok</td><td>Annonymer Zugriff</td></tr>
1017 <tr><td></td><td>guest ok = yes</td></tr>
1018 </table>
1019 END
1020 ;
1021 }
1022
1023 &Header::closebox();
1024
1025 ############################################################################################################################
1026 ############################################### Anzeige des Sambastatus ####################################################
1027
1028 &Header::openbox('100%', 'center', 'Status');
1029
1030 print <<END
1031 <hr />
1032 <table width='95%' cellspacing='0'>
1033 <tr><td colspan='4'><br /></td></tr>
1034 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>Samba Status</b></td></tr>
1035 <tr><td>$Status</td></tr>
1036 </table>
1037 END
1038 ;
1039
1040 &Header::closebox();
1041 &Header::closebigbox();
1042 &Header::closepage();
1043
1044 ############################################################################################################################
1045 ############################################ Subfunktion fr Sambadienste ##################################################
1046
1047 sub isrunning
1048 {
1049 my $cmd = $_[0];
1050 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1051 my $pid = '';
1052 my $testcmd = '';
1053 my $exename;
1054
1055 $cmd =~ /(^[a-z]+)/;
1056 $exename = $1;
1057
1058 if (open(FILE, "/var/run/${cmd}.pid"))
1059 {
1060 $pid = <FILE>; chomp $pid;
1061 close FILE;
1062 if (open(FILE, "/proc/${pid}/status"))
1063 {
1064 while (<FILE>)
1065 {
1066 if (/^Name:\W+(.*)/)
1067 {
1068 $testcmd = $1;
1069 }
1070 }
1071 close FILE;
1072 if ($testcmd =~ /$exename/)
1073 {
1074 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1075 }
1076 }
1077 }
1078 return $status;
1079 }