summaryrefslogtreecommitdiffstats
path: root/move/move.pm
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-11-27 20:10:07 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-11-27 20:10:07 +0000
commitbab956404c309ea3ed486be3c522382798d92e70 (patch)
tree46d295871a84f9405c123aad0a06fc1a890d51b1 /move/move.pm
parentc1792b9d7d35314fe10a6b9d47f9a22de45c79af (diff)
downloaddrakx-backup-do-not-use-bab956404c309ea3ed486be3c522382798d92e70.tar
drakx-backup-do-not-use-bab956404c309ea3ed486be3c522382798d92e70.tar.gz
drakx-backup-do-not-use-bab956404c309ea3ed486be3c522382798d92e70.tar.bz2
drakx-backup-do-not-use-bab956404c309ea3ed486be3c522382798d92e70.tar.xz
drakx-backup-do-not-use-bab956404c309ea3ed486be3c522382798d92e70.zip
have only one /etc/passwd so that when user changes password on one host, change is seen on other hosts
Diffstat (limited to 'move/move.pm')
-rw-r--r--move/move.pm22
1 files changed, 18 insertions, 4 deletions
diff --git a/move/move.pm b/move/move.pm
index 5c46f9860..07b2b129f 100644
--- a/move/move.pm
+++ b/move/move.pm
@@ -251,6 +251,19 @@ sub key_installfiles {
mkdir $key_sysconf;
my $sysconf = "$key_sysconf/" . machine_ident();
+ my $copy_userinfo = sub {
+ my (@files) = @_;
+ my @etcpasswords = glob("$key_sysconf/*/etc/passwd");
+ if (@etcpasswords > 1) {
+ print "inconsistency: more than one /etc/passwd on key! can't proceed, please clean the key\n";
+ exit 1;
+ }
+ my ($path) = $etcpasswords[0] =~ m|(.*)/etc/passwd|;
+ run_program::run('cp', '-f', "$path$_", $_) foreach @files;
+ run_program::run('rm', '-f', $etcpasswords[0]);
+ return $etcpasswords[0];
+ };
+
if (!-d $sysconf) {
if ($mode eq 'full') {
log::l("key_installfiles: installing config files in $sysconf");
@@ -271,13 +284,14 @@ sub key_installfiles {
} else {
#- not in full mode and no host directory, grab user config from first existing host directory if possible
log::l("key_installfiles: only looking for user config files");
- foreach (qw(/etc/passwd /etc/group /etc/sysconfig/i18n)) {
- my $first_available = first(glob("$key_sysconf/*$_")) or next;
- system("cp $first_available $_");
- }
+ $copy_userinfo->(qw(/etc/passwd /etc/group /etc/sysconfig/i18n));
}
} else {
log::l("key_installfiles: installing symlinks to key");
+ if (!-e "$sysconf/etc/passwd") {
+ log::l("key_installfiles: /etc/passwd not here, trying to copy from previous host boot");
+ $copy_userinfo->(qw(/etc/passwd /etc/group));
+ }
foreach (chomp_(`find $sysconf -type f`)) {
my ($path) = /^\Q$sysconf\E(.*)/;
mkdir_p(dirname($path));