|
Lines 202-208
Link Here
|
| 202 |
# Remove the user's at jobs, if any |
202 |
# Remove the user's at jobs, if any |
| 203 |
# (probably also needs to be done before password databases are updated) |
203 |
# (probably also needs to be done before password databases are updated) |
| 204 |
|
204 |
|
| 205 |
&remove_at_jobs($login_name, $uid); |
205 |
&remove_at_jobs($login_name); |
| 206 |
|
206 |
|
| 207 |
# |
207 |
# |
| 208 |
# Kill all the user's processes |
208 |
# Kill all the user's processes |
|
Lines 495-526
Link Here
|
| 495 |
printf STDERR " done.\n"; |
495 |
printf STDERR " done.\n"; |
| 496 |
} |
496 |
} |
| 497 |
|
497 |
|
| 498 |
sub remove_at_jobs { |
|
|
| 499 |
local($login_name, $uid) = @_; |
| 500 |
local($i, $owner, $found); |
| 501 |
|
| 502 |
$found = 0; |
| 503 |
opendir(ATDIR, $atjob_dir) || return; |
| 504 |
while ($i = readdir(ATDIR)) { |
| 505 |
next if $i eq '.'; |
| 506 |
next if $i eq '..'; |
| 507 |
next if $i eq '.lockfile'; |
| 508 |
|
498 |
|
| 509 |
$owner = (stat("$atjob_dir/$i"))[4]; # UID |
499 |
sub invoke_atq { |
| 510 |
if ($uid == $owner) { |
500 |
local *ATQ; |
| 511 |
if (!$found) { |
501 |
my($user) = (shift || ""); |
| 512 |
print STDERR "Removing user's at jobs:"; |
502 |
my($path_atq) = "/usr/bin/atq"; |
| 513 |
$found = 1; |
503 |
my(@at) = (); |
| 514 |
} |
504 |
my($pid, $line); |
| 515 |
# Use atrm to remove the job |
505 |
|
| 516 |
print STDERR " $i"; |
506 |
return @at if ($user eq ""); |
| 517 |
system('/usr/bin/atrm', $i); |
507 |
|
|
|
508 |
if (!defined($pid = open(ATQ, "-|"))) { |
| 509 |
die("creating pipe to atq: $!\n"); |
| 510 |
} elsif ($pid == 0) { |
| 511 |
exec($path_atq, $user); |
| 512 |
die("executing $path_atq: $!\n"); |
| 513 |
} |
| 514 |
|
| 515 |
while(defined($_ = <ATQ>)) { |
| 516 |
chomp; |
| 517 |
if (/^\d\d:\d\d:\d\d\s+\d\d\/\d\d\/\d\d\s+(\S+)\s+\S+\s+(\d+)$/) { |
| 518 |
push(@at, $2) if ($1 eq $user); |
| 518 |
} |
519 |
} |
| 519 |
} |
520 |
} |
| 520 |
closedir(ATDIR); |
521 |
close ATQ; |
| 521 |
if ($found) { |
522 |
return @at; |
| 522 |
print STDERR " done.\n"; |
523 |
} |
|
|
524 |
|
| 525 |
sub invoke_atrm { |
| 526 |
local *ATRM; |
| 527 |
my($user) = (shift || ""); |
| 528 |
my($path_atrm) = "/usr/bin/atrm"; |
| 529 |
my(@jobs) = @_; |
| 530 |
my($pid); |
| 531 |
my($txt) = ""; |
| 532 |
|
| 533 |
return "Invalid arguments" if (($user eq "") || ($#jobs == -1)); |
| 534 |
|
| 535 |
if (!defined($pid = open(ATRM, "-|"))) { |
| 536 |
die("creating pipe to atrm: $!\n"); |
| 537 |
} elsif ($pid == 0) { |
| 538 |
exec($path_atrm, $user, @jobs); |
| 539 |
} |
| 540 |
|
| 541 |
while(defined($_ = <ATRM>)) { |
| 542 |
$txt .= $_; |
| 523 |
} |
543 |
} |
|
|
544 |
close ATRM; |
| 545 |
return $txt; |
| 546 |
} |
| 547 |
|
| 548 |
sub remove_at_jobs { |
| 549 |
my($user) = (shift || ""); |
| 550 |
my(@at, $atrm); |
| 551 |
|
| 552 |
return 1 if ($user eq ""); |
| 553 |
|
| 554 |
print STDERR "Removing user's at jobs:"; |
| 555 |
@at = invoke_atq($user); |
| 556 |
return 0 if ($#at == -1); |
| 557 |
|
| 558 |
print STDERR " @at:"; |
| 559 |
$atrm = invoke_atrm($user, @at); |
| 560 |
if ($atrm ne "") { |
| 561 |
print STDERR " -- $atrm\n"; |
| 562 |
return 1; |
| 563 |
} |
| 564 |
|
| 565 |
print STDERR "done.\n"; |
| 566 |
return 0; |
| 524 |
} |
567 |
} |
| 525 |
|
568 |
|
| 526 |
sub resolvelink { |
569 |
sub resolvelink { |