summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
authorRyan Zezeski <rpz@joyent.com>2016-08-18 11:59:55 -0700
committerRyan Zezeski <rpz@joyent.com>2016-08-23 11:36:13 -0400
commit0c8abfcb7a94e2016322218587cc80b4bd710642 (patch)
tree460560ea819e5e18d0df7d9ffadd424783ec8705 /usr/src/lib/libc
parent7d7135b2b1824ef59ff15bd50e46e84601cb94be (diff)
downloadillumos-joyent-0c8abfcb7a94e2016322218587cc80b4bd710642.tar.gz
OS-4716 lxbrand native system(3C) broken
Reviewed by: jerry.jelinek@joyent.com Reviewed by: patrick.mooney@joyent.com
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/port/stdio/system.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr/src/lib/libc/port/stdio/system.c b/usr/src/lib/libc/port/stdio/system.c
index bc7e412d52..698d02b2ec 100644
--- a/usr/src/lib/libc/port/stdio/system.c
+++ b/usr/src/lib/libc/port/stdio/system.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2016 Joyent, Inc.
*/
/* Copyright (c) 1988 AT&T */
@@ -43,6 +44,7 @@
#include <synch.h>
#include <spawn.h>
#include <paths.h>
+#include <zone.h>
#include "libc.h"
extern const char **_environ;
@@ -125,11 +127,18 @@ system(const char *cmd)
int error;
sigset_t mask;
struct stat64 buf;
- const char *shpath = _PATH_BSHELL;
+ char shpath[MAXPATHLEN];
+ const char *zroot = zone_get_nroot();
char *argv[4];
posix_spawnattr_t attr;
static const char *shell = "sh";
+ /*
+ * If executing in brand use native root.
+ */
+ (void) snprintf(shpath, sizeof (shpath), "%s%s",
+ zroot != NULL ? zroot : "", _PATH_BSHELL);
+
if (cmd == NULL) {
if (stat64(shpath, &buf) != 0) {
return (0);