mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 15:45:21 +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
|
.Nd kill processes by name
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl dlmsvz
|
.Op Fl delmsvz
|
||||||
.Op Fl help
|
.Op Fl help
|
||||||
.Op Fl j Ar jid
|
.Op Fl j Ar jid
|
||||||
.Op Fl u Ar user
|
.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
|
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
|
printed, or a message indicating that no matching processes have been
|
||||||
found.
|
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
|
.It Fl help
|
||||||
Give a help on the command usage and exit.
|
Give a help on the command usage and exit.
|
||||||
.It Fl l
|
.It Fl l
|
||||||
|
@ -50,7 +50,7 @@ static void __dead2
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "usage: killall [-dlmsvz] [-help] [-j jid]\n");
|
fprintf(stderr, "usage: killall [-delmsvz] [-help] [-j jid]\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd]...\n");
|
" [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd]...\n");
|
||||||
fprintf(stderr, "At least one option or argument to specify processes must be given.\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 vflag = 0;
|
||||||
int sflag = 0;
|
int sflag = 0;
|
||||||
int dflag = 0;
|
int dflag = 0;
|
||||||
|
int eflag = 0;
|
||||||
int jflag = 0;
|
int jflag = 0;
|
||||||
int mflag = 0;
|
int mflag = 0;
|
||||||
int zflag = 0;
|
int zflag = 0;
|
||||||
@ -192,6 +193,9 @@ main(int ac, char **av)
|
|||||||
case 'd':
|
case 'd':
|
||||||
dflag++;
|
dflag++;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
eflag++;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
mflag++;
|
mflag++;
|
||||||
break;
|
break;
|
||||||
@ -272,7 +276,7 @@ main(int ac, char **av)
|
|||||||
miblen = 3;
|
miblen = 3;
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
mib[2] = KERN_PROC_RUID;
|
mib[2] = eflag ? KERN_PROC_UID : KERN_PROC_RUID;
|
||||||
mib[3] = uid;
|
mib[3] = uid;
|
||||||
miblen = 4;
|
miblen = 4;
|
||||||
} else if (tty) {
|
} else if (tty) {
|
||||||
@ -313,7 +317,10 @@ main(int ac, char **av)
|
|||||||
strncpy(thiscmd, procs[i].ki_comm, MAXCOMLEN);
|
strncpy(thiscmd, procs[i].ki_comm, MAXCOMLEN);
|
||||||
thiscmd[MAXCOMLEN] = '\0';
|
thiscmd[MAXCOMLEN] = '\0';
|
||||||
thistdev = procs[i].ki_tdev;
|
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)
|
if (thispid == mypid)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user