diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pkill/pkill.1 | 13 | ||||
-rw-r--r-- | usr.bin/pkill/pkill.c | 28 |
2 files changed, 35 insertions, 6 deletions
diff --git a/usr.bin/pkill/pkill.1 b/usr.bin/pkill/pkill.1 index 39c507e..1989daa 100644 --- a/usr.bin/pkill/pkill.1 +++ b/usr.bin/pkill/pkill.1 @@ -36,7 +36,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd March 1, 2002 +.Dd March 25, 2004 .Dt PKILL 1 .Os .Sh NAME @@ -46,6 +46,8 @@ .Nm pgrep .Op Fl flnvx .Op Fl G Ar gid +.Op Fl M Ar core +.Op Fl N Ar system .Op Fl P Ar ppid .Op Fl U Ar uid .Op Fl d Ar delim @@ -58,6 +60,8 @@ .Op Fl signal .Op Fl fnvx .Op Fl G Ar gid +.Op Fl M Ar core +.Op Fl N Ar system .Op Fl P Ar ppid .Op Fl U Ar uid .Op Fl g Ar pgrp @@ -87,6 +91,13 @@ list Restrict matches to processes with a parent process ID in the comma-separated list .Ar ppid . +.It Fl M +Extract values associated with the name list from the specified core +instead of the default +.Pa /dev/kmem . +.It Fl N +Extract the name list from the specified system instead of the default +.Pa /kernel . .It Fl U Ar uid Restrict matches to processes with a real user ID in the comma-separated list diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index 45087ad..6a83cce 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -125,7 +125,7 @@ main(int argc, char **argv) extern int optind; char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; char *execf, *coref, *swapf; - int i, j, ch, bestidx, rv, criteria; + int i, j, ch, bestidx, rv, criteria, drop_privs; void (*action)(struct kinfo_proc *); struct kinfo_proc *kp; struct list *li; @@ -169,13 +169,22 @@ main(int argc, char **argv) #endif criteria = 0; + drop_privs = 0; - while ((ch = getopt(argc, argv, "G:P:U:d:fg:lns:t:u:vx")) != -1) + while ((ch = getopt(argc, argv, "G:M:N:P:U:d:fg:lns:t:u:vx")) != -1) switch (ch) { case 'G': makelist(&rgidlist, LT_GROUP, optarg); criteria = 1; break; + case 'M': + coref = optarg; + drop_privs = 1; + break; + case 'N': + execf = optarg; + drop_privs = 1; + break; case 'P': makelist(&ppidlist, LT_GENERIC, optarg); criteria = 1; @@ -235,6 +244,15 @@ main(int argc, char **argv) if (!criteria) usage(); + /* + * Discard privileges if not the running kernel so that bad + * guys can't print interesting stuff from kernel memory. + */ + if (drop_privs) { + setgid(getgid()); + setuid(getuid()); + } + mypid = getpid(); /* @@ -426,9 +444,9 @@ usage(void) ustr = "[-signal] [-fnvx]"; fprintf(stderr, - "usage: %s %s [-G gid] [-P ppid] [-U uid] [-g pgrp] [-s sid]\n" - " [-t tty] [-u euid] pattern ...\n", getprogname(), - ustr); + "usage: %s %s [-G gid] [-M core] [-N system]\n" + " [-P ppid] [-U uid] [-g pgrp] [-s sid] [-t tty]\n" + " [-u euid] pattern ...\n", getprogname(), ustr); exit(STATUS_ERROR); } |