diff options
author | Olivier Blin <oblin@mandriva.org> | 2006-02-23 09:36:24 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2006-02-23 09:36:24 +0000 |
commit | 92b63febdc5244af0cfc2c199b1446c8a6a1b4e9 (patch) | |
tree | b83eab92af7f762445570344ef8be7e128b0619e /perl-install/any.pm | |
parent | 8e854d5c2ed9dc6297598f064450beb8cd99da5f (diff) | |
download | drakx-92b63febdc5244af0cfc2c199b1446c8a6a1b4e9.tar drakx-92b63febdc5244af0cfc2c199b1446c8a6a1b4e9.tar.gz drakx-92b63febdc5244af0cfc2c199b1446c8a6a1b4e9.tar.bz2 drakx-92b63febdc5244af0cfc2c199b1446c8a6a1b4e9.tar.xz drakx-92b63febdc5244af0cfc2c199b1446c8a6a1b4e9.zip |
allow to rename an old user (possibly "guest" from a live distribution) instead of creating a new one, using info from first added user in finish-install
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r-- | perl-install/any.pm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm index 7238c34f8..012ceda29 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -64,21 +64,26 @@ sub create_user { } else { run_program::rooted($::prefix, 'groupadd', '-g', $gid, $u->{name}); } + } elsif ($u->{rename_from}) { + run_program::rooted($::prefix, 'groupadd', $u->{name}) and $gid = int getgrnam($u->{name}); } + require authentication; run_program::raw({ root => $::prefix, sensitive_arguments => 1 }, - 'adduser', + ($u->{rename_from} ? 'usermod' : 'adduser'), '-p', authentication::user_crypted_passwd($u, $isMD5), if_($uid, '-u', $uid), if_($gid, '-g', $gid), if_($u->{realname}, '-c', $u->{realname}), - if_($u->{home}, '-d', $u->{home}), + if_($u->{home}, '-d', $u->{home}, if_($u->{rename_from} ,'-m')), if_($u->{shell}, '-s', $u->{shell}), - $u->{name}); + ($u->{rename_from} + ? ('-l', $u->{name}, , $u->{rename_from}) + : $u->{name})); } my (undef, undef, $uid, $gid, undef, undef, undef, $home) = getpwnam($u->{name}); - if (@existing && $::isInstall && ($uid != $existing[4] || $gid != $existing[5])) { + if (@existing && $::isInstall && ($uid != $existing[4] || $gid != $existing[5]) || $u->{rename_from}) { log::l("chown'ing $home from $existing[4].$existing[5] to $uid.$gid"); require commands; eval { commands::chown_("-r", "$uid.$gid", "$::prefix$home") }; |