b49c0bc990381c192989eafbd9f3a5bd0135c49d
[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 =$Lang::tr{'no log selected'};
27 my $defaultoption= "[Share]\npath = /var/ipfire/samba/share1\ncomment = Share - Public Access\nbrowseable = yes\nwriteable = yes\ncreate mask = 0777\ndirectory mask = 0777\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'} = '127.0.0.1';
85 $sambasettings{'GUESTACCOUNT'} = 'samba';
86 $sambasettings{'MAPTOGUEST'} = 'Never';
87 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
88 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
89 ### Values that have to be initialized
90 $sambasettings{'ACTION'} = '';
91 my $LOGLINES = '50';
92
93 ################################################## Samba PDC Variablen #####################################################
94
95 $sambasettings{'LOCALMASTER'} = 'off';
96 $sambasettings{'DOMAINMASTER'} = 'off';
97 $sambasettings{'PREFERREDMASTER'} = 'off';
98 my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
99
100
101 ############################################################################################################################
102
103 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
104 &Header::getcgihash(\%sambasettings);
105
106 &Header::openpage('Samba', 1, '');
107 &Header::openbigbox('100%', 'left', '', $errormessage);
108
109 ############################################################################################################################
110 ############################################# Samba Rootskript aufrufe fr SU-Actions #######################################
111
112 if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");}
113 if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");}
114 if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
115 if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
116 if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");}
117 if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");}
118 if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");}
119 if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");}
120 if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");}
121 if ($sambasettings{'ACTION'} eq 'globalresetyes')
122 {
123 system("/usr/local/bin/sambactrl smbglobalreset");
124 $sambasettings{'WORKGRP'} = 'homeip.net';
125 $sambasettings{'NETBIOSNAME'} = 'IPFire';
126 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.0';
127 $sambasettings{'INTERFACES'} = '';
128 $sambasettings{'SECURITY'} = 'share';
129 $sambasettings{'OSLEVEL'} = '65';
130 $sambasettings{'GREEN'} = 'on';
131 $sambasettings{'BLUE'} = 'off';
132 $sambasettings{'ORANGE'} = 'off';
133 $sambasettings{'VPN'} = 'off';
134 $sambasettings{'WINSSRV'} = '';
135 $sambasettings{'WINSSUPPORT'} = 'on';
136 $sambasettings{'REMOTEANNOUNCE'} = '';
137 $sambasettings{'PASSWORDSYNC'} = 'off';
138 $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
139 $sambasettings{'GUESTACCOUNT'} = 'samba';
140 $sambasettings{'MAPTOGUEST'} = 'Never';
141 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
142 ### Values that have to be initialized
143 $sambasettings{'ACTION'} = '';
144 $sambasettings{'LOCALMASTER'} = 'off';
145 $sambasettings{'DOMAINMASTER'} = 'off';
146 $sambasettings{'PREFERREDMASTER'} = 'off';
147 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
148 $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
149 system("/usr/local/bin/sambactrl smbreload");
150 }
151
152 # smbsafeconf is directly called by the if clause
153
154 if ($sambasettings{'ACTION'} eq 'sharesresetyes')
155 {
156 system('/usr/local/bin/sambactrl smbsharesreset');
157 @Zeilen = ();
158 @Shares = ();
159 $shareentry = "";
160 @shares = ();
161 @shareline = ();
162 $EOF = qx(cat $sharefile | wc -l);
163
164 @shares = `grep -n '^\\[' $sharefile`;
165 foreach $shareentry (@shares)
166 {
167 @shareline = split( /\:/, $shareentry );
168 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
169 }
170 system("/usr/local/bin/sambactrl smbreload");
171 }
172
173 ############################################################################################################################
174 ################################################ Sicherheitsabfrage für den Reset ##########################################
175
176 if ($sambasettings{'ACTION'} eq 'globalreset')
177 {
178 print <<END
179 <br />
180 <table width='95%' cellspacing='0'>
181 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='center'><b>$Lang::tr{'resetglobals'}</b>
182 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
183 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
184 <input type='hidden' name='ACTION' value='globalresetyes' /></form></td>
185 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
186 <input type='image' alt='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
187 <input type='hidden' name='ACTION' value='cancel' /></form></td>
188 </tr>
189 </table>
190 END
191 ;
192 }
193
194 if ($sambasettings{'ACTION'} eq 'sharesreset')
195 {
196 print <<END
197 <br />
198 <table width='95%' cellspacing='0'>
199 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='center'><b>$Lang::tr{'resetshares'}</b>
200 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
201 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
202 <input type='hidden' name='ACTION' value='sharesresetyes' /></form></td>
203 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
204 <input type='image' alt='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
205 <input type='hidden' name='ACTION' value='cancel' /></form></td>
206 </tr>
207 </table>
208 END
209 ;
210 }
211
212 ############################################################################################################################
213 ########################################### Samba Benutzer oder PC l�chen #################################################
214
215 if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");}
216
217 ############################################################################################################################
218 ############################################## Samba Share neu anlegen #####################################################
219
220 if ($sambasettings{'ACTION'} eq 'smbshareadd')
221 {
222 my $emptyline= "";
223 open (FILE, ">>${General::swroot}/samba/shares") or die "Can't save the shares settings: $!";
224 flock (FILE, 2);
225
226 print FILE <<END
227 $sambasettings{'SHAREOPTION'}
228 $emptyline
229 END
230 ;
231 close FILE;
232 system("/usr/local/bin/sambactrl smbsafeconf");
233
234 @Zeilen = ();
235 @Shares = ();
236 $shareentry = "";
237 @shares = ();
238 @shareline = ();
239 $EOF = qx(cat $sharefile | wc -l);
240
241 @shares = `grep -n '^\\[' $sharefile`;
242 foreach $shareentry (@shares)
243 {
244 @shareline = split( /\:/, $shareentry );
245 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
246 }
247 system("/usr/local/bin/sambactrl smbreload");
248 }
249
250 ############################################################################################################################
251 ################################################## Samba Share l�chen #####################################################
252
253 if ($sambasettings{'ACTION'} eq 'smbsharedel')
254 {
255 my $sharebody = '';
256 my $sharehead = '';
257 my $sharetext = '';
258 my $sharename = "$sambasettings{'NAME'}";
259 chomp $sharename;
260 $sharename=~s/\s//g;
261
262 for(my $i = 0; $i <= $#Shares; $i++)
263 {
264 chomp $Shares[$i];
265 $Shares[$i]=~s/\s//g;
266 if ( "$Shares[$i]" eq "$sharename" )
267 {
268 my $Zeilenbegin = $Zeilen[$i]-2;
269 my $Zeilenende = $EOF-$Zeilen[$i+1]+1;
270 my $Zeilenende2 = $Zeilenende-1;
271
272 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
273 {
274 $sharehead = qx(head -$Zeilenbegin $sharefile);
275 $sharetext = $sharehead;
276 }
277 elsif ($Zeilen[$i] eq 1 )
278 {
279 $sharehead = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
280 $sharetext = $sharehead;
281 }
282 else
283 {
284 $sharehead = qx(head -$Zeilenbegin $sharefile);$sharebody = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
285 $sharetext = "$sharehead\n$sharebody";
286 }
287 }
288 }
289
290 open (FILE, ">${General::swroot}/samba/shares") or die "Can't delete the share settings: $!";
291 flock (FILE, 2);
292 print FILE <<END
293 $sharetext
294 END
295 ;
296 close FILE;
297 system("/usr/local/bin/sambactrl smbsafeconf");
298
299 @Zeilen = ();
300 @Shares = ();
301 $shareentry = "";
302 @shares = ();
303 @shareline = ();
304 $EOF = qx(cat $sharefile | wc -l);
305
306 @shares = `grep -n '^\\[' $sharefile`;
307 foreach $shareentry (@shares)
308 {
309 @shareline = split( /\:/, $shareentry );
310 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
311 }
312 system("/usr/local/bin/sambactrl smbreload");
313 }
314 ############################################################################################################################
315 ################################################## Sambashare �dern #######################################################
316
317 if ($sambasettings{'ACTION'} eq 'smbsharechange')
318 {
319 my $sharebody = '';
320 my $sharehead = '';
321 my $sharename = "$sambasettings{'NAME'}";
322 my $sharetext = '';
323 $sharename=~s/\s//g;
324
325 for(my $i = 0; $i <= $#Shares; $i++)
326 {
327 chomp $Shares[$i];
328 $Shares[$i]=~s/\s//g;
329 if ( "$Shares[$i]" eq "$sharename" )
330 {
331 my $Zeilenbegin = $Zeilen[$i]-2;
332 my $Zeilenende = $EOF-$Zeilen[$i+1]+1;
333 my $Zeilenende2 = $Zeilenende-1;
334
335 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
336 {
337 $sharehead = qx(head -$Zeilenbegin $sharefile);
338 $sharetext = $sharehead;
339 }
340 elsif ($Zeilen[$i] eq 1 )
341 {
342 $sharehead = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
343 $sharetext = $sharehead;
344 }
345 else
346 {
347 $sharehead = qx(head -$Zeilenbegin $sharefile);$sharebody = qx(tail -$Zeilenende $sharefile | head -$Zeilenende2);
348 $sharetext = "$sharehead\n$sharebody";
349 }
350 }
351 }
352
353 open (FILE, ">${General::swroot}/samba/shares") or die "Can't delete the share settings: $!";
354 flock (FILE, 2);
355 print FILE <<END
356 $sharetext
357 $sambasettings{'SHAREOPTION'}
358 END
359 ;
360 close FILE;
361 system("/usr/local/bin/sambactrl smbsafeconf");
362
363 @Zeilen = ();
364 @Shares = ();
365 @shares = `grep -n '^\\[' $sharefile`;
366 foreach $shareentry (@shares)
367 {
368 @shareline = split( /\:/, $shareentry );
369 push(@Zeilen,$shareline[0]);push(@Shares,$shareline[1]);
370 }
371 system("/usr/local/bin/sambactrl smbreload");
372 }
373
374 ############################################################################################################################
375 ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
376
377 if ($sambasettings{'ACTION'} eq $Lang::tr{'save'})
378 {
379 $sambasettings{'INTERFACES'} = '';
380 if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
381 if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
382 if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
383 if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DDEVICE'}";}
384 if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
385
386 ############################################################################################################################
387 ##################################### Schreiben settings und bersetzen fr smb.conf #######################################
388
389 &General::writehash("${General::swroot}/samba/settings", \%sambasettings);
390
391 if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
392 if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "true";$sambasettings{'WINSSRV'} = "";} else { $sambasettings{'WINSSUPPORT'} = "false";}
393 if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";}
394 if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";}
395 if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";}
396
397 ############################################################################################################################
398 ############################################# Schreiben der Samba globals ##################################################
399
400 open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
401 flock (FILE, 2);
402
403 print FILE <<END
404 # global.settings by IPFire Project
405
406 [global]
407 netbios name = $sambasettings{'NETBIOSNAME'}
408 server string = $sambasettings{'SRVSTRING'}
409 workgroup = $sambasettings{'WORKGRP'}
410
411 keep alive = 30
412 os level = $sambasettings{'OSLEVEL'}
413 fstype = NTFS
414
415 kernel oplocks = false
416 map to guest = $sambasettings{'MAPTOGUEST'}
417 smb ports = 445 139
418 unix charset = CP850
419
420 security = $sambasettings{'SECURITY'}
421 encrypt passwords = yes
422 guest account = $sambasettings{'GUESTACCOUNT'}
423 unix password sync = $sambasettings{'PASSWORDSYNC'}
424 null passwords = yes
425
426 bind interfaces only = true
427 interfaces = $sambasettings{'INTERFACES'}
428 socket options = $sambasettings{'SOCKETOPTIONS'}
429 remote announce = $sambasettings{'REMOTEANNOUNCE'}
430
431 username level = 1
432 wins support = $sambasettings{'WINSSUPPORT'}
433 wins server = $sambasettings{'WINSSRV'}
434
435 log file = /var/log/samba/samba-log.%m
436 lock directory = /var/lock/samba
437 pid directory = /var/run/
438 log level = $sambasettings{'LOGLEVEL'}
439
440 preferred master = $sambasettings{'PREFERREDMASTER'}
441 domain master = $sambasettings{'DOMAINMASTER'}
442 local master = $sambasettings{'LOCALMASTER'}
443
444 END
445 ;
446 close FILE;
447
448 if ($sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' )
449 {
450 open (FILE, ">${General::swroot}/samba/pdc") or die "Can't save the pdc settings: $!";
451 flock (FILE, 2);
452 print FILE <<END
453 $sambasettings{'PDCOPTIONS'}
454 END
455 ;
456 close FILE;
457 system('/usr/local/bin/sambactrl smbsafeconfpdc');
458 }
459 else
460 {
461 system('/usr/local/bin/sambactrl smbsafeconf');
462 }
463 system("/usr/local/bin/sambactrl smbreload");
464 }
465 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
466
467
468 if ($errormessage) {
469 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
470 print "<class name='base'>$errormessage\n";
471 print "&nbsp;</class>\n";
472 &Header::closebox();
473 }
474
475 ############################################################################################################################
476 ########################################## Aktivieren von Checkboxen und Dropdowns #########################################
477
478 $checked{'WINSSUPPORT'}{'off'} = '';
479 $checked{'WINSSUPPORT'}{'on'} = '';
480 $checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'";
481 $checked{'PASSWORDSYNC'}{'off'} = '';
482 $checked{'PASSWORDSYNC'}{'on'} = '';
483 $checked{'PASSWORDSYNC'}{$sambasettings{'PASSWORDSYNC'}} = "checked='checked'";
484 $checked{'LOCALMASTER'}{'off'} = '';
485 $checked{'LOCALMASTER'}{'on'} = '';
486 $checked{'LOCALMASTER'}{$sambasettings{'LOCALMASTER'}} = "checked='checked'";
487 $checked{'DOMAINMASTER'}{'off'} = '';
488 $checked{'DOMAINMASTER'}{'on'} = '';
489 $checked{'DOMAINMASTER'}{$sambasettings{'DOMAINMASTER'}} = "checked='checked'";
490 $checked{'PREFERREDMASTER'}{'off'} = '';
491 $checked{'PREFERREDMASTER'}{'on'} = '';
492 $checked{'PREFERREDMASTER'}{$sambasettings{'PREFERREDMASTER'}} = "checked='checked'";
493 $checked{'GREEN'}{'off'} = '';
494 $checked{'GREEN'}{'on'} = '';
495 $checked{'GREEN'}{$sambasettings{'GREEN'}} = "checked='checked'";
496 $checked{'BLUE'}{'off'} = '';
497 $checked{'BLUE'}{'on'} = '';
498 $checked{'BLUE'}{$sambasettings{'BLUE'}} = "checked='checked'";
499 $checked{'ORANGE'}{'off'} = '';
500 $checked{'ORANGE'}{'on'} = '';
501 $checked{'ORANGE'}{$sambasettings{'ORANGE'}} = "checked='checked'";
502 $checked{'VPN'}{'off'} = '';
503 $checked{'VPN'}{'on'} = '';
504 $checked{'VPN'}{$sambasettings{'VPN'}} = "checked='checked'";
505
506 $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
507 $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
508
509 ############################################################################################################################
510 ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
511
512 &Header::openbox('100%', 'center', $Lang::tr{'samba'});
513 print <<END
514 <hr />
515 <br />
516 <table width='95%' cellspacing='0'>
517 END
518 ;
519 if ( $message ne "" )
520 {
521 print "<tr><td colspan='3' align='left'><font color='red'>$message</font>";
522 }
523
524 print <<END
525 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td></tr>
526 </table><table width='95%' cellspacing='0'>
527 END
528 ;
529
530 my $key = '';
531 foreach $key (sort keys %servicenames)
532 {
533 print "<tr><td align='left' width='40%'>$key</td>";
534 my $shortname = $servicenames{$key};
535 my $status = &isrunning($shortname);
536 print "$status</tr>";
537 }
538
539 print <<END
540 </table>
541 <br />
542 <table width='95%' cellspacing='0'>
543 <tr><td align='left' width='40%' />
544 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstart' /><input type='image' alt='$Lang::tr{'smbstart'}' src='/images/go-up.png' /></form></td>
545 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstop' /><input type='image' alt='$Lang::tr{'smbstop'}' src='/images/go-down.png' /></form></td>
546 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbrestart' /><input type='image' alt='$Lang::tr{'smbrestart'}' src='/images/view-refresh.png' /></form></td></tr>
547 </table>
548 <br />
549 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
550 <table width='95%' cellspacing='0'>
551 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
552 <tr><td align='left' width='40%'>$Lang::tr{'workgroup'}</td><td align='left'><input type='text' name='WORKGRP' value='$sambasettings{'WORKGRP'}' size="30" /></td></tr>
553 <tr><td align='left' width='40%'>$Lang::tr{'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%'>$Lang::tr{'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%'>$Lang::tr{'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%'>$Lang::tr{'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%'>$Lang::tr{'more'}</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>$Lang::tr{'security options'}</b></td></tr>
589 <tr><td align='left' width='40%'>$Lang::tr{'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%'>$Lang::tr{'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%'>$Lang::tr{'unix password 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>$Lang::tr{'network options'}</b></td></tr>
605 <tr><td align='left' width='40%'>$Lang::tr{'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%'>$Lang::tr{'socket options'}</td><td align='left'><input type='text' name='SOCKETOPTIONS' value='$sambasettings{'SOCKETOPTIONS'}' size="30" /></td></tr>
607 <tr><td align='left' width='40%'>$Lang::tr{'remote announce'}</td><td align='left'><input type='text' name='REMOTEANNOUNCE' value='$sambasettings{'REMOTEANNOUNCE'}' size="30" /></td></tr>
608 END
609 ;
610 if ($sambasettings{'WINSSUPPORT'} eq 'off') {print"<tr><td align='left' width='40%'>$Lang::tr{'wins server'}</td><td align='left'><input type='text' name='WINSSRV' value='$sambasettings{'WINSSRV'}' size='30' /></td></tr>";}
611 print <<END
612 <tr><td align='left' width='40%'>$Lang::tr{'wins support'}</td><td align='left'>on <input type='radio' name='WINSSUPPORT' value='on' $checked{'WINSSUPPORT'}{'on'} />/
613 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
614 END
615 ;
616
617 if ($sambasettings{'SECURITY'} eq 'user')
618 {
619 print <<END
620 <tr><td align='left' width='40%'>$Lang::tr{'local master'}</td><td align='left'>on <input type='radio' name='LOCALMASTER' value='on' $checked{'LOCALMASTER'}{'on'} />/
621 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
622 <tr><td align='left' width='40%'>$Lang::tr{'domain master'}</td><td align='left'>on <input type='radio' name='DOMAINMASTER' value='on' $checked{'DOMAINMASTER'}{'on'} />/
623 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
624 <tr><td align='left' width='40%'>$Lang::tr{'prefered master'}</td><td align='left'>on <input type='radio' name='PREFERREDMASTER' value='on' $checked{'PREFERREDMASTER'}{'on'} />/
625 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
626 END
627 ;
628 }
629
630 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
631 {
632 print <<END
633 <tr><td align='left'><br /></td><td></td></tr>
634 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
635 <tr><td align='left'><br /></td><td></td></tr>
636 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
637 END
638 ;
639 }
640
641 print <<END
642 </table>
643 <br />
644 <table width='10%' cellspacing='0'>
645 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
646 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
647 <input type='image' alt='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
648 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
649 <input type='hidden' name='ACTION' value='globalreset' />
650 <input type='image' alt='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
651 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
652 <input type='hidden' name='ACTION' value='globalcaption' />
653 <input type='image' alt='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
654 </table>
655 END
656 ;
657
658 if ($sambasettings{'ACTION'} eq 'globalcaption')
659 {
660 print <<END
661 <br />
662 <table width='95%' cellspacing='0'>
663 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
664 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
665 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
666 </table>
667 END
668 ;
669 }
670
671 &Header::closebox();
672
673 ############################################################################################################################
674 ########################################## Benutzerverwaltung fr Usersecurity #############################################
675
676 if ($sambasettings{'SECURITY'} eq 'user')
677 {
678 if ($sambasettings{'DOMAINMASTER'} eq 'off')
679 {
680 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
681 }
682 else
683 {
684 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
685 }
686 print <<END
687 <hr />
688 <br />
689 <table width='95%' cellspacing='0'>
690 <tr><td colspan='6' align='left'></td></tr>
691 <tr><td bgcolor='${Header::table1colour}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
692 <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
693 END
694 ;
695
696 if ($sambasettings{'DOMAINMASTER'} eq 'off')
697 {
698 print "<td></td>";
699 }
700 else
701 {
702 print "<td align='left'><u>$Lang::tr{'type'}</u></td>";
703 }
704
705 print "<td align='left'><u>$Lang::tr{'status'}</u></td><td colspan='3' width='5%' align='center'><u>$Lang::tr{'options'}</u></td></tr>";
706 system('/usr/local/bin/sambactrl readsmbpasswd');
707 open(FILE, "</var/ipfire/samba/private/smbpasswd") or die "Can't read user file: $!";
708 @user = <FILE>;
709 close(FILE);
710 system('/usr/local/bin/sambactrl locksmbpasswd');
711 foreach $userentry (sort @user)
712 {
713 @userline = split( /\:/, $userentry );
714 print "<tr><td align='left'>$userline[0]</td><td align='left'>";
715 if ($userline[4] =~ /N/)
716 {
717 print "$Lang::tr{'not set'}</td><td align='left'>";
718 }
719 else
720 {
721 print "$Lang::tr{'set'}</td><td align='left'>";
722 }
723
724 if ($sambasettings{'DOMAINMASTER'} eq 'off')
725 {
726 print "</td><td align='left'>";
727 }
728 else
729 {
730 if ($userline[0] =~ /\$/)
731 {
732 print "$Lang::tr{'pc'}</td><td align='left'>";
733 }
734 else
735 {
736 print "$Lang::tr{'user'}</td><td align='left'>";
737 }
738 }
739
740 if ($userline[4] =~ /D/)
741 {
742 print <<END
743 $Lang::tr{'inactive'}</td>
744 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
745 <input type='hidden' name='NAME' value='$userline[0]' />
746 <input type='hidden' name='ACTION' value='smbuserenable' />
747 <input type='image' alt='$Lang::tr{'activate'}' src='/images/on.gif' />
748 </form></td>
749 END
750 ;
751 }
752 else
753 {
754 print <<END
755 $Lang::tr{'active'}</td>
756 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
757 <input type='hidden' name='NAME' value='$userline[0]' />
758 <input type='hidden' name='ACTION' value='smbuserdisable' />
759 <input type='image' alt='$Lang::tr{'deactivate'}' src='/images/off.gif' />
760 </form></td>
761 END
762 ;
763 }
764
765 if ($userline[0] =~ /\$/)
766 {
767 print "<td></td>";
768 }
769 else
770 {
771 print <<END
772 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
773 <input type='hidden' name='NAME' value='$userline[0]' />
774 <input type='hidden' name='ACTION' value='userchangepw' />
775 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
776 </form></td>
777 END
778 ;
779 }
780
781 if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
782 {
783 print <<END
784 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
785 <input type='hidden' name='NAME' value='$userline[0]' />
786 <input type='hidden' name='ACTION' value='userdelete' />
787 <input type='image' alt='$Lang::tr{'delete'}' src='/images/network-error.png' />
788 </form></td></tr>
789 END
790 ;
791 }
792 else
793 {
794 print <<END
795 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
796 <input type='hidden' name='NAME' value='$userline[0]' />
797 <input type='hidden' name='ACTION' value='userdelete' />
798 <input type='image' alt='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
799 </form></td></tr>
800 END
801 ;
802 }
803 }
804 print <<END
805 </table>
806 <br />
807 <table width='10%' cellspacing='0'>
808 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
809 <input type='hidden' name='ACTION' value='useradd' />
810 <input type='image' alt='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
811 END
812 ;
813
814 if ($sambasettings{'DOMAINMASTER'} eq 'on')
815 {
816 print <<END
817 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
818 <input type='hidden' name='ACTION' value='pcadd' />
819 <input type='image' alt='$Lang::tr{'add pc'}' src='/images/network.png' /></form>
820 END
821 ;
822 }
823 print <<END
824 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
825 <input type='hidden' name='ACTION' value='usercaption' />
826 <input type='image' alt='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form>
827 </td></tr>
828 </table>
829 END
830 ;
831
832 if ($sambasettings{'ACTION'} eq 'usercaption')
833 {
834 print <<END
835 <br />
836 <table width='95%' cellspacing='0'>
837 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
838 <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr>
839 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'add pc'}</td></tr>
840 <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr>
841 <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr>
842 <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr>
843 <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr>
844 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
845 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
846 </table>
847 END
848 ;
849 }
850
851 if ($sambasettings{'ACTION'} eq 'userchangepw')
852 {
853 my $username = "$sambasettings{'NAME'}";
854 my $password = 'samba';
855 print <<END
856 <hr />
857 <br />
858 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
859 <table width='95%' cellspacing='0'>
860 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
861 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
862 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
863 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
864 <input type='image' alt=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
865 </table>
866 </form>
867 END
868 ;
869 }
870
871 if ($sambasettings{'ACTION'} eq 'useradd')
872 {
873 my $username = "user";
874 my $password = "samba";
875 chomp $username;
876 $username=~s/\s//g;
877 chomp $password;
878 $password=~s/\s//g;
879 print <<END
880 <hr />
881 <br />
882 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
883 <table width='95%' cellspacing='0'>
884 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
885 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
886 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
887 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr>
888 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
889 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
890 <input type='image' alt=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
891 </table>
892 </form>
893 END
894 ;
895 }
896
897 if ($sambasettings{'ACTION'} eq 'pcadd')
898 {
899 my $pcname = "client\$";
900 chomp $pcname;
901 $pcname=~s/\s//g;
902 print <<END
903 <hr />
904 <br />
905 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
906 <table width='95%' cellspacing='0'>
907 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
908 <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr>
909 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr>
910 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
911 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
912 <input type='image' alt=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
913 </table>
914 </form>
915 END
916 ;
917 }
918
919 &Header::closebox();
920 }
921
922 ############################################################################################################################
923 ############################################### Verwalten von Freigaben ####################################################
924
925 &Header::openbox('100%', 'center', $Lang::tr{'shares'});
926
927 print <<END
928 <hr />
929 <br />
930 <table width='95%' cellspacing='0'>
931 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b>
932 <tr><td align='left'><u>$Lang::tr{'sharename'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
933 END
934 ;
935
936 foreach $shareentry (sort @Shares)
937 {
938 print <<END
939 <tr><td align='left'>$shareentry</td>
940 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
941 <input type='hidden' name='NAME' value='$shareentry' />
942 <input type='hidden' name='ACTION' value='sharechange' />
943 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
944 </form></td>
945 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
946 <input type='hidden' name='NAME' value='$shareentry' />
947 <input type='hidden' name='ACTION' value='smbsharedel' />
948 <input type='image' alt='$Lang::tr{'delete'}' src='/images/user-trash.png' />
949 </form></td></tr>
950 END
951 ;
952 }
953
954 print <<END
955 </table>
956 <br />
957 <table width='10%' cellspacing='0'>
958 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
959 <input type='hidden' name='ACTION' value='shareadd' />
960 <input type='image' alt='$Lang::tr{'add share'}' src='/images/list-add.png' />
961 </form></td>
962 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
963 <input type='hidden' name='ACTION' value='sharesreset' />
964 <input type='image' alt='$Lang::tr{'reset'}' src='/images/reload.gif' />
965 </form></td>
966 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
967 <input type='hidden' name='ACTION' value='sharecaption' />
968 <input type='image' alt='$Lang::tr{'caption'}' src='/images/help-browser.png' />
969 </form></td>
970 </tr>
971 </table>
972 END
973 ;
974
975 if ($sambasettings{'ACTION'} eq 'sharecaption')
976 {
977 print <<END
978 <br />
979 <table width='95%' cellspacing='0'>
980 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
981 <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
982 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
983 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
984 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
985 <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
986 </table>
987 END
988 ;
989 }
990
991 if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
992 {
993 print <<END
994 <hr />
995 <br />
996 <table width='95%' cellspacing='0'>
997 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
998 <tr><td colspan='2' align='center'></td></tr>
999 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
1000 <a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=360,scrollbars=no, toolbar=no,status=no, resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')"><img border="0" src="/images/help-browser.png"></a>
1001 </td></tr>
1002 <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>
1003 </table>
1004 <br />
1005 <table width='10%' cellspacing='0'>
1006 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
1007 <input type='image' alt='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form>
1008 </table>
1009 END
1010 ;
1011 }
1012
1013 if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
1014 {
1015 my $sharename = "$sambasettings{'NAME'}";
1016 chomp $sharename;
1017 $sharename=~s/\s//g;
1018
1019 for(my $i = 0; $i <= $#Shares; $i++)
1020 {
1021 chomp $Shares[$i];
1022 $Shares[$i]=~s/\s//g;
1023 if ( "$Shares[$i]" eq "$sharename" )
1024 {
1025 my $Zeilenbegin = $Zeilen[$i+1]-2;
1026 my $Zeilenende = $Zeilen[$i+1]-$Zeilen[$i];
1027 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
1028 {$Zeilenende = $EOF-$Zeilen[$#Shares]+1;$Zeilenbegin = $EOF-$Zeilen[$#Shares]; $shareoption = qx(tail -$Zeilenende $sharefile | head -$Zeilenbegin);}
1029 else
1030 {$shareoption = qx(head -$Zeilenbegin $sharefile | tail -$Zeilenende);}
1031 }
1032 }
1033 print <<END
1034 <hr />
1035 <br />
1036 <table width='95%' cellspacing='0'>
1037 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
1038 <tr><td colspan='2' align='center'></td></tr>
1039 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<form method='post' action='$ENV{'SCRIPT_NAME'}'>
1040 <input type='hidden' name='ACTION' value='optioncaption2' />
1041 <input type='image' alt='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
1042 <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>
1043 </table>
1044 <br />
1045 <table width='10%' cellspacing='0'>
1046 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
1047 <input type='image' alt='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
1048 <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
1049 </table>
1050 END
1051 ;
1052 }
1053
1054 &Header::closebox();
1055
1056 ############################################################################################################################
1057 ############################################### Anzeige des Sambastatus ####################################################
1058
1059 &Header::openbox('100%', 'center', 'Status');
1060
1061 print <<END
1062 <hr />
1063 <br />
1064 <table width='95%' cellspacing='0'>
1065 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
1066 <tr><td align='left'>$Status</td></tr>
1067 </table>
1068 END
1069 ;
1070 &Header::closebox();
1071
1072 ############################################################################################################################
1073 ############################################### Anzeige des Sambastatus ####################################################
1074
1075
1076 if ($sambasettings{'ACTION'} eq 'showlog')
1077 {
1078 $Log = qx(tail -n $LOGLINES /var/log/samba/$sambasettings{'LOG'});
1079 $Log=~s/\n/<br \/>/g;
1080 }
1081
1082 &Header::openbox('100%', 'center', $Lang::tr{'log'});
1083
1084 print <<END
1085 <hr />
1086 <br />
1087 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1088 <table width='95%' cellspacing='0'>
1089 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
1090 <tr><td colspan='3' align='left'><br /></td></tr>
1091 <tr><td align='left'><select name='LOG' style="width: 200px">
1092 END
1093 ;
1094 foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1095 print <<END
1096
1097 </select></td><td align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
1098 <td align='left'><input type='hidden' name='ACTION' value='showlog' /><input type='image' alt='view Log' src='/images/format-justify-fill.png' /></td></tr>
1099 <tr><td colspan='3' align='left'><br /></td></tr>
1100 <tr><td colspan='3' align='left'><font size=2>$Log</font></td></tr>
1101 <tr><td colspan='3' align='left'><br /></td></tr>
1102 <tr><td colspan='3' align='center'>$sambasettings{'LOG'}</td></tr>
1103 </table>
1104 </form>
1105 END
1106 ;
1107
1108 &Header::closebox();
1109 &Header::closebigbox();
1110 &Header::closepage();
1111
1112 ############################################################################################################################
1113 ############################################ Subfunktion fr Sambadienste ###################################################
1114
1115 sub isrunning
1116 {
1117 my $cmd = $_[0];
1118 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1119 my $pid = '';
1120 my $testcmd = '';
1121 my $exename;
1122
1123 $cmd =~ /(^[a-z]+)/;
1124 $exename = $1;
1125
1126 if (open(FILE, "/var/run/${cmd}.pid"))
1127 {
1128 $pid = <FILE>; chomp $pid;
1129 close FILE;
1130 if (open(FILE, "/proc/${pid}/status"))
1131 {
1132 while (<FILE>)
1133 {
1134 if (/^Name:\W+(.*)/)
1135 {
1136 $testcmd = $1;
1137 }
1138 }
1139 close FILE;
1140 if ($testcmd =~ /$exename/)
1141 {
1142 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1143 }
1144 }
1145 }
1146 return $status;
1147 }