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