From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21248 invoked from network); 29 Jun 2021 14:48:50 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 29 Jun 2021 14:48:50 -0000 Received: (qmail 1763 invoked by uid 550); 29 Jun 2021 14:48:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1743 invoked from network); 29 Jun 2021 14:48:47 -0000 Date: Tue, 29 Jun 2021 10:48:35 -0400 From: Rich Felker To: Alexey Kodanev Cc: musl@lists.openwall.com Message-ID: <20210629144834.GP13220@brightrain.aerifal.cx> References: <20210629133130.143543-1-aleksei.kodanev@bell-sw.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210629133130.143543-1-aleksei.kodanev@bell-sw.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] nice: return EPERM instead of EACCES On Tue, Jun 29, 2021 at 04:31:30PM +0300, Alexey Kodanev wrote: > To comply with POSIX, change errno from EACCES to EPERM > when the caller did not have the required privilege. > --- > src/unistd/nice.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/src/unistd/nice.c b/src/unistd/nice.c > index 6c25c8c3..1c2295ff 100644 > --- a/src/unistd/nice.c > +++ b/src/unistd/nice.c > @@ -1,4 +1,5 @@ > #include > +#include > #include > #include > #include "syscall.h" > @@ -12,5 +13,11 @@ int nice(int inc) > prio += getpriority(PRIO_PROCESS, 0); > if (prio > NZERO-1) prio = NZERO-1; > if (prio < -NZERO) prio = -NZERO; > - return setpriority(PRIO_PROCESS, 0, prio) ? -1 : prio; > + if (setpriority(PRIO_PROCESS, 0, prio)) { > + if (errno == EACCES) > + errno = EPERM; > + return -1; > + } else { > + return prio; > + } > } > -- > 2.25.1 Is there actually an issue here? setpriority is specified to fail with EACCES already for this case; EPERM is only specified for targeting other processes you don't have permission to target. Is Linux getting this wrong for setpriority? Rich