Bug 23052

Summary: [PATCH] rmuser fails to remove at jobs
Product: Base System Reporter: Peter Pentchev <roam>
Component: binAssignee: Guy Helmer <ghelmer>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
file.diff none

Description Peter Pentchev 2000-11-23 22:00:01 UTC
The /usr/sbin/rmuser Perl script includes a function for removing
the late user's at-scheduled jobs.  However, that code has been subtly
wrong from the start, and for quite some time now has simply not worked.

It scans the /var/at/jobs directory for files belonging to the user
being removed, and then passes each filename as an argument to atrm.
However, atrm no longer accepts such filenames as arguments - it wants
a job ID.  Failing to find the "ID" specified, atrm quietly does nothing,
leaving the scheduled job to be executed, and not alerting the adminstrator
or whoever it is invoking rmuser.

Submitted by:	Mike Sellenschuetter <mike.sellenschuetter@bankofamerica.com>
		in a mail to -security;
		Message-Id: <8625699E.0061FCDC.00@dalnsd40.bankofamerica.com>

Fix: Although it is trivial to extract the job ID from the filename - in the
example given, the job ID was 24, and the filename contained a 00018
hex string - I do not really think this is the way to go.  There's no
telling when the at job filename format shall be changed again, and it is
very easy to miss updating rmuser if/when that should happen.

Attached instead are two patches - one against RELENG_4, another against
-current - which add two additional subroutines to invoke atq, parse its
output, find the jobs belonging to this user, then invoke atrm and kill
off the correct job ID's.

The patch against RELENG_4 also applies cleanly to RELENG_3.  I think
this one might well be worth MFC'ing into 3.x.

Here's the diff against -current..

==================================================================

And here's the diff against RELENG_4..
How-To-Repeat: 
[root@ringworld:v4 ~]# pw adduser test
[root@ringworld:v4 ~]# echo 'at -f /dev/null now + 1 hour' | su test
Job 24 will be executed using /bin/sh
[root@ringworld:v4 ~]# atq
Date                    Owner   Queue   Job#
00:45:00 11/24/00       test    c       24
[root@ringworld:v4 ~]# rmuser test
Matching password entry:

test:*:1007:1007::0:0:User &:/home/test:/bin/sh

Is this the entry you wish to remove? y
/usr/sbin/rmuser: Informational: Home /home/test is not a directory, so it won't
 be removed
Removing user's at jobs: c0001800f7f5d5 done.
Updating password file, updating databases, done.
Updating group file: (removing group test -- personal group is empty) done.
Removing user's incoming mail file /var/mail/test: done.
Removing files belonging to test from /tmp: done.
Removing files belonging to test from /var/tmp: done.
Removing files belonging to test from /var/tmp/vi.recover: done.
[root@ringworld:v4 ~]# atq
Date                    Owner   Queue   Job#
00:45:00 11/24/00       ???     c       24
[root@ringworld:v4 ~]#
Comment 1 Guy Helmer freebsd_committer freebsd_triage 2000-12-28 15:07:22 UTC
Responsible Changed
From-To: freebsd-bugs->ghelmer

I'll take this one. 
.
Comment 2 Guy Helmer freebsd_committer freebsd_triage 2001-07-23 19:29:32 UTC
State Changed
From-To: open->closed

Patch committed to -current and scheduled for MFC in 1 week. 
Thanks!