85
87
"remove-home" => \$pconfig{"remove_home"},
86
88
"remove-all-files" => \$pconfig{"remove_all_files"},
87
89
"backup" => \$pconfig{"backup"},
88
"backup-to=s" => \$pconfig{"backup_to"}
90
"backup-to=s" => \$pconfig{"backup_to"},
223
226
unless(exist_user($user)) {
224
227
fail (2,gtx("The user `%s' does not exist.\n"),$user);
230
# Warn in any case if you want to remove the root account
231
if ((defined($pw_uid)) && ($pw_uid == 0) && (!defined($force))) {
232
printf (gtx("WARNING: You are just about to delete the root account (uid 0)\n"));
233
printf (gtx("Usually this is never required as it may render the whole system unusable\n"));
234
printf (gtx("If you really want this, call deluser with parameter --force\n"));
235
printf (gtx("Stopping now without having performed any action\n"));
228
240
if($config{"remove_home"} || $config{"remove_all_files"}) {
294
306
if($config{"backup"}) {
295
s_printf (gtx("Backing up files to be removed to %s ...\n"),$config{"backup_to"});
296
my $filesfile = new File::Temp(TEMPLATE=>"deluser.XXXXX", DIR=>"/tmp");
297
my $filesfilename = $filesfile->filename;
298
my $backup_name = $config{"backup_to"} . "/$user.tar";
299
print "backup_name = $backup_name";
300
print $filesfile join("\n",@files);
307
s_printf (gtx("Backing up files to be removed to %s ...\n"),$config{"backup_to"});
308
my $filesfile = new File::Temp(TEMPLATE=>"deluser.XXXXX", DIR=>"/tmp");
309
my $filesfilename = $filesfile->filename;
310
my $backup_name = $config{"backup_to"} . "/$user.tar";
311
print "backup_name = $backup_name";
312
print $filesfile join("\n",@files);
302
314
my $tar = &which('tar');
303
&systemcall($tar, "-cf", $backup_name, "--files-from", $filesfilename);
304
chmod 0600, $backup_name;
306
chown $rootid, $rootid, $backup_name;
307
unlink($filesfilename);
308
315
my $bzip2 = &which('bzip2', 1);
309
316
my $gzip = &which('gzip', 1);
311
systemcall($bzip2, $backup_name);
313
systemcall($gzip, "--best", $backup_name);
319
$backup_name = "$backup_name.bz2";
320
$options = "--bzip2";
322
$backup_name = "$backup_name.gz";
325
&systemcall($tar, "-cf", $options, $backup_name, "--files-from", $filesfilename);
326
chmod 0600, $backup_name;
328
chown $rootid, $rootid, $backup_name;
329
unlink($filesfilename);
317
332
if(@files || @dirs) {
333
348
s_printf (gtx("Removing user `%s' ...\n"),$user);
334
349
my @members = get_group_members($maingroup);
335
350
if (@members == 0) {
336
s_printf (gtx("Warning: Removing group `%s', since no other user is part of it.\n"), $maingroup);
351
s_printf (gtx("Warning: group `%s' has no more members.\n"), $maingroup);
338
353
my $userdel = &which('userdel');
339
354
&systemcall($userdel, $user);