diff options
author | Olivier Blin <oblin@mandriva.org> | 2006-02-23 09:36:51 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2006-02-23 09:36:51 +0000 |
commit | 4808dba37976e9f3e420ada5c6d0475ecda3851b (patch) | |
tree | d3be3650a3623bc6de3830e3248ac512b106d224 | |
parent | f6297c8c070d3777fa7a350fd3f2b73717fb5836 (diff) | |
download | drakx-4808dba37976e9f3e420ada5c6d0475ecda3851b.tar drakx-4808dba37976e9f3e420ada5c6d0475ecda3851b.tar.gz drakx-4808dba37976e9f3e420ada5c6d0475ecda3851b.tar.bz2 drakx-4808dba37976e9f3e420ada5c6d0475ecda3851b.tar.xz drakx-4808dba37976e9f3e420ada5c6d0475ecda3851b.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 (backport from HEAD)
-rw-r--r-- | perl-install/any.pm | 13 | ||||
-rwxr-xr-x | perl-install/standalone/finish-install | 7 |
2 files changed, 16 insertions, 4 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm index e4784a0f2..df96e0810 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") }; diff --git a/perl-install/standalone/finish-install b/perl-install/standalone/finish-install index 02f0b5310..c44b73cc7 100755 --- a/perl-install/standalone/finish-install +++ b/perl-install/standalone/finish-install @@ -75,6 +75,13 @@ sub ask_authentication() { sub ask_users() { my $users = []; any::ask_users($in, $users, $security, []); + my $old_user = $conf{USER_RENAME_FROM}; + if (@$users && $old_user) { + $users->[0]{rename_from} = $old_user; + $users->[0]{home} ||= '/home/' . $users->[0]{name}; + my $autologin = any::get_autologin(); + $autologin->{autologin} eq $old_user and any::set_autologin($users->[0]{name}, $autologin->{desktop}); + } any::add_users($users, $authentication); } |