X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fsamba.cgi;h=28518867ed033fce3d642c6ab8647b7d6d1304f2;hp=69cb9fe25872fabe0cb57690ccb3df75b806d788;hb=97e7cfaf262bcc5c71288caafdc0b5ef3fe932e5;hpb=a08a5f33f844f3381e3fbe2fac03d72cc4fad552 diff --git a/html/cgi-bin/samba.cgi b/html/cgi-bin/samba.cgi index 69cb9fe258..28518867ed 100644 --- a/html/cgi-bin/samba.cgi +++ b/html/cgi-bin/samba.cgi @@ -1,15 +1,28 @@ #!/usr/bin/perl -# -# IPFire CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The IPFire Team +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use strict; # enable only the following on debugging purpose -use warnings; -use CGI::Carp 'fatalsToBrowser'; +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -60,7 +73,7 @@ my %servicenames = ('SMB Daemon' => 'smbd','NetBIOS Nameserver' => 'nmbd'); $sambasettings{'WORKGRP'} = 'homeip.net'; $sambasettings{'NETBIOSNAME'} = 'IPFire'; -$sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.0'; +$sambasettings{'SRVSTRING'} = 'Samba running on IPFire 2.3'; $sambasettings{'INTERFACES'} = ''; $sambasettings{'SECURITY'} = 'share'; $sambasettings{'OSLEVEL'} = '33'; @@ -71,11 +84,17 @@ $sambasettings{'VPN'} = 'off'; $sambasettings{'WINSSRV'} = ''; $sambasettings{'WINSSUPPORT'} = 'on'; $sambasettings{'REMOTEANNOUNCE'} = ''; +$sambasettings{'REMOTESYNC'} = ''; $sambasettings{'PASSWORDSYNC'} = 'off'; $sambasettings{'OTHERINTERFACES'} = '127.0.0.1'; $sambasettings{'GUESTACCOUNT'} = 'samba'; $sambasettings{'MAPTOGUEST'} = 'Never'; $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2'; +$sambasettings{'SYSLOGLEVEL'} = '1'; +$sambasettings{'SYSLOGONLY'} = 'on'; +$sambasettings{'DOSCHARSET'} = 'CP850'; +$sambasettings{'UNIXCHARSET'} = 'UTF8'; +$sambasettings{'DISPLAYCHARSET'} = 'CP850'; $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE'; ### Values that have to be initialized $sambasettings{'ACTION'} = ''; @@ -98,7 +117,7 @@ my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`; &General::readhash("${General::swroot}/samba/settings", \%sambasettings); &Header::getcgihash(\%sambasettings); -sub refreshpage{&Header::openbox( 'Waiting', 1, "" );} +sub refreshpage{&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'pagerefresh'}
";&Header::closebox();} &Header::openpage('Samba', 1, ''); &Header::openbigbox('100%', 'left', '', $errormessage); @@ -131,11 +150,17 @@ if ($sambasettings{'ACTION'} eq 'globalresetyes') $sambasettings{'WINSSRV'} = ''; $sambasettings{'WINSSUPPORT'} = 'on'; $sambasettings{'REMOTEANNOUNCE'} = ''; + $sambasettings{'REMOTESYNC'} = ''; $sambasettings{'PASSWORDSYNC'} = 'off'; $sambasettings{'OTHERINTERFACES'} = '127.0.0.1'; $sambasettings{'GUESTACCOUNT'} = 'samba'; $sambasettings{'MAPTOGUEST'} = 'Never'; $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2'; + $sambasettings{'SYSLOGLEVEL'} = '1'; + $sambasettings{'SYSLOGONLY'} = 'on'; + $sambasettings{'DOSCHARSET'} = 'CP850'; + $sambasettings{'UNIXCHARSET'} = 'UTF8'; + $sambasettings{'DISPLAYCHARSET'} = 'CP850'; ### Samba CUPS Variablen $sambasettings{'LOADPRINTERS'} = 'Yes'; $sambasettings{'PRINTING'} = 'cups'; @@ -205,7 +230,7 @@ $sambasettings{'INTERFACES'} = ''; if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";} if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";} if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";} -if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DDEVICE'}";} +if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DOVPN_SUBNET'}";} if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";} ############################################################################################################################ @@ -219,6 +244,7 @@ if ($sambasettings{'WINSSUPPORT'} eq 'on'){ $sambasettings{'WINSSUPPORT'} = "tru if ($sambasettings{'LOCALMASTER'} eq 'on'){ $sambasettings{'LOCALMASTER'} = "true";} else { $sambasettings{'LOCALMASTER'} = "false";} if ($sambasettings{'DOMAINMASTER'} eq 'on'){ $sambasettings{'DOMAINMASTER'} = "true";} else { $sambasettings{'DOMAINMASTER'} = "false";} if ($sambasettings{'PREFERREDMASTER'} eq 'on'){ $sambasettings{'PREFERREDMASTER'} = "true";} else { $sambasettings{'PREFERREDMASTER'} = "false";} +if ($sambasettings{'SYSLOGONLY'} eq 'on'){ $sambasettings{'SYSLOGONLY'} = "yes";} else { $sambasettings{'SYSLOGONLY'} = "no";} ############################################################################################################################ ############################################# Schreiben der Samba globals ################################################## @@ -241,7 +267,9 @@ fstype = NTFS kernel oplocks = false map to guest = $sambasettings{'MAPTOGUEST'} smb ports = 445 139 -unix charset = CP850 +dos charset = $sambasettings{'DOSCHARSET'} +unix charset = $sambasettings{'UNIXCHARSET'} +display charset = $sambasettings{'DISPLAYCHARSET'} security = $sambasettings{'SECURITY'} encrypt passwords = yes @@ -253,6 +281,7 @@ bind interfaces only = true interfaces = $sambasettings{'INTERFACES'} socket options = $sambasettings{'SOCKETOPTIONS'} remote announce = $sambasettings{'REMOTEANNOUNCE'} +remote browse sync = $sambasettings{'REMOTESYNC'} username level = 1 wins support = $sambasettings{'WINSSUPPORT'} @@ -260,9 +289,11 @@ wins server = $sambasettings{'WINSSRV'} log file = /var/log/samba/samba-log.%m lock directory = /var/lock/samba -pid directory = /var/run/ +pid directory = /var/run/ log level = $sambasettings{'LOGLEVEL'} - +syslog = $sambasettings{'SYSLOGLEVEL'} +syslog only = $sambasettings{'SYSLOGONLY'} + preferred master = $sambasettings{'PREFERREDMASTER'} domain master = $sambasettings{'DOMAINMASTER'} local master = $sambasettings{'LOCALMASTER'} @@ -304,12 +335,12 @@ END if ( -e "/var/ipfire/cups/enable") { if ( $sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");refreshpage();} - else {system("/usr/local/bin/sambactrl smbsafeconfcups");refreshpage();} + else {system("/usr/local/bin/sambactrl smbsafeconfcups");} } else { if ( $sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");refreshpage();} - else{system("/usr/local/bin/sambactrl smbsafeconf");refreshpage();} + else{system("/usr/local/bin/sambactrl smbsafeconf");} } system("/usr/local/bin/sambactrl smbreload");refreshpage(); @@ -328,6 +359,9 @@ if ($errormessage) ############################################################################################################################ ########################################## Aktivieren von Checkboxen und Dropdowns ######################################### +$checked{'SYSLOGONLY'}{'off'} = ''; +$checked{'SYSLOGONLY'}{'on'} = ''; +$checked{'SYSLOGONLY'}{$sambasettings{'SYSLOGONLY'}} = "checked='checked'"; $checked{'WINSSUPPORT'}{'off'} = ''; $checked{'WINSSUPPORT'}{'on'} = ''; $checked{'WINSSUPPORT'}{$sambasettings{'WINSSUPPORT'}} = "checked='checked'"; @@ -403,11 +437,17 @@ print <$Lang::tr{'basic options'} $Lang::tr{'workgroup'} $Lang::tr{'netbios name'} +$Lang::tr{'dos charset'} +$Lang::tr{'unix charset'} +$Lang::tr{'display charset'} $Lang::tr{'server string'} $Lang::tr{'log level'} +Sys$Lang::tr{'log level'} +Syslog onlyon / + off $Lang::tr{'interfaces'}on / off | - OpenVpn - $ovpnsettings{'DDEVICE'} + OpenVpn - $ovpnsettings{'DOVPN_SUBNET'} on / off | $Lang::tr{'green'} - $netsettings{'GREEN_DEV'} @@ -450,13 +490,17 @@ print <Bad User -$Lang::tr{'unix password sync'}on / - off +END +; +#$Lang::tr{'unix password sync'}on / +# off +print <
$Lang::tr{'network options'} $Lang::tr{'os level'} $Lang::tr{'socket options'} $Lang::tr{'remote announce'} +$Lang::tr{'remote browse sync'} END ; if ($sambasettings{'WINSSUPPORT'} eq 'off') {print"$Lang::tr{'wins server'}";} @@ -548,6 +592,7 @@ if ($sambasettings{'SECURITY'} eq 'user') &Header::openbox('100%', 'center', $Lang::tr{'accounting user pdc'}); } print <
@@ -571,10 +616,14 @@ END @user = ; close(FILE); system('/usr/local/bin/sambactrl locksmbpasswd'); + + my $lines = 0; + foreach $userentry (sort @user) { @userline = split( /\:/, $userentry ); - print "";} else {print "";} + print " END ; @@ -616,10 +665,10 @@ END { print < - END ; @@ -632,7 +681,7 @@ END else { print <
+
$userline[0]"; + if ($lines % 2) {print "
$userline[0]"; if ($userline[4] =~ /N/) { print "$Lang::tr{'not set'}"; @@ -604,10 +653,10 @@ END { print < -
+
- +
+
- + @@ -644,7 +693,7 @@ END if ($sambasettings{'DOMAINMASTER'} eq 'on' && $userline[0] =~ /\$/) { print < + @@ -655,7 +704,7 @@ END else { print < + @@ -663,12 +712,13 @@ END END ; } + $lines++; } print <
- END @@ -677,14 +727,14 @@ END if ($sambasettings{'DOMAINMASTER'} eq 'on') { print <
+
@@ -702,8 +752,8 @@ END - - + +
+
END ; } print <
+
$Lang::tr{'pc add'}
$Lang::tr{'delete user'}
$Lang::tr{'delete pc'}
$Lang::tr{'activate user'}
$Lang::tr{'deactivate user'}
$Lang::tr{'activate user'}
$Lang::tr{'deactivate user'}
$Lang::tr{'change passwords'}
$Lang::tr{'save config'}
@@ -717,7 +767,7 @@ END my $password = 'samba'; print < -
+ @@ -740,7 +790,7 @@ END $password=~s/\s//g; print < - +
$Lang::tr{'change passwords'}
$Lang::tr{'username'}
@@ -762,7 +812,7 @@ END $pcname=~s/\s//g; print < - +
$Lang::tr{'add user'}
$Lang::tr{'username'}
@@ -788,6 +838,7 @@ my %shares = config("${General::swroot}/samba/shares"); print <
$Lang::tr{'pc add'}
$Lang::tr{'client'}
";} else {print "";} print < - + - END ; + $lines++; } print <
$Lang::tr{'manage shares'} @@ -796,39 +847,42 @@ END ; my @Shares = keys(%shares); +my $lines = 0; foreach my $shareentry (sort @Shares) { chomp $shareentry; + if ($lines % 2) {print "
$shareentry + $shareentry
+
- - - @@ -862,7 +916,7 @@ if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optio - +
+
+
+
$Lang::tr{'show share options'}

@@ -882,7 +936,7 @@ if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'op - +
$Lang::tr{'edit share'}
$Lang::tr{'show share options'}

@@ -932,6 +986,7 @@ if ( -e "/var/ipfire/cups/enable") my @Printers = keys(%printer); print <
- -
$Lang::tr{'manage printers'} @@ -943,12 +998,12 @@ foreach my $printerentry (sort @Printers) chomp $printerentry; print <$printerentry +
+
@@ -960,15 +1015,15 @@ print <
- - - @@ -986,7 +1041,7 @@ if ($sambasettings{'ACTION'} eq 'printeradd' || $sambasettings{'ACTION'} eq 'pri - +
+
+
+
$Lang::tr{'show share options'}

@@ -1007,7 +1062,7 @@ if ($sambasettings{'ACTION'} eq 'printerchange' || $sambasettings{'ACTION'} eq ' - +
$Lang::tr{'edit printer'}
$Lang::tr{'show share options'}

@@ -1071,8 +1126,9 @@ $Log=~s/\n/
/g; &Header::openbox('100%', 'center', $Lang::tr{'log'}); print <
- +
$Lang::tr{'log view'}