Samba CGI 2sprachig DE und ENG
[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/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'} = '127.0.0.1';
85 $sambasettings{'GUESTACCOUNT'} = 'samba';
86 $sambasettings{'MAPTOGUEST'} = 'Never';
87 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
88 ### Values that have to be initialized
89 $sambasettings{'ACTION'} = '';
90 my $LOGLINES = '50';
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 'smbreload'){system("/usr/local/bin/sambactrl smbreload");}
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'} = '127.0.0.1';
138 $sambasettings{'GUESTACCOUNT'} = 'samba';
139 $sambasettings{'MAPTOGUEST'} = 'Never';
140 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 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', $Lang::tr{'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='3' align='left'><font color='red'>$message</font>";
513 }
514
515 print <<END
516 <tr><td colspan='3'><br /></td></tr>
517 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</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</td>";
526 my $shortname = $servicenames{$key};
527 my $status = &isrunning($shortname);
528 print "$status</tr>";
529 }
530
531 print <<END
532 <tr><td colspan='3'><br /></td></tr>
533 <tr><td></td><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
534 <input type='submit' name='ACTION' value='smbstart' />
535 <input type='submit' name='ACTION' value='smbstop' />
536 <input type='submit' name='ACTION' value='smbrestart' />
537 </form></td></tr>
538 </table>
539
540
541 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
542 <table width='95%' cellspacing='0'>
543 <tr><td colspan='2'><br /></td></tr>
544 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
545 <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>
546 <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>
547 <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>
548 <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>
549 <tr><td align='left' width='40%'>$Lang::tr{'interfaces'}</td><td align='left'>on <input type='radio' name='VPN' value='on' $checked{'VPN'}{'on'} />/
550 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
551 <font size='2' color='$Header::colourovpn'><b> OpenVpn - $ovpnsettings{'DDEVICE'}</b></font></td></tr>
552 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
553 <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
554 <font size='2' color='$Header::colourgreen'><b> $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font></td></tr>
555 END
556 ;
557
558 if (&Header::blue_used())
559 {
560 print <<END
561 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
562 <input type='radio' name='BLUE' value='off' $checked{'BLUE'}{'off'} /> off |
563 <font size='2' color='$Header::colourblue'><b> $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font></td></tr>
564 END
565 ;
566 }
567
568 if (&Header::orange_used())
569 {
570 print <<END
571 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
572 <input type='radio' name='ORANGE' value='off' $checked{'ORANGE'}{'off'} /> off |
573 <font size='2' color='$Header::colourorange'><b> $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font></td></tr>
574 END
575 ;
576 }
577
578 print <<END
579 <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>
580 <tr><td align='left'><br /></td><td></td></tr>
581 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr>
582 <tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px">
583 <option value='share' $selected{'SECURITY'}{'share'}>Share</option>
584 <option value='user' $selected{'SECURITY'}{'user'}>User</option>
585 <option value='domain' $selected{'SECURITY'}{'domain'}>Domain</option>
586 <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option>
587 <option value='server' $selected{'SECURITY'}{'server'}>Server</option>
588 </select></td></tr>
589 <tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px">
590 <option value='Never' $selected{'MAPTOGUEST'}{'Never'}>Never</option>
591 <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option>
592 <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option>
593 </select></td></tr>
594 <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'} />/
595 <input type='radio' name='PASSWORDSYNC' value='off' $checked{'PASSWORDSYNC'}{'off'} /> off</td></tr>
596 <tr><td align='left'><br /></td><td /></tr>
597 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr>
598 <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>
599 <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>
600 END
601 ;
602 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>";}
603 print <<END
604 <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'} />/
605 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
606 END
607 ;
608
609 if ($sambasettings{'SECURITY'} eq 'user')
610 {
611 print <<END
612 <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'} />/
613 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
614 <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'} />/
615 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
616 <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'} />/
617 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
618 END
619 ;
620 }
621
622 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
623 {
624 print <<END
625 <tr><td align='left'><br /></td><td></td></tr>
626 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
627 <tr><td align='left'><br /></td><td></td></tr>
628 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
629 END
630 ;
631 }
632
633 print <<END
634 </table>
635 <table width='10%' cellspacing='0'>
636 <tr><td colspan='3'><br /></td></tr>
637 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
638 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
639 <input type='image' alt='$Lang::tr{'save'}' src='/images/floppy.gif' /></form></td>
640 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
641 <input type='hidden' name='ACTION' value='globalreset' />
642 <input type='image' alt='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
643 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
644 <input type='hidden' name='ACTION' value='globalcaption' />
645 <input type='image' alt='$Lang::tr{'caption'}' src='/images/info.gif' /></form></td></tr>
646 </table>
647 END
648 ;
649
650 if ($sambasettings{'ACTION'} eq 'globalcaption')
651 {
652 print <<END
653 <table width='95%' cellspacing='0'>
654 <tr><td colspan='2'><br /></td></tr>
655 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
656 <tr><td align='right' width='33%'><img src='/images/floppy.gif' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
657 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
658 </table>
659 END
660 ;
661 }
662
663 &Header::closebox();
664
665 ############################################################################################################################
666 ########################################## Benutzerverwaltung fr Usersecurity #############################################
667
668 if ($sambasettings{'SECURITY'} eq 'user')
669 {
670 if ($sambasettings{'DOMAINMASTER'} eq 'off')
671 {
672 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
673 }
674 else
675 {
676 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
677 }
678 print <<END
679 <hr />
680 <table width='95%' cellspacing='0'>
681 <tr><td colspan='6'><br /></td></tr>
682 <tr><td colspan='6' align='left'></td></tr>
683 <tr><td bgcolor='${Header::table1colour}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
684 <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
685 END
686 ;
687
688 if ($sambasettings{'DOMAINMASTER'} eq 'off')
689 {
690 print "<td></td>";
691 }
692 else
693 {
694 print "<td align='left'><u>Typ</u></td>";
695 }
696
697 print "<td align='left'><u>$Lang::tr{'interfaces'}</u></td><td colspan='3' width='5%' align='center'><u>$Lang::tr{'options'}</u></td></tr>";
698 system('/usr/local/bin/sambactrl readsmbpasswd');
699 open(FILE, "</var/ipfire/samba/private/smbpasswd") or die "Can't read user file: $!";
700 @user = <FILE>;
701 close(FILE);
702 system('/usr/local/bin/sambactrl locksmbpasswd');
703 foreach $userentry (sort @user)
704 {
705 @userline = split( /\:/, $userentry );
706 print "<tr><td align='left'>$userline[0]</td><td align='left'>";
707 if ($userline[4] =~ /N/)
708 {
709 print "$Lang::tr{'not set'}</td><td align='left'>";
710 }
711 else
712 {
713 print "$Lang::tr{'set'}</td><td align='left'>";
714 }
715
716 if ($sambasettings{'DOMAINMASTER'} eq 'off')
717 {
718 print "</td><td align='left'>";
719 }
720 else
721 {
722 if ($userline[0] =~ /\$/)
723 {
724 print "$Lang::tr{'interfaces'}</td><td align='left'>";
725 }
726 else
727 {
728 print "$Lang::tr{'user'}</td><td align='left'>";
729 }
730 }
731
732 if ($userline[4] =~ /D/)
733 {
734 print <<END
735 inaktiv</td>
736 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
737 <input type='hidden' name='NAME' value='$userline[0]' />
738 <input type='hidden' name='ACTION' value='smbuserenable' />
739 <input type='image' alt='$Lang::tr{'activate'}' src='/images/on.gif' />
740 </form></td>
741 END
742 ;
743 }
744 else
745 {
746 print <<END
747 aktiv</td>
748 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
749 <input type='hidden' name='NAME' value='$userline[0]' />
750 <input type='hidden' name='ACTION' value='smbuserdisable' />
751 <input type='image' alt='$Lang::tr{'deactivate'}' src='/images/off.gif' />
752 </form></td>
753 END
754 ;
755 }
756
757 if ($userline[0] =~ /\$/)
758 {
759 print "<td></td>";
760 }
761 else
762 {
763 print <<END
764 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
765 <input type='hidden' name='NAME' value='$userline[0]' />
766 <input type='hidden' name='ACTION' value='userchangepw' />
767 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
768 </form></td>
769 END
770 ;
771 }
772
773 if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
774 {
775 print <<END
776 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
777 <input type='hidden' name='NAME' value='$userline[0]' />
778 <input type='hidden' name='ACTION' value='userdelete' />
779 <input type='image' alt='$Lang::tr{'delete'}' src='/images/network-error.png' />
780 </form></td></tr>
781 END
782 ;
783 }
784 else
785 {
786 print <<END
787 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
788 <input type='hidden' name='NAME' value='$userline[0]' />
789 <input type='hidden' name='ACTION' value='userdelete' />
790 <input type='image' alt='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
791 </form></td></tr>
792 END
793 ;
794 }
795 }
796 print <<END
797 </table>
798 <table width='10%' cellspacing='0'>
799 <tr><td colspan='3'><br /></td></tr>
800 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
801 <input type='hidden' name='ACTION' value='useradd' />
802 <input type='image' alt='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
803 END
804 ;
805
806 if ($sambasettings{'DOMAINMASTER'} eq 'on')
807 {
808 print <<END
809 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
810 <input type='hidden' name='ACTION' value='pcadd' />
811 <input type='image' alt='$Lang::tr{'add pc'}' src='/images/network.png' /></form>
812 END
813 ;
814 }
815 print <<END
816 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
817 <input type='hidden' name='ACTION' value='usercaption' />
818 <input type='image' alt='$Lang::tr{'caption'}' src='/images/info.gif' /></form>
819 </td></tr>
820 </table>
821 END
822 ;
823
824 if ($sambasettings{'ACTION'} eq 'usercaption')
825 {
826 print <<END
827 <table width='95%' cellspacing='0'>
828 <tr><td align='center' colspan='2'><br /></td></tr>
829 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
830 <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr>
831 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'add pc'}</td></tr>
832 <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr>
833 <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr>
834 <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr>
835 <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr>
836 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
837 <tr><td align='right' width='33%'><img src='/images/floppy.gif' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
838 </table>
839 END
840 ;
841 }
842
843 if ($sambasettings{'ACTION'} eq 'userchangepw')
844 {
845 my $username = "$sambasettings{'NAME'}";
846 my $password = 'samba';
847 print <<END
848 <hr />
849 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
850 <table width='95%' cellspacing='0'>
851 <tr><td colspan='2'><br /></td></tr>
852 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
853 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
854 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
855 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
856 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
857 </table>
858 </form>
859 END
860 ;
861 }
862
863 if ($sambasettings{'ACTION'} eq 'useradd')
864 {
865 my $username = "user";
866 my $password = "samba";
867 chomp $username;
868 $username=~s/\s//g;
869 chomp $password;
870 $password=~s/\s//g;
871 print <<END
872 <hr />
873 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
874 <table width='95%' cellspacing='0'>
875 <tr><td colspan='2'><br /></td></tr>
876 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
877 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
878 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
879 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr>
880 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
881 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
882 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
883 </table>
884 </form>
885 END
886 ;
887 }
888
889 if ($sambasettings{'ACTION'} eq 'pcadd')
890 {
891 my $pcname = "client\$";
892 chomp $pcname;
893 $pcname=~s/\s//g;
894 print <<END
895 <hr />
896 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
897 <table width='95%' cellspacing='0'>
898 <tr><td colspan='2'><br /></td></tr>
899 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
900 <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr>
901 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr>
902 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
903 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
904 <input type='image' alt=$Lang::tr{'save'} src='/images/floppy.gif' /></td></tr>
905 </table>
906 </form>
907 END
908 ;
909 }
910
911 &Header::closebox();
912 }
913
914 ############################################################################################################################
915 ############################################### Verwalten von Freigaben ####################################################
916
917 &Header::openbox('100%', 'center', $Lang::tr{'shares'});
918
919 print <<END
920 <hr />
921 <table width='95%' cellspacing='0'>
922 <tr><td colspan='3'><br /></td></tr>
923 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b>
924 <tr><td align='left'><u>$Lang::tr{'sharename'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
925 END
926 ;
927
928 foreach $shareentry (sort @Shares)
929 {
930 print <<END
931 <tr><td align='left'>$shareentry</td>
932 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
933 <input type='hidden' name='NAME' value='$shareentry' />
934 <input type='hidden' name='ACTION' value='sharechange' />
935 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
936 </form></td>
937 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
938 <input type='hidden' name='NAME' value='$shareentry' />
939 <input type='hidden' name='ACTION' value='smbsharedel' />
940 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
941 </form></td></tr>
942 END
943 ;
944 }
945
946 print <<END
947 </table>
948 <table width='10%' cellspacing='0'>
949 <tr><td colspan='3'><br /></td></tr>
950 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
951 <input type='hidden' name='ACTION' value='shareadd' />
952 <input type='image' alt='$Lang::tr{'add share'}' src='/images/add.gif' />
953 </form></td>
954 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
955 <input type='hidden' name='ACTION' value='sharesreset' />
956 <input type='image' alt='$Lang::tr{'reset'}' src='/images/reload.gif' />
957 </form></td>
958 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
959 <input type='hidden' name='ACTION' value='sharecaption' />
960 <input type='image' alt='$Lang::tr{'caption'}' src='/images/info.gif' />
961 </form></td></tr>
962 </table>
963 END
964 ;
965
966 if ($sambasettings{'ACTION'} eq 'sharecaption')
967 {
968 print <<END
969 <table width='95%' cellspacing='0'>
970 <tr><td align='center' colspan='2'><br /></td></tr>
971 <tr><td align='center' colspan='2'><b>Legende:</b></td></tr>
972 <tr><td align='right' width='33%'><img src='/images/add.gif' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
973 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
974 <tr><td align='right' width='33%'><img src='/images/floppy.gif' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
975 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
976 <tr><td align='right' width='33%'><img src='/images/delete.gif' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
977 </table>
978 END
979 ;
980 }
981
982 if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
983 {
984 print <<END
985 <hr />
986 <table width='95%' cellspacing='0'>
987 <tr><td colspan='2'><br /></td></tr>
988 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
989 <tr><td colspan='2' align='center'></td></tr>
990 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<form method='post' action='$ENV{'SCRIPT_NAME'}'>
991 <input type='hidden' name='ACTION' value='optioncaption' />
992 <input type='image' alt='$Lang::tr{'caption'}' src='/images/info.gif' />
993 </form></td></tr>
994 <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>
995 </table>
996 <table width='10%' cellspacing='0'>
997 <tr><td><br /></td></tr>
998 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
999 <input type='image' alt='$Lang::tr{'add share'}' src='/images/floppy.gif' /></td></tr></form>
1000 </table>
1001 END
1002 ;
1003 }
1004
1005 if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
1006 {
1007 my $sharename = "$sambasettings{'NAME'}";
1008 chomp $sharename;
1009 $sharename=~s/\s//g;
1010
1011 for(my $i = 0; $i <= $#Shares; $i++)
1012 {
1013 chomp $Shares[$i];
1014 $Shares[$i]=~s/\s//g;
1015 if ( "$Shares[$i]" eq "$sharename" )
1016 {
1017 my $Zeilenbegin = $Zeilen[$i+1]-2;
1018 my $Zeilenende = $Zeilen[$i+1]-$Zeilen[$i];
1019 if ( $Zeilen[$i] eq $Zeilen[$#Shares] )
1020 {$Zeilenende = $EOF-$Zeilen[$#Shares]+1;$Zeilenbegin = $EOF-$Zeilen[$#Shares]; $shareoption = qx(tail -$Zeilenende $sharefile | head -$Zeilenbegin);}
1021 else
1022 {$shareoption = qx(head -$Zeilenbegin $sharefile | tail -$Zeilenende);}
1023 }
1024 }
1025 print <<END
1026 <hr />
1027 <table width='95%' cellspacing='0'>
1028 <tr><td colspan='2'><br /></td></tr>
1029 <tr bgcolor='${Header::table1colour}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
1030 <tr><td colspan='2' align='center'></td></tr>
1031 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<form method='post' action='$ENV{'SCRIPT_NAME'}'>
1032 <input type='hidden' name='ACTION' value='optioncaption2' />
1033 <input type='image' alt='$Lang::tr{'caption'}' src='/images/info.gif' /></form></td></tr>
1034 <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>
1035 </table>
1036 <table width='10%' cellspacing='0'>
1037 <tr><td><br /></td></tr>
1038 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
1039 <input type='image' alt='$Lang::tr{'change share'}' src='/images/floppy.gif' />
1040 <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
1041 </table>
1042 END
1043 ;
1044 }
1045
1046 if ($sambasettings{'ACTION'} eq 'optioncaption' || $sambasettings{'ACTION'} eq 'optioncaption2')
1047 {
1048 print <<END
1049 <table width='95%' cellspacing='0'>
1050 <tr><td><br /></td></tr>
1051 <tr><td><b>$Lang::tr{'caption'}</b></td></tr>
1052 <tr><td><u>$Lang::tr{'options'}</u></td><td><u>$Lang::tr{'meaning'}</u> / <u>$Lang::tr{'exampel'}</u></td></tr>
1053 <tr><td>comment</td><td>$Lang::tr{'comment'}</td></tr>
1054 <tr><td></td><td>comment = $Lang::tr{'my new share'}</td></tr>
1055 <tr><td><br /></td><td></td></tr>
1056 <tr><td>path</td><td>$Lang::tr{'path to directory'}</td></tr>
1057 <tr><td></td><td>path = /tmp</td></tr>
1058 <tr><td><br /></td><td></td></tr>
1059 <tr><td>writeable</td><td>$Lang::tr{'directory writeable'}</td></tr>
1060 <tr><td></td><td>writeable = yes</td></tr>
1061 <tr><td><br /></td><td></td></tr>
1062 <tr><td>browseable</td><td>sichtbar in Verzeichnisliste</td></tr>
1063 <tr><td></td><td>browsable = yes</td></tr>
1064 <tr><td><br /></td><td></td></tr>
1065 <tr><td>user</td><td>Besitzer der Freigabe</td></tr>
1066 <tr><td></td><td>user = samba</td></tr>
1067 <tr><td><br /></td><td></td></tr>
1068 <tr><td>valid users</td><td>Liste der Zugriffsberechtigten</td></tr>
1069 <tr><td></td><td>valid users = samba, user1</td></tr>
1070 <tr><td><br /></td><td></td></tr>
1071 <tr><td>write list</td><td>$Lang::tr{'visible in browselist'}</td></tr>
1072 <tr><td></td><td>write list = samba</td></tr>
1073 <tr><td><br /></td><td></td></tr>
1074 <tr><td>hosts allow</td><td>$Lang::tr{'host allow'}</td></tr>
1075 <tr><td></td><td>hosts allow = localhost 192.168.1.1 192.168.2.0/24</td></tr>
1076 <tr><td><br /></td><td></td></tr>
1077 <tr><td>hosts deny</td><td>$Lang::tr{'host deny'}</td></tr>
1078 <tr><td></td><td>hosts deny = 192.168.1.2 192.168.3.0/24</td></tr>
1079 <tr><td><br /></td><td></td></tr>
1080 <tr><td>read list</td><td>$Lang::tr{'read list'}</td></tr>
1081 <tr><td></td><td>read list = user1</td></tr>
1082 <tr><td><br /></td><td></td></tr>
1083 <tr><td>admin users</td><td>$Lang::tr{'admin users'}</td></tr>
1084 <tr><td></td><td>admin users = user1</td></tr>
1085 <tr><td><br /></td><td></td></tr>
1086 <tr><td>invalid users</td><td>$Lang::tr{'invalid users'}</td></tr>
1087 <tr><td></td><td>invalid users = user2</td></tr>
1088 <tr><td><br /></td><td></td></tr>
1089 <tr><td>force user</td><td>$Lang::tr{'force user'}</td></tr>
1090 <tr><td></td><td>force user = samba</td></tr>
1091 <tr><td><br /></td><td></td></tr>
1092 <tr><td>directory mask</td><td>$Lang::tr{'directory mask'}</td></tr>
1093 <tr><td></td><td>directory mask = 0777</td></tr>
1094 <tr><td><br /></td><td></td></tr>
1095 <tr><td>create mask</td><td>U$Lang::tr{'create mask'}</td></tr>
1096 <tr><td></td><td>create mask = 0777</td></tr>
1097 <tr><td><br /></td><td></td></tr>
1098 <tr><td>guest ok</td><td>$Lang::tr{'guest ok'}</td></tr>
1099 <tr><td></td><td>guest ok = yes</td></tr>
1100 </table>
1101 END
1102 ;
1103 }
1104
1105 &Header::closebox();
1106
1107 ############################################################################################################################
1108 ############################################### Anzeige des Sambastatus ####################################################
1109
1110 &Header::openbox('100%', 'center', 'Status');
1111
1112 print <<END
1113 <hr />
1114 <table width='95%' cellspacing='0'>
1115 <tr><td colspan='4' align='left'><br /></td></tr>
1116 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
1117 <tr><td align='left'>$Status</td></tr>
1118 </table>
1119 END
1120 ;
1121 &Header::closebox();
1122
1123 ############################################################################################################################
1124 ############################################### Anzeige des Sambastatus ####################################################
1125
1126
1127 if ($sambasettings{'ACTION'} eq 'showlog')
1128 {
1129 $Log = qx(tail -n $LOGLINES /var/log/samba/$sambasettings{'LOG'});
1130 $Log=~s/\n/<br \/>/g;
1131 }
1132
1133 &Header::openbox('100%', 'center', $Lang::tr{'log'});
1134
1135 print <<END
1136 <hr />
1137 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1138 <table width='95%' cellspacing='0'>
1139 <tr><td colspan='3' align='left'><br /></td></tr>
1140 <tr><td bgcolor='${Header::table1colour}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
1141 <tr><td colspan='3' align='left'><br /></td></tr>
1142 <tr><td align='left'><select name='LOG' style="width: 200px">
1143 END
1144 ;
1145 foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1146 print <<END
1147
1148 </select></td><td align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
1149 <td align='left'><input type='hidden' name='ACTION' value='showlog' /><input type='image' alt='view Log' src='/images/document-open.png' /></td></tr>
1150 <tr><td colspan='3' align='left'><br /></td></tr>
1151 <tr><td colspan='3' align='left'><font size=2>$Log</font></td></tr>
1152 <tr><td colspan='3' align='left'><br /></td></tr>
1153 <tr><td colspan='3' align='center'>$sambasettings{'LOG'}</td></tr>
1154 </table>
1155 </form>
1156 END
1157 ;
1158
1159 &Header::closebox();
1160 &Header::closebigbox();
1161 &Header::closepage();
1162
1163 ############################################################################################################################
1164 ############################################ Subfunktion fr Sambadienste ###################################################
1165
1166 sub isrunning
1167 {
1168 my $cmd = $_[0];
1169 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1170 my $pid = '';
1171 my $testcmd = '';
1172 my $exename;
1173
1174 $cmd =~ /(^[a-z]+)/;
1175 $exename = $1;
1176
1177 if (open(FILE, "/var/run/${cmd}.pid"))
1178 {
1179 $pid = <FILE>; chomp $pid;
1180 close FILE;
1181 if (open(FILE, "/proc/${pid}/status"))
1182 {
1183 while (<FILE>)
1184 {
1185 if (/^Name:\W+(.*)/)
1186 {
1187 $testcmd = $1;
1188 }
1189 }
1190 close FILE;
1191 if ($testcmd =~ /$exename/)
1192 {
1193 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1194 }
1195 }
1196 }
1197 return $status;
1198 }