From 5aa41214a8fa8a2f369b79c70c825aa32166391d Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Mon, 26 Jan 2004 11:11:36 +0000 Subject: [PATCH] New -e flag, modifies the behavior of the -u uid flag to use the effective user id, instead of the real user id. MFC after: 2 weeks --- usr.bin/killall/killall.1 | 7 ++++++- usr.bin/killall/killall.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1 index 4c2ecaf07f90..bb10e9483c15 100644 --- a/usr.bin/killall/killall.1 +++ b/usr.bin/killall/killall.1 @@ -32,7 +32,7 @@ .Nd kill processes by name .Sh SYNOPSIS .Nm -.Op Fl dlmsvz +.Op Fl delmsvz .Op Fl help .Op Fl j Ar jid .Op Fl u Ar user @@ -63,6 +63,11 @@ Be more verbose about what will be done. For a single option, a list of the processes that will be sent the signal will be printed, or a message indicating that no matching processes have been found. +.It Fl e +Use the effective user id instead of the (default) real user id for matching +processes specified with the +.Fl u +option. .It Fl help Give a help on the command usage and exit. .It Fl l diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c index 6d1596903a58..be3b9697d778 100644 --- a/usr.bin/killall/killall.c +++ b/usr.bin/killall/killall.c @@ -50,7 +50,7 @@ static void __dead2 usage(void) { - fprintf(stderr, "usage: killall [-dlmsvz] [-help] [-j jid]\n"); + fprintf(stderr, "usage: killall [-delmsvz] [-help] [-j jid]\n"); fprintf(stderr, " [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd]...\n"); fprintf(stderr, "At least one option or argument to specify processes must be given.\n"); @@ -113,6 +113,7 @@ main(int ac, char **av) int vflag = 0; int sflag = 0; int dflag = 0; + int eflag = 0; int jflag = 0; int mflag = 0; int zflag = 0; @@ -192,6 +193,9 @@ main(int ac, char **av) case 'd': dflag++; break; + case 'e': + eflag++; + break; case 'm': mflag++; break; @@ -272,7 +276,7 @@ main(int ac, char **av) miblen = 3; if (user) { - mib[2] = KERN_PROC_RUID; + mib[2] = eflag ? KERN_PROC_UID : KERN_PROC_RUID; mib[3] = uid; miblen = 4; } else if (tty) { @@ -313,7 +317,10 @@ main(int ac, char **av) strncpy(thiscmd, procs[i].ki_comm, MAXCOMLEN); thiscmd[MAXCOMLEN] = '\0'; thistdev = procs[i].ki_tdev; - thisuid = procs[i].ki_ruid; /* real uid */ + if (eflag) + thisuid = procs[i].ki_uid; /* effective uid */ + else + thisuid = procs[i].ki_ruid; /* real uid */ if (thispid == mypid) continue;