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