diff options
author | steve <steve@FreeBSD.org> | 1996-10-29 03:12:51 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1996-10-29 03:12:51 +0000 |
commit | ac82f35222ffb550ce85912f86498957f59ce50b (patch) | |
tree | 97cdea4e237b2b62bb4b43b1b77a859e45b517fc /bin/sh/options.c | |
parent | 6a0fb85f4754bfc12c9e49202548159489701554 (diff) | |
download | FreeBSD-src-ac82f35222ffb550ce85912f86498957f59ce50b.zip FreeBSD-src-ac82f35222ffb550ce85912f86498957f59ce50b.tar.gz |
Add the -p (privileged) commandline switch
found in bash, zsh, and friends.
Reviewed by: joerg
Diffstat (limited to 'bin/sh/options.c')
-rw-r--r-- | bin/sh/options.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bin/sh/options.c b/bin/sh/options.c index 095c7a9..627c20c 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: options.c,v 1.6 1995/10/09 17:56:32 joerg Exp $ + * $Id: options.c,v 1.7 1996/09/01 10:21:16 peter Exp $ */ #ifndef lint @@ -92,6 +92,7 @@ procargs(argc, argv) argptr++; for (i = 0; i < NOPTS; i++) optlist[i].val = 2; + privileged = (getuid() != geteuid() || getgid() != getegid()); options(1); if (*argptr == NULL && minusc == NULL) sflag = 1; @@ -184,6 +185,10 @@ options(cmdline) if (*argptr) argptr++; } else { + if (c == 'p' && !val && privileged) { + (void) setuid(getuid()); + (void) setgid(getgid()); + } setoption(c, val); } } @@ -205,6 +210,10 @@ minus_o(name, 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; } |