Fixed huge bug in create homedirs

Did't check if File/Path allready exists
This commit is contained in:
katagia 2003-07-10 16:39:06 +00:00
parent 2e4baad5c7
commit 01a0b4bea0
2 changed files with 33 additions and 18 deletions

View File

@ -355,25 +355,36 @@ function checksamba($values, $type) { // This function checks all samba account
if ((!$values->smb_smbuserworkstations=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $values->smb_smbuserworkstations))
$errors[] = array('ERROR', _('User Workstations'), _('User Workstations is invalid.'));
$return->smb_flagsW = 0;
if ((!$values->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $values->smb_domain))
$errors[] = array('ERROR', _('Domain Name'), _('Domain Name contents invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if ($values->smb_useunixpwd) $return->smb_useunixpwd = 1; else $return->smb_useunixpwd = 0;
if ($values->smb_pwdcanchange) $return->smb_pwdcanchange = 1; else $return->smb_pwdcanchange = 0;
if ($values->smb_pwdmustchange) $return->smb_pwdmustchange = 1; else $return->smb_pwdmustchange = 0;
if ($values->smb_password) {
// Encrypt password
$return->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $values->smb_password,
MCRYPT_MODE_ECB, $iv));
}
else $return->smb_password = "";
break;
case 'host' :
$return->smb_password = $values->unix_password;
$return->smb_flagsW = 1;
if ((!$values->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $values->smb_domain))
$errors[] = array('ERROR', _('Domain Name'), _('Domain Name contents invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if ($values->smb_useunixpwd) $return->smb_useunixpwd = 1; else $return->smb_useunixpwd = 0;
if ($values->smb_pwdcanchange) $return->smb_pwdcanchange = 1; else $return->smb_pwdcanchange = 0;
if ($values->smb_pwdmustchange) $return->smb_pwdmustchange = 1; else $return->smb_pwdmustchange = 0;
if ($values->smb_password) {
// Encrypt password
$return->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $values->smb_password,
MCRYPT_MODE_ECB, $iv));
}
else $return->smb_password = "";
break;
case 'group' :
break;
}
if ((!$values->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $values->smb_domain))
$errors[] = array('ERROR', _('Domain Name'), _('Domain Name contents invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if ($values->smb_useunixpwd) $return->smb_useunixpwd = 1; else $return->smb_useunixpwd = 0;
if ($values->smb_pwdcanchange) $return->smb_pwdcanchange = 1; else $return->smb_pwdcanchange = 0;
if ($values->smb_pwdmustchange) $return->smb_pwdmustchange = 1; else $return->smb_pwdmustchange = 0;
if ($values->smb_password) {
// Encrypt password
$return->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $values->smb_password,
MCRYPT_MODE_ECB, $iv));
}
else $return->smb_password = "";
// Return values and errors
if (!$errors) return array($return);
else return array($return, $errors);

View File

@ -107,18 +107,22 @@ if ($found==true) {
my $path = $user[7];
$path =~ s,/(?:[^/]*)$,,;
($<, $>) = ($>, $<); # Get root privileges
system 'mkdir', '-m 755', '-p', $path; # Create paths to homedir
system 'mkdir', '-m 700', $user[7]; # Create himdir itself
system "cp -a /etc/skel/* /etc/skel/.[^.]* $user[7]"; # Copy /etc/sekl into homedir
system 'chown', '-R', "$user[2]:$user[3]" , $user[7]; # Change owner to new user
system '/usr/sbin/useradd.local', $user[0]; # run useradd-script
if (! -e $path) {
system 'mkdir', '-m 755', '-p', $path; # Create paths to homedir
system 'mkdir', '-m 700', $user[7]; # Create himdir itself
system "cp -a /etc/skel/* /etc/skel/.[^.]* $user[7]"; # Copy /etc/sekl into homedir
system 'chown', '-R', "$user[2]:$user[3]" , $user[7]; # Change owner to new user
system '/usr/sbin/useradd.local', $user[0]; # run useradd-script
}
($<, $>) = ($>, $<); # Give up root previleges
last switch2;
};
$vals[4] eq 'rem' && do {
($<, $>) = ($>, $<); # Get root previliges
system 'rm', '-R', $user[7]; # Delete Homedirectory
system '/usr/sbin/userdel.local', $user[0];
if (-d $user[7]) {
system 'rm', '-R', $user[7]; # Delete Homedirectory
system '/usr/sbin/userdel.local', $user[0];
}
($<, $>) = ($>, $<); # Give up root previleges
last switch2;
};