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