diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-01-27 09:37:05 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-01-27 09:37:05 -0800 |
commit | befc5e7de0d37fe462c0837a8c3ed47d66283dbe (patch) | |
tree | 136bd424ce1079b8ac7e3469346158b630020c97 /lib | |
parent | 10dadbb8516613d2ea31c9ddc73b4005b3f8f7e0 (diff) | |
download | vyatta-cfg-quagga-befc5e7de0d37fe462c0837a8c3ed47d66283dbe.tar.gz vyatta-cfg-quagga-befc5e7de0d37fe462c0837a8c3ed47d66283dbe.zip |
Don't delete non-user accounts
Only mess with user accounts in the dynamic range (1000-29999);
don't delete 'nobody' for example. Also, leave home directory
for possible examination.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Vyatta/Login/User.pm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Vyatta/Login/User.pm b/lib/Vyatta/Login/User.pm index 1aee01dd..3038c467 100755 --- a/lib/Vyatta/Login/User.pm +++ b/lib/Vyatta/Login/User.pm @@ -171,13 +171,13 @@ sub _update_user { } } +# returns list of dynamically allocated users (see Debian Policy Manual) sub _local_users { my @users; setpwent(); while ( my ($name, undef, $uid) = getpwent() ) { - # Skip system accounts (< SYS_UID_MAX) - next if $uid < 1000; + next unless ($uid >= 1000 && $uid <= 29999); push @users, $name; } endpwent(); @@ -213,7 +213,8 @@ sub update { next if defined $users{$user}; warn "User $user not listed in current configuration\n"; - system("sudo userdel --remove $user") == 0 + # Remove user account but leave home directory to be safe + system("sudo userdel $user") == 0 or die "Attempt to delete user $user failed: $!"; } } |