summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorOliver Tappe2008-03-06 20:56:38 +0100
committerOliver Tappe2008-03-06 20:56:38 +0100
commit5eb8bbe3a84c6ad741bc123ccaec5bddfa5d9961 (patch)
treee07b2f77461d0cba878c90e92783b9c82de8cebd /installer
parent* added check for rsync, as we rely on it being installed (diff)
downloadcore-5eb8bbe3a84c6ad741bc123ccaec5bddfa5d9961.tar.gz
core-5eb8bbe3a84c6ad741bc123ccaec5bddfa5d9961.tar.xz
core-5eb8bbe3a84c6ad741bc123ccaec5bddfa5d9961.zip
* improved setting a password such that is able to cope with a
non-existing /etc/shadow git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1609 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer')
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Base.pm22
1 files changed, 12 insertions, 10 deletions
diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm
index b05e5cfe..a3753b1f 100644
--- a/installer/OpenSLX/OSSetup/Distro/Base.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Base.pm
@@ -233,29 +233,31 @@ sub setPasswordForUser
my $writePasswordFunction = sub {
# now read, change and write shadow-file in atomic manner:
my $shadowFile = '/etc/shadow';
+ if (!-e $shadowFile) {
+ spitFile( $shadowFile, '');
+ }
slxsystem("cp -r $shadowFile $shadowFile~");
my $shadowFH;
open($shadowFH, '+<', $shadowFile)
or croak _tr("could not open file '%s'! (%s)", $shadowFile, $!);
flock($shadowFH, LOCK_EX)
or croak _tr("could not lock file '%s'! (%s)", $shadowFile, $!);
+ my $lastChanged = int(time()/24/60/60);
+ my $newEntry
+ = "$username:$hashedPassword:$lastChanged:0:99999:7:::";
my $content = do { local $/; <$shadowFH> };
if ($content =~ m{^$username:}ims) {
- my $lastChanged = int(time()/24/60/60);
- my $newEntry
- = "$username:$hashedPassword:$lastChanged:0:99999:7:::";
$content =~ s{^$username:.+?$}{$newEntry}ms;
- seek($shadowFH, 0, 0);
- print $shadowFH $content;
} else {
- warn _tr(
- "user '%s' doesn't exist - unable to set password! (%s)",
- $username
- );
+ $content .= "$newEntry\n";
}
+ seek($shadowFH, 0, 0)
+ or croak _tr("could not seek file '%s'! (%s)", $shadowFile, $!);
+ print $shadowFH $content
+ or croak _tr("could not write to file '%s'! (%s)", $shadowFile, $!);
close($shadowFH)
or croak _tr("could not close file '%s'! (%s)", $shadowFile, $!);
-# unlink "$shadowFile~";
+ unlink "$shadowFile~";
};
$self->{engine}->callChrootedFunctionForVendorOS($writePasswordFunction);
}