View | Details | Raw Unified | Return to bug 23052 | Differences between
and this patch

Collapse All | Expand All

(-)rmuser.perl (-23 / +66 lines)
Lines 199-205 Link Here
199
# Remove the user's at jobs, if any
199
# Remove the user's at jobs, if any
200
# (probably also needs to be done before password databases are updated)
200
# (probably also needs to be done before password databases are updated)
201
201
202
&remove_at_jobs($login_name, $uid);
202
&remove_at_jobs($login_name);
203
203
204
#
204
#
205
# Kill all the user's processes
205
# Kill all the user's processes
Lines 464-495 Link Here
464
    printf STDERR " done.\n";
464
    printf STDERR " done.\n";
465
}
465
}
466
466
467
sub remove_at_jobs {
468
    local($login_name, $uid) = @_;
469
    local($i, $owner, $found);
470
471
    $found = 0;
472
    opendir(ATDIR, $atjob_dir) || return;
473
    while ($i = readdir(ATDIR)) {
474
	next if $i eq '.';
475
	next if $i eq '..';
476
	next if $i eq '.lockfile';
477
467
478
	$owner = (stat("$atjob_dir/$i"))[4]; # UID
468
sub invoke_atq {
479
	if ($uid == $owner) {
469
    local *ATQ;
480
	    if (!$found) {
470
    my($user) = (shift || "");
481
		print STDERR "Removing user's at jobs:";
471
    my($path_atq) = "/usr/bin/atq";
482
		$found = 1;
472
    my(@at) = ();
483
	    }
473
    my($pid, $line);
484
	    # Use atrm to remove the job
474
    
485
	    print STDERR " $i";
475
    return @at if ($user eq "");
486
	    system('/usr/bin/atrm', $i);
476
    
477
    if (!defined($pid = open(ATQ, "-|"))) {
478
	die("creating pipe to atq: $!\n");
479
    } elsif ($pid == 0) {
480
	exec($path_atq, $user);
481
	die("executing $path_atq: $!\n");
482
    }
483
    
484
    while(defined($_ = <ATQ>)) {
485
	chomp;
486
	if (/^\d\d:\d\d:\d\d\s+\d\d\/\d\d\/\d\d\s+(\S+)\s+\S+\s+(\d+)$/) {
487
	    push(@at, $2) if ($1 eq $user);
487
	}
488
	}
488
    }
489
    }
489
    closedir(ATDIR);
490
    close ATQ;
490
    if ($found) {
491
    return @at;
491
	print STDERR " done.\n";
492
}
493
494
sub invoke_atrm {
495
    local *ATRM;
496
    my($user) = (shift || "");
497
    my($path_atrm) = "/usr/bin/atrm";
498
    my(@jobs) = @_;
499
    my($pid);
500
    my($txt) = "";
501
    
502
    return "Invalid arguments" if (($user eq "") || ($#jobs == -1));
503
    
504
    if (!defined($pid = open(ATRM, "-|"))) {
505
	die("creating pipe to atrm: $!\n");
506
    } elsif ($pid == 0) {
507
	exec($path_atrm, $user, @jobs);
508
    }
509
    
510
    while(defined($_ = <ATRM>)) {
511
	$txt .= $_;
492
    }
512
    }
513
    close ATRM;
514
    return $txt;
515
}
516
517
sub remove_at_jobs {
518
    my($user) = (shift || "");
519
    my(@at, $atrm);
520
    
521
    return 1 if ($user eq "");
522
    
523
    print STDERR "Removing user's at jobs:";
524
    @at = invoke_atq($user);
525
    return 0 if ($#at == -1);
526
    
527
    print STDERR " @at:";
528
    $atrm = invoke_atrm($user, @at);
529
    if ($atrm ne "") {
530
	print STDERR " -- $atrm\n";
531
	return 1;
532
    }
533
    
534
    print STDERR "done.\n";
535
    return 0;
493
}
536
}
494
537
495
sub resolvelink {
538
sub resolvelink {

Return to bug 23052