Skip site navigation (1)Skip section navigation (2)
Date:      Sun,  9 Mar 2008 10:39:10 +0100 (CET)
From:      Romain Tartiere <romain@blogreen.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/121512: [sysctl] [patch] sysctl(8) should return 1 if the user is not allowed to change values
Message-ID:  <20080309093910.51AB55C052@marvin.blogreen.org>
Resent-Message-ID: <200803091010.m29AA1D4060722@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         121512
>Category:       bin
>Synopsis:       [sysctl] [patch] sysctl(8) should return 1 if the user is not allowed to change values
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 09 10:10:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Romain Tartiere
>Release:        FreeBSD 7.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD marvin.blogreen.org 7.0-STABLE FreeBSD 7.0-STABLE #12: Tue Mar 4 14:26:24 CET 2008 root@marvin.blogreen.org:/usr/obj/usr/src/sys/MARVIN i386


	
>Description:

Launching sysctl(8) to tune the system as a regular user will fail because of
permissions ...

> % sysctl vfs.usermount=1
> vfs.usermount: 1
> sysctl: vfs.usermount: Operation not permitted
> %

... but the program still returns 0.  Exiting with 1 may be more consistent.
The attached patch handle this very particular case.  Maybe it is even possible
to change the default statement to call err(3) whatever the error is.

	
>How-To-Repeat:

% sysctl vfs.usermount=1 && echo Success || echo Failed
vfs.usermount: 1
sysctl: vfs.usermount: Operation not permitted
Success
%

>Fix:

	

--- patch-sysctl.c begins here ---
--- /usr/src/sbin/sysctl/sysctl.c	2007-06-11 15:02:15.000000000 +0200
+++ sysctl/sysctl.c	2008-03-09 10:23:57.000000000 +0100
@@ -302,6 +302,8 @@
 			case ENOMEM:
 				errx(1, "%s: type is unknown to this program",
 					string);
+			case EPERM:
+				err(1, "%s", string);
 			default:
 				warn("%s", string);
 				return;
--- patch-sysctl.c ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080309093910.51AB55C052>