Print this page
OS-4716 lxbrand native system(3C) broken
Reviewed by: jerry.jelinek@joyent.com
Reviewed by: patrick.mooney@joyent.com
        
*** 20,29 ****
--- 20,30 ----
   */
  
  /*
   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
   * Use is subject to license terms.
+  * Copyright 2016 Joyent, Inc.
   */
  
  /*      Copyright (c) 1988 AT&T */
  /*        All Rights Reserved   */
  
*** 41,50 ****
--- 42,52 ----
  #include <pthread.h>
  #include <errno.h>
  #include <synch.h>
  #include <spawn.h>
  #include <paths.h>
+ #include <zone.h>
  #include "libc.h"
  
  extern const char **_environ;
  
  extern int __xpg4;      /* defined in _xpg4.c; 0 if not xpg4-compiled program */
*** 123,137 ****
          pid_t w;
          int status;
          int error;
          sigset_t mask;
          struct stat64 buf;
!         const char *shpath = _PATH_BSHELL;
          char *argv[4];
          posix_spawnattr_t attr;
          static const char *shell = "sh";
  
          if (cmd == NULL) {
                  if (stat64(shpath, &buf) != 0) {
                          return (0);
                  } else if (getuid() == buf.st_uid) {
                          /* exec for user */
--- 125,146 ----
          pid_t w;
          int status;
          int error;
          sigset_t mask;
          struct stat64 buf;
!         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);
                  } else if (getuid() == buf.st_uid) {
                          /* exec for user */