mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 13:32:45 +00:00
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
This commit is contained in:
parent
8615b04cff
commit
5aa41214a8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125013
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user