diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-10-11 17:35:35 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-10-11 17:35:35 +0000 |
commit | e4f62031c585cbc4a45230714e13821b9bfca34c (patch) | |
tree | 29ff4480df90ce8b6c0ddf9231a1e567f34ffe2b /perl-install/install_steps.pm | |
parent | 9ad846cd08f909f760f80bf703b8d4dbe1809c7b (diff) | |
download | drakx-e4f62031c585cbc4a45230714e13821b9bfca34c.tar drakx-e4f62031c585cbc4a45230714e13821b9bfca34c.tar.gz drakx-e4f62031c585cbc4a45230714e13821b9bfca34c.tar.bz2 drakx-e4f62031c585cbc4a45230714e13821b9bfca34c.tar.xz drakx-e4f62031c585cbc4a45230714e13821b9bfca34c.zip |
no_comment
Diffstat (limited to 'perl-install/install_steps.pm')
-rw-r--r-- | perl-install/install_steps.pm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index ee62d62bf..3191e167a 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -278,12 +278,15 @@ sub addUser($) { my $p = $o->{prefix}; my @passwd = cat_("$p/etc/passwd");; - !$u{name} || getpwnam($u{name}) and return; - - for ($u{uid} = 500; getpwuid($u{uid}); $u{uid}++) {} - for ($u{gid} = 500; getgrgid($u{gid}); $u{gid}++) {} + return if !$u{name} || getpwnam($u{name}); $u{home} ||= "/home/$u{name}"; + my (%uids, %gids); + foreach (glob_("/home")) { my ($u, $g) = (stat($_))[4,5]; $uids{$u} = 1; $gids{$g} = 1; } + my ($old_uid, $old_gid) = ($u{uid}, $u{gid}) = (stat($u{home}))[4,5]; + if (getpwuid($u{uid})) { for ($u{uid} = 500; getpwuid($u{uid}) || $uids{$u{uid}}; $u{uid}++) {} } + if (getgrgid($u{gid})) { for ($u{gid} = 500; getgrgid($u{gid}) || $gids{$u{gid}}; $u{gid}++) {} } + $u{password} = crypt_($u{password}) if $u{password}; return if $::testing; @@ -295,8 +298,11 @@ sub addUser($) { open F, ">> $p/etc/group" or die "can't append to group file: $!"; print F "$u{name}::$u{gid}:\n"; - eval { commands::cp("-f", "$p/etc/skel", "$p$u{home}") }; $@ and log::l("copying of skel failed: $@"), mkdir("$p$u{home}", 0750); - commands::chown_("-r", "$u{uid}.$u{gid}", "$p$u{home}"); + unless (-d "$p$u{home}") { + eval { commands::cp("-f", "$p/etc/skel", "$p$u{home}") }; + if ($@) { log::l("copying of skel failed: $@"); mkdir("$p$u{home}", 0750); } + } + commands::chown_("-r", "$u{uid}.$u{gid}", "$p$u{home}") if $u{uid} != $old_uid || $u{gid} != $old_gid; } #------------------------------------------------------------------------------ |