diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-12-08 14:49:39 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-12-08 14:49:39 -0800 |
commit | f956bfc6ee753fbbf251a7c43e7ad2573aa89c83 (patch) | |
tree | f03b8cadf4df7ed6511947cdb28be689eab53bb7 /lib/Vyatta/Login | |
parent | e22eb2d21c15a0053178b88c8b9444d0d05e9af1 (diff) | |
download | vyatta-cfg-system-f956bfc6ee753fbbf251a7c43e7ad2573aa89c83.tar.gz vyatta-cfg-system-f956bfc6ee753fbbf251a7c43e7ad2573aa89c83.zip |
Allow root account to not exist
If root account is deleted, disable it rather than removing it from
passwd file and confusing everything.
Diffstat (limited to 'lib/Vyatta/Login')
-rwxr-xr-x | lib/Vyatta/Login/User.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Vyatta/Login/User.pm b/lib/Vyatta/Login/User.pm index 3b1170ff..b03b90b7 100755 --- a/lib/Vyatta/Login/User.pm +++ b/lib/Vyatta/Login/User.pm @@ -159,14 +159,18 @@ sub update { my %users = $uconfig->listNodeStatus(); die "All users deleted!\n" unless %users; - die "User root cannot be deleted\n" - if (! defined $users{'root'} || $users{'root'} eq 'deleted'); foreach my $user ( keys %users ) { my $state = $users{$user}; if ( $state eq 'deleted' ) { - system("sudo userdel -r '$user'") == 0 - or die "userdel failed: $?\n"; + if ($user eq 'root') { + warn "Disabling root account, instead of deleting\n"; + system ('sudo usermod -p ! root') == 0 + or die "usermod of root failed: $?\n"; + } else { + system("sudo userdel -r '$user'") == 0 + or die "userdel of $user failed: $?\n"; + } next; } |