Fix samba.cgi: syslog only radiobutton.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / samba.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23 # enable only the following on debugging purpose
24 #use warnings;
25 #use CGI::Carp 'fatalsToBrowser';
26
27 require '/var/ipfire/general-functions.pl';
28 require "${General::swroot}/lang.pl";
29 require "${General::swroot}/header.pl";
30
31 my %sambasettings = ();
32 my %cgisettings = ();
33 my %checked = ();
34 my %netsettings = ();
35 my %ovpnsettings = ();
36 my %color = ();
37 my %mainsettings = ();
38 my $message = "";
39 my $errormessage = "";
40
41 my @Logs = qx(ls /var/log/samba/);
42 my $Log =$Lang::tr{'no log selected'};
43
44 my $Status = qx(/usr/local/bin/sambactrl smbstatus);
45 $Status=~s/\n/<br \/>/g;
46
47 my $userentry = "";
48 my @user = ();
49 my @userline = ();
50 my $userfile = "${General::swroot}/samba/private/smbpasswd";
51 my %selected= () ;
52
53 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";
54 my $defaultprinter= "[Printer]\ncomment = Printer public\npath = /var/spool/cups\nprinting = sysvn\nprintcap = lpstat\npublic = yes\nwritable = no\nprintable = yes";
55 my %printer = ();
56 my %shares = ();
57
58 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
59 &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
60 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
61 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
62
63 my @ovpnnetwork = split(/\//,$ovpnsettings{'DOVPN_SUBNET'});
64 my @ovpnip = split(/\./,$ovpnnetwork[0]);
65 $ovpnip[3]=$ovpnip[3]+1;
66
67 ############################################################################################################################
68 ############################################# Samba Dienste fr Statusberprfung ##########################################
69
70 my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd');
71 #my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd','Winbind Daemon' => 'winbindd');
72
73 &Header::showhttpheaders();
74
75 ############################################################################################################################
76 #################################### Initialisierung von Samba Variablen fr global Settings ###############################
77
78 $sambasettings{'WORKGRP'} = 'homeip.net';
79 $sambasettings{'NETBIOSNAME'} = 'IPFire';
80 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.5';
81 $sambasettings{'INTERFACES'} = '';
82 $sambasettings{'SECURITY'} = 'share';
83 $sambasettings{'OSLEVEL'} = '33';
84 $sambasettings{'GREEN'} = 'on';
85 $sambasettings{'BLUE'} = 'off';
86 $sambasettings{'ORANGE'} = 'off';
87 $sambasettings{'VPN'} = 'off';
88 $sambasettings{'WINSSRV'} = '';
89 $sambasettings{'WINSSUPPORT'} = 'on';
90 $sambasettings{'REMOTEANNOUNCE'} = '';
91 $sambasettings{'REMOTESYNC'} = '';
92 $sambasettings{'PASSWORDSYNC'} = 'off';
93 $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
94 $sambasettings{'GUESTACCOUNT'} = 'samba';
95 $sambasettings{'MAPTOGUEST'} = 'Never';
96 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
97 $sambasettings{'SYSLOGLEVEL'} = '1';
98 $sambasettings{'SYSLOGONLY'} = 'on';
99 $sambasettings{'DOSCHARSET'} = 'CP850';
100 $sambasettings{'UNIXCHARSET'} = 'UTF8';
101 $sambasettings{'DISPLAYCHARSET'} = 'CP850';
102 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
103 ### Values that have to be initialized
104 $sambasettings{'ACTION'} = '';
105 ### Samba CUPS Variablen
106 $sambasettings{'LOADPRINTERS'} = 'Yes';
107 $sambasettings{'PRINTING'} = 'cups';
108 $sambasettings{'PRINTCAPNAME'} = 'cups';
109 my $LOGLINES = '50';
110
111 ################################################## Samba PDC Variablen #####################################################
112
113 $sambasettings{'LOCALMASTER'} = 'off';
114 $sambasettings{'DOMAINMASTER'} = 'off';
115 $sambasettings{'PREFERREDMASTER'} = 'off';
116 my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
117
118
119 ############################################################################################################################
120
121 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
122 &Header::getcgihash(\%sambasettings);
123
124 sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();}
125
126 &Header::openpage('Samba', 1, '');
127 &Header::openbigbox('100%', 'left', '', $errormessage);
128
129 ############################################################################################################################
130 ############################################# Samba Rootskript aufrufe fr SU-Actions #######################################
131
132 if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");refreshpage();}
133 if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");refreshpage();}
134 if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
135 if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
136 if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");refreshpage();}
137 if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");refreshpage();}
138 if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");refreshpage();}
139 if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");refreshpage();}
140 if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");refreshpage();}
141 if ($sambasettings{'ACTION'} eq 'globalresetyes')
142 {
143 system("/usr/local/bin/sambactrl smbglobalreset");
144 $sambasettings{'WORKGRP'} = 'homeip.net';
145 $sambasettings{'NETBIOSNAME'} = 'IPFire';
146 $sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.0';
147 $sambasettings{'INTERFACES'} = '';
148 $sambasettings{'SECURITY'} = 'share';
149 $sambasettings{'OSLEVEL'} = '65';
150 $sambasettings{'GREEN'} = 'on';
151 $sambasettings{'BLUE'} = 'off';
152 $sambasettings{'ORANGE'} = 'off';
153 $sambasettings{'VPN'} = 'off';
154 $sambasettings{'WINSSRV'} = '';
155 $sambasettings{'WINSSUPPORT'} = 'on';
156 $sambasettings{'REMOTEANNOUNCE'} = '';
157 $sambasettings{'REMOTESYNC'} = '';
158 $sambasettings{'PASSWORDSYNC'} = 'off';
159 $sambasettings{'OTHERINTERFACES'} = '127.0.0.1';
160 $sambasettings{'GUESTACCOUNT'} = 'samba';
161 $sambasettings{'MAPTOGUEST'} = 'Never';
162 $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2';
163 $sambasettings{'SYSLOGLEVEL'} = '1';
164 $sambasettings{'SYSLOGONLY'} = 'on';
165 $sambasettings{'DOSCHARSET'} = 'CP850';
166 $sambasettings{'UNIXCHARSET'} = 'UTF8';
167 $sambasettings{'DISPLAYCHARSET'} = 'CP850';
168 ### Samba CUPS Variablen
169 $sambasettings{'LOADPRINTERS'} = 'Yes';
170 $sambasettings{'PRINTING'} = 'cups';
171 $sambasettings{'PRINTCAPNAME'} = 'cups';
172 $sambasettings{'PRINTERNAME'} = 'Printer';
173 ### Values that have to be initialized
174 $sambasettings{'ACTION'} = '';
175 $sambasettings{'LOCALMASTER'} = 'off';
176 $sambasettings{'DOMAINMASTER'} = 'off';
177 $sambasettings{'PREFERREDMASTER'} = 'off';
178 $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
179 $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
180 system("/usr/local/bin/sambactrl smbreload");
181 refreshpage();
182 }
183
184 ############################################################################################################################
185 ################################################ Sicherheitsabfrage für den Reset ##########################################
186
187 if ($sambasettings{'ACTION'} eq 'globalreset')
188 {
189 print <<END
190 <br />
191 <table width='95%' cellspacing='0'>
192 <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetglobals'}</b>
193 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
194 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
195 <input type='hidden' name='ACTION' value='globalresetyes' /></form></td>
196 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
197 <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
198 <input type='hidden' name='ACTION' value='cancel' /></form></td>
199 </tr>
200 </table>
201 END
202 ;
203 }
204
205 if ($sambasettings{'ACTION'} eq 'sharesreset')
206 {
207 print <<END
208 <br />
209 <table width='95%' cellspacing='0'>
210 <tr><td bgcolor='$color{'color20'}' colspan='3' align='center'><b>$Lang::tr{'resetshares'}</b>
211 <tr><td align='right' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
212 $Lang::tr{'yes'} <input type='image' alt='$Lang::tr{'yes'}' title='$Lang::tr{'yes'}' src='/images/edit-redo.png' />
213 <input type='hidden' name='ACTION' value='sharesresetyes' /></form></td>
214 <td align='left' width='50%'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
215 <input type='image' alt='$Lang::tr{'no'}' title='$Lang::tr{'no'}' src='/images/dialog-error.png' /> $Lang::tr{'no'}
216 <input type='hidden' name='ACTION' value='cancel' /></form></td>
217 </tr>
218 </table>
219 END
220 ;
221 }
222
223 ############################################################################################################################
224 ########################################### Samba Benutzer oder PC l�chen #################################################
225
226 if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");refreshpage();}
227
228 ############################################################################################################################
229 ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
230
231 if ($sambasettings{'ACTION'} eq $Lang::tr{'save'})
232 {
233 $sambasettings{'INTERFACES'} = '';
234 if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
235 if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
236 if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
237 if ($sambasettings{'VPN'} eq 'on'){$sambasettings{'INTERFACES'} .= " ";}
238 if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
239
240 ############################################################################################################################
241 ##################################### Schreiben settings und bersetzen fr smb.conf #######################################
242
243 delete $sambasettings{'__CGI__'};delete $sambasettings{'x'};delete $sambasettings{'y'};
244 &General::writehash("${General::swroot}/samba/settings", \%sambasettings);
245
246 if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
247 if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "true";$sambasettings{'WINSSRV'} = "";} else { $sambasettings{'WINSSUPPORT'} = "false";}
248 if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";}
249 if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";}
250 if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";}
251 if ($sambasettings{'SYSLOGONLY'} eq 'on'){ $sambasettings{'SYSLOGONLY'} = "yes";} else { $sambasettings{'SYSLOGONLY'} = "no";}
252
253 ############################################################################################################################
254 ############################################# Schreiben der Samba globals ##################################################
255
256 open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
257 flock (FILE, 2);
258
259 print FILE <<END
260 # global.settings by IPFire Project
261
262 [global]
263 netbios name = $sambasettings{'NETBIOSNAME'}
264 server string = $sambasettings{'SRVSTRING'}
265 workgroup = $sambasettings{'WORKGRP'}
266
267 keep alive = 30
268 os level = $sambasettings{'OSLEVEL'}
269 fstype = NTFS
270
271 kernel oplocks = false
272 map to guest = $sambasettings{'MAPTOGUEST'}
273 smb ports = 445 139
274 dos charset = $sambasettings{'DOSCHARSET'}
275 unix charset = $sambasettings{'UNIXCHARSET'}
276 display charset = $sambasettings{'DISPLAYCHARSET'}
277
278 security = $sambasettings{'SECURITY'}
279 encrypt passwords = yes
280 guest account = $sambasettings{'GUESTACCOUNT'}
281 unix password sync = $sambasettings{'PASSWORDSYNC'}
282 null passwords = yes
283
284 bind interfaces only = true
285 interfaces = $sambasettings{'INTERFACES'}
286 socket options = $sambasettings{'SOCKETOPTIONS'}
287 remote announce = $sambasettings{'REMOTEANNOUNCE'}
288 remote browse sync = $sambasettings{'REMOTESYNC'}
289
290 username level = 1
291 wins support = $sambasettings{'WINSSUPPORT'}
292 wins server = $sambasettings{'WINSSRV'}
293
294 log file = /var/log/samba/samba-log.%m
295 lock directory = /var/lock/samba
296 pid directory = /var/run/
297 log level = $sambasettings{'LOGLEVEL'}
298 syslog = $sambasettings{'SYSLOGLEVEL'}
299 syslog only = $sambasettings{'SYSLOGONLY'}
300
301 preferred master = $sambasettings{'PREFERREDMASTER'}
302 domain master = $sambasettings{'DOMAINMASTER'}
303 local master = $sambasettings{'LOCALMASTER'}
304
305 END
306 ;
307 close FILE;
308
309 if (-e "${General::swroot}/cups/enable"){
310 open (FILE, ">>${General::swroot}/samba/global") or die "Can't save the global cups settings: $!";
311 flock (FILE, 2);
312 print FILE <<END
313 load printers = $sambasettings{'LOADPRINTERS'}
314 printing = $sambasettings{'PRINTING'}
315 printcap name = $sambasettings{'PRINTCAPNAME'}
316
317 END
318 ;
319 close FILE;
320 }
321
322 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' )
323 {
324 open (FILE, ">${General::swroot}/samba/pdc") or die "Can't save the pdc settings: $!";
325 flock (FILE, 2);
326 chomp $sambasettings{'PDCOPTIONS'};
327 $sambasettings{'PDCOPTIONS'} =~ s/\r\n/\n/gi;
328 $sambasettings{'PDCOPTIONS'} =~ s/^\n//gi;
329 $sambasettings{'PDCOPTIONS'} =~ s/^\r//gi;
330 $sambasettings{'PDCOPTIONS'} =~ s/^.\n//gi;
331 $sambasettings{'PDCOPTIONS'} =~ s/^.\r//gi;
332 print FILE <<END
333 $sambasettings{'PDCOPTIONS'}
334 END
335 ;
336 close FILE;
337 }
338
339 if ( -e "/var/ipfire/cups/enable")
340 {
341 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");refreshpage();}
342 else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
343 }
344 else
345 {
346 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");refreshpage();}
347 else{system("/usr/local/bin/sambactrl smbsafeconf");}
348 }
349
350 system("/usr/local/bin/sambactrl smbreload");refreshpage();
351 }
352 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
353
354
355 if ($errormessage)
356 {
357 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
358 print "<class name='base'>$errormessage\n";
359 print "&nbsp;</class>\n";
360 &Header::closebox();
361 }
362
363 ############################################################################################################################
364 ########################################## Aktivieren von Checkboxen und Dropdowns #########################################
365
366 $checked{'SYSLOGONLY'}{'off'} = '';
367 $checked{'SYSLOGONLY'}{'on'} = '';
368 $checked{'SYSLOGONLY'}{$sambasettings{'SYSLOGONLY'}} = "checked='checked'";
369 $checked{'WINSSUPPORT'}{'off'} = '';
370 $checked{'WINSSUPPORT'}{'on'} = '';
371 $checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'";
372 $checked{'PASSWORDSYNC'}{'off'} = '';
373 $checked{'PASSWORDSYNC'}{'on'} = '';
374 $checked{'PASSWORDSYNC'}{$sambasettings{'PASSWORDSYNC'}} = "checked='checked'";
375 $checked{'LOCALMASTER'}{'off'} = '';
376 $checked{'LOCALMASTER'}{'on'} = '';
377 $checked{'LOCALMASTER'}{$sambasettings{'LOCALMASTER'}} = "checked='checked'";
378 $checked{'DOMAINMASTER'}{'off'} = '';
379 $checked{'DOMAINMASTER'}{'on'} = '';
380 $checked{'DOMAINMASTER'}{$sambasettings{'DOMAINMASTER'}} = "checked='checked'";
381 $checked{'PREFERREDMASTER'}{'off'} = '';
382 $checked{'PREFERREDMASTER'}{'on'} = '';
383 $checked{'PREFERREDMASTER'}{$sambasettings{'PREFERREDMASTER'}} = "checked='checked'";
384 $checked{'GREEN'}{'off'} = '';
385 $checked{'GREEN'}{'on'} = '';
386 $checked{'GREEN'}{$sambasettings{'GREEN'}} = "checked='checked'";
387 $checked{'BLUE'}{'off'} = '';
388 $checked{'BLUE'}{'on'} = '';
389 $checked{'BLUE'}{$sambasettings{'BLUE'}} = "checked='checked'";
390 $checked{'ORANGE'}{'off'} = '';
391 $checked{'ORANGE'}{'on'} = '';
392 $checked{'ORANGE'}{$sambasettings{'ORANGE'}} = "checked='checked'";
393 $checked{'VPN'}{'off'} = '';
394 $checked{'VPN'}{'on'} = '';
395 $checked{'VPN'}{$sambasettings{'VPN'}} = "checked='checked'";
396
397 $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'";
398 $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'";
399
400 ############################################################################################################################
401 ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ###################################
402
403 &Header::openbox('100%', 'center', $Lang::tr{'samba'});
404 print <<END
405 <br />
406 <table width='95%' cellspacing='0'>
407 END
408 ;
409 if ( $message ne "" )
410 {
411 print "<tr><td colspan='3' align='left'><font color='red'>$message</font>";
412 }
413
414 print <<END
415 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td></tr>
416 </table><table width='95%' cellspacing='0'>
417 END
418 ;
419
420 my $key = '';
421 foreach $key (sort keys %servicenames)
422 {
423 print "<tr><td align='left' width='40%'>$key</td>";
424 my $shortname = $servicenames{$key};
425 my $status = &isrunning($shortname);
426 print "$status</tr>";
427 }
428
429 print <<END
430 </table>
431 <br />
432 <table width='95%' cellspacing='0'>
433 <tr><td align='left' width='40%' />
434 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstart' /><input type='image' alt='$Lang::tr{'smbstart'}' title='$Lang::tr{'smbstart'}' src='/images/go-up.png' /></form></td>
435 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbstop' /><input type='image' alt='$Lang::tr{'smbstop'}' title='$Lang::tr{'smbstop'}' src='/images/go-down.png' /></form></td>
436 <td align='center' ><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='smbrestart' /><input type='image' alt='$Lang::tr{'smbrestart'}' title='$Lang::tr{'smbrestart'}' src='/images/view-refresh.png' /></form></td></tr>
437 </table>
438 <br />
439 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
440 <table width='95%' cellspacing='0'>
441 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr>
442 <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>
443 <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>
444 <tr><td align='left' width='40%'>$Lang::tr{'dos charset'}</td><td align='left'><input type='text' name='DOSCHARSET' value='$sambasettings{'DOSCHARSET'}' size="30" /></td></tr>
445 <tr><td align='left' width='40%'>$Lang::tr{'unix charset'}</td><td align='left'><input type='text' name='UNIXCHARSET' value='$sambasettings{'UNIXCHARSET'}' size="30" /></td></tr>
446 <tr><td align='left' width='40%'>$Lang::tr{'display charset'}</td><td align='left'><input type='text' name='DISPLAYCHARSET' value='$sambasettings{'DISPLAYCHARSET'}' size="30" /></td></tr>
447 <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>
448 <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>
449 <tr><td align='left' width='40%'>Sys$Lang::tr{'log level'}</td><td align='left'><input type='text' name='SYSLOGLEVEL' value='$sambasettings{'SYSLOGLEVEL'}' size="30" /></td></tr>
450 <tr><td align='left' width='40%'>Syslog only</td><td align='left'>on <input type='radio' name='SYSLOGONLY' value='on' $checked{'SYSLOGONLY'}{'on'} />/
451 <input type='radio' name='SYSLOGONLY' value='off' $checked{'SYSLOGONLY'}{'off'} /> off</td></tr>
452 <tr><td align='left' width='40%'>$Lang::tr{'interfaces'}</td><td align='left'>on <input type='radio' name='VPN' value='on' $checked{'VPN'}{'on'} />/
453 <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
454 <font size='2' color='$Header::colourovpn'><b> OpenVpn - $ovpnip[0].$ovpnip[1].$ovpnip[2].$ovpnip[3]/$ovpnnetwork[1]</b></font></td></tr>
455 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
456 <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
457 <font size='2' color='$Header::colourgreen'><b> $Lang::tr{'green'} - $netsettings{'GREEN_DEV'}</b></font></td></tr>
458 END
459 ;
460
461 if (&Header::blue_used())
462 {
463 print <<END
464 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='BLUE' value='on' $checked{'BLUE'}{'on'} />/
465 <input type='radio' name='BLUE' value='off' $checked{'BLUE'}{'off'} /> off |
466 <font size='2' color='$Header::colourblue'><b> $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'}</b></font></td></tr>
467 END
468 ;
469 }
470
471 if (&Header::orange_used())
472 {
473 print <<END
474 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='ORANGE' value='on' $checked{'ORANGE'}{'on'} />/
475 <input type='radio' name='ORANGE' value='off' $checked{'ORANGE'}{'off'} /> off |
476 <font size='2' color='$Header::colourorange'><b> $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'}</b></font></td></tr>
477 END
478 ;
479 }
480
481 print <<END
482 <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>
483 <tr><td align='left'><br /></td><td></td></tr>
484 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr>
485 <tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px">
486 <option value='share' $selected{'SECURITY'}{'share'}>Share</option>
487 <option value='user' $selected{'SECURITY'}{'user'}>User</option>
488 <option value='domain' $selected{'SECURITY'}{'domain'}>Domain</option>
489 <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option>
490 <option value='server' $selected{'SECURITY'}{'server'}>Server</option>
491 </select></td></tr>
492 <tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px">
493 <option value='Never' $selected{'MAPTOGUEST'}{'Never'}>Never</option>
494 <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option>
495 <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option>
496 </select></td></tr>
497 END
498 ;
499 #<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'} />/
500 # <input type='radio' name='PASSWORDSYNC' value='off' $checked{'PASSWORDSYNC'}{'off'} /> off</td></tr>
501 print <<END
502 <tr><td align='left'><br /></td><td /></tr>
503 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr>
504 <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>
505 <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>
506 <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>
507 <tr><td align='left' width='40%'>$Lang::tr{'remote browse sync'}</td><td align='left'><input type='text' name='REMOTESYNC' value='$sambasettings{'REMOTESYNC'}' size="30" /></td></tr>
508 END
509 ;
510 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>";}
511 print <<END
512 <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'} />/
513 <input type='radio' name='WINSSUPPORT' value='off' $checked{'WINSSUPPORT'}{'off'} /> off</td></tr>
514 END
515 ;
516
517 if ($sambasettings{'SECURITY'} eq 'user')
518 {
519 print <<END
520 <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'} />/
521 <input type='radio' name='LOCALMASTER' value='off' $checked{'LOCALMASTER'}{'off'} /> off</td></tr>
522 <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'} />/
523 <input type='radio' name='DOMAINMASTER' value='off' $checked{'DOMAINMASTER'}{'off'} /> off</td></tr>
524 <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'} />/
525 <input type='radio' name='PREFERREDMASTER' value='off' $checked{'PREFERREDMASTER'}{'off'} /> off</td></tr>
526 END
527 ;
528 }
529
530 if ($sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'on')
531 {
532 print <<END
533 <tr><td align='left'><br /></td><td></td></tr>
534 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pdc options'}</b></td></tr>
535 <tr><td align='left'><br /></td><td></td></tr>
536 <tr><td colspan='2' align='center'><textarea name="PDCOPTIONS" cols="50" rows="15" Wrap="off">$PDCOPTIONS</textarea></td></tr>
537 END
538 ;
539 }
540
541 if ( -e "/var/ipfire/cups/enable")
542 {
543 print <<END
544 <tr><td align='left'><br /></td><td></td></tr>
545 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'printing options'}</b></td></tr>
546 <tr><td align='left' width='40%'>$Lang::tr{'load printer'}</td><td align='left'><input type='text' name='LOADPRINTERS' value='$sambasettings{'LOADPRINTERS'}' size="30" /></td></tr>
547 <tr><td align='left' width='40%'>$Lang::tr{'printing'}</td><td align='left'><input type='text' name='PRINTING' value='$sambasettings{'PRINTING'}' size="30" /></td></tr>
548 <tr><td align='left' width='40%'>$Lang::tr{'printcap name'}</td><td align='left'><input type='text' name='PRINTCAPNAME' value='$sambasettings{'PRINTCAPNAME'}' size="30" /></td></tr>
549 END
550 ;
551 }
552
553 print <<END
554 </table>
555 <br />
556 <table width='10%' cellspacing='0'>
557 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
558 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
559 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
560 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
561 <input type='hidden' name='ACTION' value='globalreset' />
562 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' /></form></td>
563 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
564 <input type='hidden' name='ACTION' value='globalcaption' />
565 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr>
566 </table>
567 END
568 ;
569
570 if ($sambasettings{'ACTION'} eq 'globalcaption')
571 {
572 print <<END
573 <br />
574 <table width='95%' cellspacing='0'>
575 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
576 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr>
577 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr>
578 </table>
579 END
580 ;
581 }
582
583 &Header::closebox();
584
585 ############################################################################################################################
586 ########################################## Benutzerverwaltung fr Usersecurity #############################################
587
588 if ($sambasettings{'SECURITY'} eq 'user')
589 {
590 if ($sambasettings{'DOMAINMASTER'} eq 'off')
591 {
592 &Header::openbox('100%', 'center', $Lang::tr{'accounting user nonpdc'});
593 }
594 else
595 {
596 &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'});
597 }
598 print <<END
599 <a name="$Lang::tr{'accounting'}"</a>
600 <br />
601 <table width='95%' cellspacing='0'>
602 <tr><td colspan='6' align='left'></td></tr>
603 <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr>
604 <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td>
605 END
606 ;
607
608 if ($sambasettings{'DOMAINMASTER'} eq 'off')
609 {
610 print "<td></td>";
611 }
612 else
613 {
614 print "<td align='left'><u>$Lang::tr{'type'}</u></td>";
615 }
616
617 print "<td align='left'><u>$Lang::tr{'status'}</u></td><td colspan='3' width='5%' align='center'><u>$Lang::tr{'options'}</u></td></tr>";
618 system('/usr/local/bin/sambactrl readsmbpasswd');
619 open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!";
620 @user = <FILE>;
621 close(FILE);
622 system('/usr/local/bin/sambactrl locksmbpasswd');
623
624 my $lines = 0;
625
626 foreach $userentry (sort @user)
627 {
628 @userline = split( /\:/, $userentry );
629 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
630 print "<td align='left'>$userline[0]</td><td align='left'>";
631 if ($userline[4] =~ /N/)
632 {
633 print "$Lang::tr{'not set'}</td><td align='left'>";
634 }
635 else
636 {
637 print "$Lang::tr{'set'}</td><td align='left'>";
638 }
639
640 if ($sambasettings{'DOMAINMASTER'} eq 'off')
641 {
642 print "</td><td align='left'>";
643 }
644 else
645 {
646 if ($userline[0] =~ /\$/)
647 {
648 print "$Lang::tr{'pc'}</td><td align='left'>";
649 }
650 else
651 {
652 print "$Lang::tr{'user'}</td><td align='left'>";
653 }
654 }
655
656 if ($userline[4] =~ /D/)
657 {
658 print <<END
659 $Lang::tr{'inactive'}</td>
660 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
661 <input type='hidden' name='NAME' value='$userline[0]' />
662 <input type='hidden' name='ACTION' value='smbuserenable' />
663 <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' />
664 </form></td>
665 END
666 ;
667 }
668 else
669 {
670 print <<END
671 $Lang::tr{'active'}</td>
672 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
673 <input type='hidden' name='NAME' value='$userline[0]' />
674 <input type='hidden' name='ACTION' value='smbuserdisable' />
675 <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' />
676 </form></td>
677 END
678 ;
679 }
680
681 if ($userline[0] =~ /\$/)
682 {
683 print "<td></td>";
684 }
685 else
686 {
687 print <<END
688 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
689 <input type='hidden' name='NAME' value='$userline[0]' />
690 <input type='hidden' name='ACTION' value='userchangepw' />
691 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
692 </form></td>
693 END
694 ;
695 }
696
697 if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/)
698 {
699 print <<END
700 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
701 <input type='hidden' name='NAME' value='$userline[0]' />
702 <input type='hidden' name='ACTION' value='userdelete' />
703 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/network-error.png' />
704 </form></td></tr>
705 END
706 ;
707 }
708 else
709 {
710 print <<END
711 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
712 <input type='hidden' name='NAME' value='$userline[0]' />
713 <input type='hidden' name='ACTION' value='userdelete' />
714 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' />
715 </form></td></tr>
716 END
717 ;
718 }
719 $lines++;
720 }
721 print <<END
722 </table>
723 <br />
724 <table width='10%' cellspacing='0'>
725 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
726 <input type='hidden' name='ACTION' value='useradd' />
727 <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td>
728 END
729 ;
730
731 if ($sambasettings{'DOMAINMASTER'} eq 'on')
732 {
733 print <<END
734 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
735 <input type='hidden' name='ACTION' value='pcadd' />
736 <input type='image' alt='$Lang::tr{'pc add'}' title='$Lang::tr{'pc add'}' src='/images/network.png' /></form>
737 END
738 ;
739 }
740 print <<END
741 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
742 <input type='hidden' name='ACTION' value='usercaption' />
743 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form>
744 </td></tr>
745 </table>
746 END
747 ;
748
749 if ($sambasettings{'ACTION'} eq 'usercaption')
750 {
751 print <<END
752 <br />
753 <table width='95%' cellspacing='0'>
754 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
755 <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr>
756 <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr>
757 <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr>
758 <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr>
759 <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr>
760 <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr>
761 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr>
762 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
763 </table>
764 END
765 ;
766 }
767
768 if ($sambasettings{'ACTION'} eq 'userchangepw')
769 {
770 my $username = "$sambasettings{'NAME'}";
771 my $password = 'samba';
772 print <<END
773 <br />
774 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
775 <table width='95%' cellspacing='0'>
776 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr>
777 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly /></td></tr>
778 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
779 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' />
780 <input type='image' alt=$Lang::tr{'save'} title=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
781 </table>
782 </form>
783 END
784 ;
785 }
786
787 if ($sambasettings{'ACTION'} eq 'useradd')
788 {
789 my $username = "user";
790 my $password = "samba";
791 chomp $username;
792 $username=~s/\s//g;
793 chomp $password;
794 $password=~s/\s//g;
795 print <<END
796 <br />
797 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
798 <table width='95%' cellspacing='0'>
799 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr>
800 <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr>
801 <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr>
802 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr>
803 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
804 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' />
805 <input type='image' alt=$Lang::tr{'save'} title=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
806 </table>
807 </form>
808 END
809 ;
810 }
811
812 if ($sambasettings{'ACTION'} eq 'pcadd')
813 {
814 my $pcname = "client\$";
815 chomp $pcname;
816 $pcname=~s/\s//g;
817 print <<END
818 <br />
819 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'>
820 <table width='95%' cellspacing='0'>
821 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr>
822 <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr>
823 <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr>
824 <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr>
825 <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' />
826 <input type='image' title=$Lang::tr{'save'} alt=$Lang::tr{'save'} src='/images/media-floppy.png' /></td></tr>
827 </table>
828 </form>
829 END
830 ;
831 }
832
833 &Header::closebox();
834 }
835
836 ############################################################################################################################
837 ############################################### Verwalten von Freigaben ####################################################
838
839 &Header::openbox('100%', 'center', $Lang::tr{'shares'});
840
841 my %shares = config("${General::swroot}/samba/shares");
842
843
844 print <<END
845 <a name="$Lang::tr{'manage shares'}"</a>
846 <br />
847 <table width='95%' cellspacing='0'>
848 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b>
849 <tr><td align='left'><u>$Lang::tr{'sharename'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
850 END
851 ;
852
853 my @Shares = keys(%shares);
854 my $lines = 0;
855
856 foreach my $shareentry (sort @Shares)
857 {
858 chomp $shareentry;
859 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
860 print <<END
861 <td align='left'>$shareentry</td>
862 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
863 <input type='hidden' name='NAME' value='$shareentry' />
864 <input type='hidden' name='ACTION' value='sharechange' />
865 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
866 </form></td>
867 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
868 <input type='hidden' name='NAME' value='$shareentry' />
869 <input type='hidden' name='ACTION' value='smbsharedel' />
870 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
871 </form></td></tr>
872 END
873 ;
874 $lines++;
875 }
876
877 print <<END
878 </table>
879 <br />
880 <table width='10%' cellspacing='0'>
881 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
882 <input type='hidden' name='ACTION' value='shareadd' />
883 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' />
884 </form></td>
885 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
886 <input type='hidden' name='ACTION' value='sharesreset' />
887 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
888 </form></td>
889 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'>
890 <input type='hidden' name='ACTION' value='sharecaption' />
891 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
892 </form></td>
893 </tr>
894 </table>
895 END
896 ;
897
898 if ($sambasettings{'ACTION'} eq 'sharecaption')
899 {
900 print <<END
901 <br />
902 <table width='95%' cellspacing='0'>
903 <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr>
904 <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr>
905 <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr>
906 <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr>
907 <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'reset shares'}</td></tr>
908 <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr>
909 </table>
910 END
911 ;
912 }
913
914 if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' )
915 {
916 print <<END
917 <br />
918 <table width='95%' cellspacing='0'>
919 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr>
920 <tr><td colspan='2' align='center'></td></tr>
921 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
922 <a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, 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></td></tr>
923 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><tr><td colspan='2' align='center'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$defaultoption</textarea></td></tr>
924 </table>
925 <br />
926 <table width='10%' cellspacing='0'>
927 <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' />
928 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form>
929 </table>
930 END
931 ;
932 }
933
934 if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' )
935 {
936 my $shareoption = $shares{$sambasettings{'NAME'}};
937 print <<END
938 <br />
939 <table width='95%' cellspacing='0'>
940 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr>
941 <tr><td colspan='2' align='center'></td></tr>
942 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, 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></td></tr>
943 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$shareoption</textarea></td></tr>
944 </table>
945 <br />
946 <table width='10%' cellspacing='0'>
947 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
948 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
949 <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr>
950 </table>
951 END
952 ;
953 }
954
955 if ($sambasettings{'ACTION'} eq 'sharesresetyes')
956 {
957 system('/usr/local/bin/sambactrl smbsharesreset');
958 my $shares = config("${General::swroot}/samba/shares");
959 system("/usr/local/bin/sambactrl smbreload");
960 }
961 if ($sambasettings{'ACTION'} eq 'smbshareadd')
962 {
963 $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}";
964 save("shares");
965 my $shares = config("${General::swroot}/samba/shares");
966 }
967 if ($sambasettings{'ACTION'} eq 'smbsharedel')
968 {
969 delete $shares{$sambasettings{'NAME'}};
970 save("shares");
971 my %shares = config("${General::swroot}/samba/shares");
972 }
973 if ($sambasettings{'ACTION'} eq 'smbsharechange')
974 {
975 $shares{$sambasettings{'NAME'}} = $sambasettings{'SHAREOPTION'};
976 save("shares");
977 my %shares = config("${General::swroot}/samba/shares");
978 }
979
980 &Header::closebox();
981
982 ############################################################################################################################
983 ################################################ Verwalten von Druckern ####################################################
984
985 my %printer = config("${General::swroot}/samba/printer");
986
987 if ( -e "/var/ipfire/cups/enable")
988 {
989 &Header::openbox('100%', 'center', $Lang::tr{'printer'});
990
991 my @Printers = keys(%printer);
992 print <<END
993 <a name="$Lang::tr{'manage printers'}"</a>
994 <br />
995 <table width='95%' cellspacing='0'>
996 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage printers'}</b>
997 <tr><td align='left'><u>$Lang::tr{'printername'}</u></td><td colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></td></tr>
998 END
999 ;
1000 foreach my $printerentry (sort @Printers)
1001 {
1002 chomp $printerentry;
1003 print <<END
1004 <tr><td align='left'>$printerentry</td>
1005 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1006 <input type='hidden' name='NAME' value='$printerentry' />
1007 <input type='hidden' name='ACTION' value='printerchange' />
1008 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1009 </form></td>
1010 <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1011 <input type='hidden' name='NAME' value='$printerentry' />
1012 <input type='hidden' name='ACTION' value='smbprinterdel' />
1013 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
1014 </form></td></tr>
1015 END
1016 ;
1017 }
1018 print <<END
1019 </table>
1020 <br />
1021 <table width='10%' cellspacing='0'>
1022 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1023 <input type='hidden' name='ACTION' value='printeradd' />
1024 <input type='image' alt='$Lang::tr{'add printer'}' title='$Lang::tr{'add printer'}' src='/images/list-add.png' />
1025 </form></td>
1026 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1027 <input type='hidden' name='ACTION' value='printereset' />
1028 <input type='image' alt='$Lang::tr{'reset'}' title='$Lang::tr{'reset'}' src='/images/reload.gif' />
1029 </form></td>
1030 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'>
1031 <input type='hidden' name='ACTION' value='printercaption' />
1032 <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' />
1033 </form></td>
1034 </tr>
1035 </table>
1036 END
1037 ;
1038
1039 if ($sambasettings{'ACTION'} eq 'printeradd' || $sambasettings{'ACTION'} eq 'printercaption' )
1040 {
1041 print <<END
1042 <br />
1043 <table width='95%' cellspacing='0'>
1044 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add printer'}</b></td></tr>
1045 <tr><td colspan='2' align='center'></td></tr>
1046 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}
1047 <a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, 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></td></tr>
1048 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'><tr><td colspan='2' align='center'><textarea name="PRINTEROPTION" cols="50" rows="15" Wrap="off">$defaultprinter</textarea></td></tr>
1049 </table>
1050 <br />
1051 <table width='10%' cellspacing='0'>
1052 <tr><td align='center'><input type='hidden' name='ACTION' value='smbprinteradd' />
1053 <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr>
1054 </table>
1055 </form>
1056 END
1057 ;
1058 }
1059
1060 if ($sambasettings{'ACTION'} eq 'printerchange' || $sambasettings{'ACTION'} eq 'printercaption2' )
1061 {
1062 my $printeroption = $printer{$sambasettings{'NAME'}};
1063 print <<END
1064 <br />
1065 <table width='95%' cellspacing='0'>
1066 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit printer'}</b></td></tr>
1067 <tr><td colspan='2' align='center'></td></tr>
1068 <tr><td colspan='2' align='center'>$Lang::tr{'show share options'}<a href="sambahlp.cgi" target="popup" onClick="window.open ('', 'popup', 'width=580,height=600,scrollbars=yes, 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></td></tr>
1069 <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage printers'}'><textarea name="PRINTEROPTION" cols="50" rows="15" Wrap="off">$printeroption</textarea></td></tr>
1070 </table>
1071 <br />
1072 <table width='10%' cellspacing='0'>
1073 <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' />
1074 <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' />
1075 <input type='hidden' name='ACTION' value='smbprinterchange' /></form></td></tr>
1076 </table>
1077 END
1078 ;
1079 }
1080
1081 if ($sambasettings{'ACTION'} eq 'smbprinteradd')
1082 {
1083 $printer{'xvx'}= "$sambasettings{'PRINTEROPTION'}";
1084 save("printer");
1085 my %printer = config("${General::swroot}/samba/printer");
1086 }
1087
1088 if ($sambasettings{'ACTION'} eq 'smbprinterdel')
1089 {
1090 delete $printer{$sambasettings{'NAME'}};
1091 save("printer");
1092 my %printer = config("${General::swroot}/samba/printer");
1093 }
1094
1095 if ($sambasettings{'ACTION'} eq 'smbprinterchange')
1096 {
1097 $printer{$sambasettings{'NAME'}} = $sambasettings{'PRINTEROPTION'};
1098 save("printer");
1099 my %printer = config("${General::swroot}/samba/printer");
1100 }
1101
1102 &Header::closebox();
1103 }
1104
1105 ############################################################################################################################
1106 ############################################### Anzeige des Sambastatus ####################################################
1107
1108 &Header::openbox('100%', 'center', 'Status');
1109
1110 print <<END
1111 <br />
1112 <table width='95%' cellspacing='0'>
1113 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr>
1114 <tr><td align='left'>$Status</td></tr>
1115 </table>
1116 END
1117 ;
1118 &Header::closebox();
1119
1120 ############################################################################################################################
1121 ############################################### Anzeige der Sambalogs ######################################################
1122
1123
1124 if ($sambasettings{'ACTION'} eq 'showlog')
1125 {
1126 $Log = qx(tail -n $sambasettings{'LOGLINES'} /var/log/samba/$sambasettings{'LOG'});
1127 $Log=~s/\n/<br \/>/g;
1128 }
1129
1130 &Header::openbox('100%', 'center', $Lang::tr{'log'});
1131
1132 print <<END
1133 <a name="$Lang::tr{'log view'}"</a>
1134 <br />
1135 <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'log view'}'>
1136 <table width='95%' cellspacing='0'>
1137 <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'log view'}</b></td></tr>
1138 <tr><td colspan='3' align='left'><br /></td></tr>
1139 <tr><td align='left'><select name='LOG' style="width: 200px">
1140 END
1141 ;
1142 foreach my $log (@Logs) {chomp $log;print"<option value='$log'>$log</option>";}
1143 print <<END
1144
1145 </select></td><td align='left'>$Lang::tr{'show last x lines'}<input type='text' name='LOGLINES' value='$LOGLINES' size="3" /></td>
1146 <td align='left'><input type='hidden' name='ACTION' value='showlog' /><input type='image' alt='view Log' title='view Log' src='/images/format-justify-fill.png' /></td></tr>
1147 <tr><td colspan='3' align='left'><br /></td></tr>
1148 <tr><td colspan='3' align='left'><font size=2>$Log</font></td></tr>
1149 <tr><td colspan='3' align='left'><br /></td></tr>
1150 <tr><td colspan='3' align='center'>$sambasettings{'LOG'}</td></tr>
1151 </table>
1152 </form>
1153 END
1154 ;
1155 &Header::closebox();
1156 &Header::closebigbox();
1157 &Header::closepage();
1158
1159 ############################################################################################################################
1160 ############################################ Subfunktion fr Sambadienste ###################################################
1161
1162 sub config
1163 {
1164 my $file = shift;
1165 my @allarray = `grep -n '^\\[' $file`;
1166 my @linesarray = ();
1167 my @namearray = ();
1168 my %hash = ();
1169 my $options = ();
1170 my $EOF = qx(cat $file | wc -l);
1171 foreach my $allarrayentry (@allarray)
1172 {
1173 my @allarrayline = split( /\:/, $allarrayentry );
1174 push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]);
1175 }
1176 for(my $i = 0; $i <= $#namearray; $i++)
1177 {
1178 chomp $namearray[$i];
1179 $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g;
1180 if ( $i eq $#namearray )
1181 {
1182 my $lineend = $EOF-$linesarray[$i]+1;
1183 $options=qx(tail -$lineend $file);
1184 }
1185 else
1186 {
1187 my $linestart = $EOF-$linesarray[$i]+1;
1188 my $lineend = $linesarray[$i+1]-$linesarray[$i];
1189 $options=qx(tail -$linestart $file | head -$lineend);
1190 }
1191 $hash{$namearray[$i]} = "$options";
1192 #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging
1193 }
1194 return(%hash);
1195 }
1196
1197 sub save
1198 {
1199 my $smb = shift;
1200 open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!";
1201 flock (FILE, 2);
1202
1203 if ( $smb eq 'printer')
1204 {while (my ($name, $option) = each %printer){chomp $option;$option =~ s/\r\n/\n/gi;$option =~ s/^\n//gi;$option =~ s/^\r//gi;$option =~ s/^.\n//gi;$option =~ s/^.\r//gi;print FILE "$option\n";}}
1205
1206 if ( $smb eq 'shares')
1207 {while (my ($name, $option) = each %shares){chomp $option;$option =~ s/\r\n/\n/gi;$option =~ s/^\n//gi;$option =~ s/^\r//gi;$option =~ s/^.\n//gi;$option =~ s/^.\r//gi;print FILE "$option\n";} }
1208
1209 close FILE;
1210
1211 if ( -e "/var/ipfire/cups/enable")
1212 {
1213 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");}
1214 else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
1215 }
1216 else
1217 {
1218 if ( $sambasettings{'SECURITY'} eq 'user' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");}
1219 else{system("/usr/local/bin/sambactrl smbsafeconf");}
1220 }
1221
1222 system("/usr/local/bin/sambactrl smbreload");
1223 refreshpage();
1224 }
1225
1226 sub isrunning
1227 {
1228 my $cmd = $_[0];
1229 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
1230 my $pid = '';
1231 my $testcmd = '';
1232 my $exename;
1233
1234 $cmd =~ /(^[a-z]+)/;
1235 $exename = $1;
1236
1237 if (open(FILE, "/var/run/${cmd}.pid"))
1238 {
1239 $pid = <FILE>; chomp $pid;
1240 close FILE;
1241 if (open(FILE, "/proc/${pid}/status"))
1242 {
1243 while (<FILE>)
1244 {
1245 if (/^Name:\W+(.*)/)
1246 {
1247 $testcmd = $1;
1248 }
1249 }
1250 close FILE;
1251 if ($testcmd =~ /$exename/)
1252 {
1253 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
1254 }
1255 }
1256 }
1257 return $status;
1258 }