From c56b64b92e2f866dfde41aff470e3cd70ce14d8b Mon Sep 17 00:00:00 2001 From: damien Date: Thu, 21 Dec 2000 12:35:29 +0000 Subject: added setAdminpassword (a little bit redundant, sorry) --- perl-install/install_steps.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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}; -- cgit v1.2.1