Bugfixes in Samba und Sambactrl
authormaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Thu, 3 May 2007 21:26:52 +0000 (21:26 +0000)
committermaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Thu, 3 May 2007 21:26:52 +0000 (21:26 +0000)
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@519 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

config/samba/default.shares
html/cgi-bin/samba.cgi
src/misc-progs/sambactrl.c

index ccd9440..015870a 100644 (file)
@@ -7,7 +7,6 @@ create mask = 0777
 directory mask = 0777\r
 guest ok = yes\r
 force user = samba\r
-\r
 [P2P]\r
 path = /var/ipfire/samba/p2p\r
 comment = P2P\r
index b916ef0..c4b3226 100644 (file)
@@ -94,21 +94,23 @@ my $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
 &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
 &Header::getcgihash(\%sambasettings);
 
+sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );}
+
 &Header::openpage('Samba', 1, '');
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
 ############################################################################################################################
 ############################################# Samba Rootskript aufrufe fr SU-Actions #######################################
 
-if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");}
-if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");}
-if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
-if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");}
-if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");}
-if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");}
-if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");}
-if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");}
-if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");}
+if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");refreshpage();}
+if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");refreshpage();}
 if ($sambasettings{'ACTION'} eq 'globalresetyes')
        {
        system("/usr/local/bin/sambactrl smbglobalreset");
@@ -143,6 +145,7 @@ if ($sambasettings{'ACTION'} eq 'globalresetyes')
        $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE';
        $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`;
        system("/usr/local/bin/sambactrl smbreload");
+       refreshpage();
        }
 
 ############################################################################################################################
@@ -187,7 +190,7 @@ END
 ############################################################################################################################
 ########################################### Samba Benutzer oder PC l�chen #################################################
 
-if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");}
+if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");refreshpage();}
 
 ############################################################################################################################
 ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ######################################
@@ -204,6 +207,7 @@ if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= "
 ############################################################################################################################
 ##################################### Schreiben settings und bersetzen fr smb.conf #######################################
 
+delete $sambasettings{'__CGI__'};delete $sambasettings{'x'};delete $sambasettings{'y'};
 &General::writehash("${General::swroot}/samba/settings", \%sambasettings);
 
 if ($sambasettings{'PASSWORDSYNC'} eq 'on'){ $sambasettings{'PASSWORDSYNC'} = "true";} else { $sambasettings{'PASSWORDSYNC'} = "false";}
@@ -295,16 +299,16 @@ END
 
 if ( -e "/var/ipfire/cups/enable")
        {
-       if ( $sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdccups");}
-       else {system("/usr/local/bin/sambactrl smbsafeconfcups");}
+       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
        {
-       if ( $sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");}
-       else{system("/usr/local/bin/sambactrl smbsafeconf");}
+       if ( $sambasettings{'SECURITY'} eq 'User' && $sambasettings{'DOMAINMASTER'} eq 'true' ){system("/usr/local/bin/sambactrl smbsafeconfpdc");refreshpage();}
+       else{system("/usr/local/bin/sambactrl smbsafeconf");refreshpage();}
        }
 
-system("/usr/local/bin/sambactrl smbreload");
+system("/usr/local/bin/sambactrl smbreload");refreshpage();
 }
   &General::readhash("${General::swroot}/samba/settings", \%sambasettings);
   
@@ -1165,6 +1169,7 @@ else
        }
 
 system("/usr/local/bin/sambactrl smbreload");
+refreshpage();
 }
 
 sub isrunning
index 9991ee6..8493540 100644 (file)
@@ -48,48 +48,48 @@ return 0;
 
 if (strcmp(argv[1], "smbsafeconf")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
 return 0;
 }
 
 if (strcmp(argv[1], "smbsafeconfcups")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf");
 return 0;
 }
 
 if (strcmp(argv[1], "smbsafeconfpdc")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
 return 0;
 }
 
 if (strcmp(argv[1], "smbsafeconfpdccups")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf");
 return 0;
 }
 
 if (strcmp(argv[1], "smbglobalreset")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/default.global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf >/dev/null");
-safe_system("/bin/cat /var/ipfire/samba/default.settings > /var/ipfire/samba/settings >/dev/null");
-safe_system("/bin/cat /var/ipfire/samba/default.global > /var/ipfire/samba/global >/dev/null");
-safe_system("/bin/cat /var/ipfire/samba/default.pdc > /var/ipfire/samba/pdc >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/default.global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
+safe_system("/bin/cat /var/ipfire/samba/default.settings > /var/ipfire/samba/settings");
+safe_system("/bin/cat /var/ipfire/samba/default.global > /var/ipfire/samba/global");
+safe_system("/bin/cat /var/ipfire/samba/default.pdc > /var/ipfire/samba/pdc");
 return 0;
 }
 
 if (strcmp(argv[1], "smbsharesreset")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/default.shares > /var/ipfire/samba/smb.conf >/dev/null");
-safe_system("/bin/cat /var/ipfire/samba/default.shares > /var/ipfire/samba/shares >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/default.shares > /var/ipfire/samba/smb.conf");
+safe_system("/bin/cat /var/ipfire/samba/default.shares > /var/ipfire/samba/shares");
 return 0;
 }
 
 if (strcmp(argv[1], "smbprinterreset")==0)
 {
-safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/default.printer > /var/ipfire/samba/smb.conf >/dev/null");
-safe_system("/bin/cat /var/ipfire/samba/default.printer > /var/ipfire/samba/printer >/dev/null");
+safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/default.printer > /var/ipfire/samba/smb.conf");
+safe_system("/bin/cat /var/ipfire/samba/default.printer > /var/ipfire/samba/printer");
 return 0;
 }
 
@@ -128,7 +128,9 @@ if (strcmp(argv[1], "smbuseradd")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambauser >/dev/null");
 safe_system(command);
-snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g %s -p %s -s %s %s >/dev/null", argv[4], argv[3], argv[5], argv[2]);
+snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g %s -s %s %s >/dev/null", argv[4], argv[5], argv[2]);
+safe_system(command);
+snprintf(command, BUFFER_SIZE-1, "echo %s:%s | chpasswd", argv[2], argv[3]);
 safe_system(command);
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s >/dev/null", argv[3], argv[3], argv[2]);
 safe_system(command);
@@ -148,6 +150,8 @@ return 0;
 
 if (strcmp(argv[1], "smbchangepw")==0)
 {
+snprintf(command, BUFFER_SIZE-1, "echo %s:%s | chpasswd", argv[2], argv[3]);
+safe_system(command);
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s >/dev/null", argv[3], argv[3], argv[2]);
 safe_system(command);
 return 0;
@@ -174,6 +178,8 @@ if (strcmp(argv[1], "enable")==0)
 {
 safe_system("touch /var/ipfire/samba/enable");
 safe_system("/etc/rc.d/init.d/samba start ");
+safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc2.d/S50samba");
+safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc2.d/K50samba");
 safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S50samba");
 safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/K50samba");
 return 0;
@@ -181,8 +187,12 @@ return 0;
 
 if (strcmp(argv[1], "disable")==0)
 {
+safe_system("unlink /var/ipfire/samba/enable");
 safe_system("/etc/rc.d/init.d/samba stop");
-safe_system("rm -f /etc/rc.d/rc3.d/*samba /var/ipfire/samba/enable 2>/dev/null");
+safe_system("unlink /etc/rc.d/rc2.d/S50samba");
+safe_system("unlink /etc/rc.d/rc2.d/K50samba");
+safe_system("unlink /etc/rc.d/rc3.d/S50samba");
+safe_system("unlink /etc/rc.d/rc3.d/K50samba");
 return 0;
 }
 return 0;