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;