Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2000 10:55:10 +0200 (CEST)
From:      alex@freebsd.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/19946: possible bug in sh(1) with -p flag (privileged mode)
Message-ID:  <20000715085510.2B2C014AEB@cichlids.cichlids.com>

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

>Number:         19946
>Category:       bin
>Synopsis:       possible bug in sh(1) with -p flag (privileged mode)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 15 02:00:02 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Langer
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
FreeBSD Project
>Environment:

-current

>Description:

I think I found a possible bug  in the sh(1) -p (privileged mode) behaviour.
On the one hand, the manpage is something broken (see pr 18243).

However, this is another thing.  If I understood the -p flag correctly
from the source and the current manpage, the -p flag should turn
off different real and effective user ids (and gids).
-p turns on, that the effective uid is set TO the real uid. (and the gid's
respectively).
However, in this case, it makes no sense, that STILL /etc/suid_profile
is parsed in spite of ~/.profile(!) - in fact, -p should turn OFF
the priviledged mode behaviour, or am I wrong?

So, I suggest to use the following patch, which sets the global variable
`privileged' to 0 again, after the -p flag is given and the
effective uid/gid are set to the real ones.
This makes sh parse ~/.profile later on (in main.c), which is
the correct behaviour in my opinion.

I'll take a look at the manpage later to clarify this.

>How-To-Repeat:

n/a

>Fix:

cvs server: Diffing .
Index: options.c
===================================================================
RCS file: /home/ncvs/src/bin/sh/options.c,v
retrieving revision 1.16
diff -u -r1.16 options.c
--- options.c	2000/04/20 09:49:16	1.16
+++ options.c	2000/07/15 08:54:26
@@ -193,6 +193,7 @@
 				if (c == 'p' && !val && privileged) {
 					(void) setuid(getuid());
 					(void) setgid(getgid());
+					privileged = 0;
 				}
 				setoption(c, val);
 			}
@@ -218,6 +219,7 @@
 				if (!val && privileged && equal(name, "privileged")) {
 					(void) setuid(getuid());
 					(void) setgid(getgid());
+					privileged = 0;
 				}
 				setoption(optlist[i].letter, val);
 				return;
cvs server: Diffing bltin
cvs server: Diffing funcs

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


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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