Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 May 2011 22:04:59 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r221514 - stable/8/bin/sh
Message-ID:  <201105052204.p45M4xX0018621@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu May  5 22:04:59 2011
New Revision: 221514
URL: http://svn.freebsd.org/changeset/base/221514

Log:
  MFC r221011: sh: Remove duplicate code resetting uid/gid for set +p/
  +o privileged.

Modified:
  stable/8/bin/sh/options.c
Directory Properties:
  stable/8/bin/sh/   (props changed)

Modified: stable/8/bin/sh/options.c
==============================================================================
--- stable/8/bin/sh/options.c	Thu May  5 20:55:55 2011	(r221513)
+++ stable/8/bin/sh/options.c	Thu May  5 22:04:59 2011	(r221514)
@@ -195,13 +195,8 @@ options(int cmdline)
 				minus_o(*argptr, val);
 				if (*argptr)
 					argptr++;
-			} else {
-				if (c == 'p' && !val && privileged) {
-					(void) setuid(getuid());
-					(void) setgid(getgid());
-				}
+			} else
 				setoption(c, val);
-			}
 		}
 	}
 	return;
@@ -269,10 +264,6 @@ minus_o(char *name, int val)
 	} else {
 		for (i = 0; i < NOPTS; i++)
 			if (equal(name, optlist[i].name)) {
-				if (!val && privileged && equal(name, "privileged")) {
-					(void) setuid(getuid());
-					(void) setgid(getgid());
-				}
 				setoption(optlist[i].letter, val);
 				return;
 			}
@@ -286,6 +277,10 @@ setoption(int flag, int val)
 {
 	int i;
 
+	if (flag == 'p' && !val && privileged) {
+		(void) setuid(getuid());
+		(void) setgid(getgid());
+	}
 	for (i = 0; i < NOPTS; i++)
 		if (optlist[i].letter == flag) {
 			optlist[i].val = val;



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