NetBSD Problem Report #42587
From www@NetBSD.org Wed Jan 6 15:40:44 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id B3DA163C442
for <gnats-bugs@gnats.NetBSD.org>; Wed, 6 Jan 2010 15:40:44 +0000 (UTC)
Message-Id: <20100106154044.86B2863C430@www.NetBSD.org>
Date: Wed, 6 Jan 2010 15:40:44 +0000 (UTC)
From: ekamperi@gmail.com
Reply-To: ekamperi@gmail.com
To: gnats-bugs@NetBSD.org
Subject: nice() returns EACCES instead of (standard mandated) EPERM
X-Send-Pr-Version: www-1.0
>Number: 42587
>Category: lib
>Synopsis: nice() returns EACCES instead of (standard mandated) EPERM
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 06 15:45:00 +0000 2010
>Closed-Date: Sun May 01 04:28:00 +0000 2011
>Last-Modified: Sun May 01 06:45:01 +0000 2011
>Originator: Stathis Kamperis
>Release: 5.0.1
>Organization:
>Environment:
NetBSD 5.0.1 GENERIC/i386 (sorry, handwritter :-))
>Description:
Quoting from (same applies to Issue 7):
http://www.opengroup.org/onlinepubs/000095399/functions/nice.html
The nice() function shall fail if:
[EPERM]
The incr argument is negative and the calling process does not have
appropriate privileges.
Linux + OpenSolaris do it right. *BSD I tried return wrong error code.
>How-To-Repeat:
Call nice(-2) from a non-privileged program and check errno variable. It is EACCES, instead of EPERM.
Trivial test case here may be found here:
http://gitweb.dragonflybsd.org/~beket/pcca-tests.git/blob_plain/master:/unistd.h/t_nice.c
>Fix:
http://nxr.netbsd.org/source/xref/src/sys/kern/kern_resource.c#310
Replace EACCES with EPERM here.
>Release-Note:
>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandated) EPERM
Date: Wed, 6 Jan 2010 13:23:48 -0500
On Jan 6, 3:45pm, ekamperi@gmail.com (ekamperi@gmail.com) wrote:
-- Subject: lib/42587: nice() returns EACCES instead of (standard mandated) E
| >Number: 42587
| >Category: lib
| >Synopsis: nice() returns EACCES instead of (standard mandated) EPERM
| >Confidential: no
| >Severity: non-critical
| >Priority: low
| >Responsible: lib-bug-people
| >State: open
| >Class: sw-bug
| >Submitter-Id: net
| >Arrival-Date: Wed Jan 06 15:45:00 +0000 2010
| >Originator: Stathis Kamperis
| >Release: 5.0.1
| >Organization:
| >Environment:
| NetBSD 5.0.1 GENERIC/i386 (sorry, handwritter :-))
| >Description:
| Quoting from (same applies to Issue 7):
| http://www.opengroup.org/onlinepubs/000095399/functions/nice.html
|
| The nice() function shall fail if:
| [EPERM]
| The incr argument is negative and the calling process does not have
| appropriate privileges.
|
| Linux + OpenSolaris do it right. *BSD I tried return wrong error code.
|
|
| >How-To-Repeat:
| Call nice(-2) from a non-privileged program and check errno variable. It is EACCES, instead of EPERM.
|
|
| Trivial test case here may be found here:
| http://gitweb.dragonflybsd.org/~beket/pcca-tests.git/blob_plain/master:/unistd.h/t_nice.c
| >Fix:
| http://nxr.netbsd.org/source/xref/src/sys/kern/kern_resource.c#310
That will break setpriority(2). You need to make the change in nice(3).
christos
From: Stathis Kamperis <ekamperi@gmail.com>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandated)
EPERM
Date: Wed, 6 Jan 2010 20:46:12 +0200
> =A0That will break setpriority(2). You need to make the change in nice(3)=
.
>
> =A0christos
>
>
Ah, right, nice catch Christos.
setpriority() should return EACCES, and nice() EPERM. So we can't
change it in donice() as both are using it.
POSIX's 'p' stands for paranoia.
stathis
From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/42587 CVS commit: src/tests/lib/libc/gen
Date: Wed, 6 Apr 2011 08:47:55 +0000
Module Name: src
Committed By: jruoho
Date: Wed Apr 6 08:47:55 UTC 2011
Modified Files:
src/tests/lib/libc/gen: t_nice.c
Log Message:
As there is PR lib/42587, mark tiny POSIX error as expected failure.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_nice.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandated)
EPERM
Date: Sun, 1 May 2011 02:27:46 +0000
On Wed, Jan 06, 2010 at 06:25:02PM +0000, Christos Zoulas wrote:
> | http://nxr.netbsd.org/source/xref/src/sys/kern/kern_resource.c#310
>
> That will break setpriority(2). You need to make the change in nice(3).
any objection to this?
Index: nice.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/nice.c,v
retrieving revision 1.12
diff -u -p -r1.12 nice.c
--- nice.c 7 Aug 2003 16:42:53 -0000 1.12
+++ nice.c 1 May 2011 02:22:14 -0000
@@ -60,8 +60,11 @@ nice(incr)
errno = 0;
prio = getpriority(PRIO_PROCESS, 0);
- if (prio == -1 && errno)
+ if (prio == -1 && errno) {
+ if (errno == EACCES)
+ errno = EPERM;
return (-1);
+ }
if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0)
return (-1);
return (getpriority(PRIO_PROCESS, 0));
--
David A. Holland
dholland@netbsd.org
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, ekamperi@gmail.com
Cc:
Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandated) EPERM
Date: Sat, 30 Apr 2011 22:36:22 -0400
On May 1, 2:30am, dholland-bugs@netbsd.org (David Holland) wrote:
-- Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandate
| The following reply was made to PR lib/42587; it has been noted by GNATS.
|
| any objection to this?
|
| Index: nice.c
| ===================================================================
| RCS file: /cvsroot/src/lib/libc/gen/nice.c,v
| retrieving revision 1.12
| diff -u -p -r1.12 nice.c
| --- nice.c 7 Aug 2003 16:42:53 -0000 1.12
| +++ nice.c 1 May 2011 02:22:14 -0000
| @@ -60,8 +60,11 @@ nice(incr)
|
| errno = 0;
| prio = getpriority(PRIO_PROCESS, 0);
| - if (prio == -1 && errno)
| + if (prio == -1 && errno) {
| + if (errno == EACCES)
| + errno = EPERM;
| return (-1);
| + }
| if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0)
| return (-1);
| return (getpriority(PRIO_PROCESS, 0));
You need to do it in setpriority, since getpriority cannot fail with EACCES...
I should fix the man page too.
christos
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/42587: nice() returns EACCES instead of (standard mandated)
EPERM
Date: Sun, 1 May 2011 04:24:16 +0000
On Sun, May 01, 2011 at 02:40:05AM +0000, Christos Zoulas wrote:
> You need to do it in setpriority, since getpriority cannot fail with EACCES...
> I should fix the man page too.
oops that was dumb.
Index: nice.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/nice.c,v
retrieving revision 1.12
diff -u -p -r1.12 nice.c
--- nice.c 7 Aug 2003 16:42:53 -0000 1.12
+++ nice.c 1 May 2011 04:23:43 -0000
@@ -62,7 +62,10 @@ nice(incr)
prio = getpriority(PRIO_PROCESS, 0);
if (prio == -1 && errno)
return (-1);
- if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0)
+ if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0) {
+ if (errno == EACCES)
+ errno = EPERM;
return (-1);
+ }
return (getpriority(PRIO_PROCESS, 0));
}
--
David A. Holland
dholland@netbsd.org
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 01 May 2011 04:28:00 +0000
State-Changed-Why:
actually christos just committed the same fix
From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/42587 CVS commit: src/tests/lib/libc/gen
Date: Sun, 1 May 2011 06:42:30 +0000
Module Name: src
Committed By: jruoho
Date: Sun May 1 06:42:29 UTC 2011
Modified Files:
src/tests/lib/libc/gen: t_nice.c
Log Message:
PR lib/42587 was fixed; remove xfail.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_nice.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.