diff options
-rw-r--r-- | perl-install/install_steps.pm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index b07443235..9beec337b 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -606,6 +606,29 @@ sub setRootPassword($) { #------------------------------------------------------------------------------ +my @etc_pass_fields = qw(name pw uid gid realname home shell); +sub setAdminPassword($) { + my ($o) = @_; + my $p = $o->{prefix}; + my $u = $o->{adminuser} ||= {}; + + $u->{pw} ||= $u->{password} && any::crypt($u->{password}, $o->{authentication}{md5}); + + my @lines = cat_(my $f = "$p/etc/passwd") or log::l("missing passwd file"), return; + + local *F; + open F, "> $f" or die "failed to write file $f: $!\n"; + foreach (@lines) { + if (/^admin:/) { + chomp; + my %l; @l{@etc_pass_fields} = split ':'; + add2hash($u, \%l); + $_ = join(':', @$u{@etc_pass_fields}) . "\n"; + } + print F $_; + } +} + sub addUser($) { my ($o) = @_; my $p = $o->{prefix}; |