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