diff options
author | Bryan Cantrill <bryan@joyent.com> | 2016-03-18 03:31:54 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2016-03-18 03:31:54 +0000 |
commit | d38d9cda28b3a3fd1e10b66a3e6a0b77542dbde2 (patch) | |
tree | e87362e316fbfe2d47fc4fa2d7e784ed46f8a7bb | |
parent | 38e5d7678c1b8beb9ae028d906a2ccb033979b81 (diff) | |
download | illumos-joyent-d38d9cda28b3a3fd1e10b66a3e6a0b77542dbde2.tar.gz |
OS-5254 lx brand: kill(-1) spuriously returns EPERM for non-root
-rw-r--r-- | usr/src/uts/common/brand/lx/syscall/lx_kill.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/usr/src/uts/common/brand/lx/syscall/lx_kill.c b/usr/src/uts/common/brand/lx/syscall/lx_kill.c index 908d83b6be..eeed914566 100644 --- a/usr/src/uts/common/brand/lx/syscall/lx_kill.c +++ b/usr/src/uts/common/brand/lx/syscall/lx_kill.c @@ -18,15 +18,13 @@ * * CDDL HEADER END */ + /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright 2015 Joyent, Inc. + * Copyright 2016 Joyent, Inc. */ - - - #include <sys/types.h> #include <sys/systm.h> #include <sys/errno.h> @@ -196,9 +194,9 @@ lx_kill(pid_t lx_pid, int lx_sig) * signal to init(1M). */ initpid = zone->zone_proc_initpid; - if (lx_pid == 1 || lx_pid == -1) { + if (lx_pid == 1) { s_pid = initpid; - } else if (lx_pid == 0) { + } else if (lx_pid == 0 || lx_pid == -1) { s_pid = 0; } else if (lx_pid > 0) { if (lx_lpid_to_spair(lx_pid, &s_pid, NULL) != 0) { @@ -260,10 +258,15 @@ lx_kill(pid_t lx_pid, int lx_sig) p = (lx_pid == -1) ? p->p_next : p->p_pglink; } mutex_exit(&pidlock); + + /* + * If we found no processes, we'll return ESRCH -- but unlike our + * native kill(2), we do not return EPERM if processes are found but + * we did not have permission to send any of them a signal. + */ if (nfound == 0) err = ESRCH; - else if (err == 0 && v.perm == 0) - err = EPERM; + return (err ? set_errno(err) : 0); } |