Print this page
Forgot to merge in unlink of ZONE_LOCK in dlmgmtd.
dlmgmt mismerge
OS-3007 dlmgmtd needs to work with non-native zones

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2014 Joyent, Inc.  All rights reserved.
  */
 
 /*
  * The dlmgmtd daemon is started by the datalink-management SMF service.
  * This daemon is used to manage <link name, linkid> mapping and the

@@ -129,13 +130,22 @@
 dlmgmt_door_attach(zoneid_t zoneid, char *rootdir)
 {
         int     fd;
         int     err = 0;
         char    doorpath[MAXPATHLEN];
+        struct stat statbuf;
 
-        (void) snprintf(doorpath, sizeof (doorpath), "%s%s", rootdir,
-            DLMGMT_DOOR);
+        /* Handle running in a non-native branded zone (i.e. has /native) */
+        (void) snprintf(doorpath, sizeof (doorpath), "%s/native%s",
+            rootdir, DLMGMT_TMPFS_DIR);
+        if (stat(doorpath, &statbuf) == 0) {
+                (void) snprintf(doorpath, sizeof (doorpath), "%s/native%s",
+                    rootdir, DLMGMT_DOOR);
+        } else {
+                (void) snprintf(doorpath, sizeof (doorpath), "%s%s",
+                    rootdir, DLMGMT_DOOR);
+        }
 
         /*
          * Create the door file for dlmgmtd.
          */
         if ((fd = open(doorpath, O_CREAT|O_RDONLY, 0644)) == -1) {

@@ -190,22 +200,30 @@
          * Create the DLMGMT_TMPFS_DIR directory.
          */
         (void) snprintf(tmpfsdir, sizeof (tmpfsdir), "%s%s", rootdir,
             DLMGMT_TMPFS_DIR);
         if (stat(tmpfsdir, &statbuf) < 0) {
+                if (mkdir(tmpfsdir, (mode_t)0755) < 0) {
+                        /*
+                         * Handle running in a non-native branded zone
+                         * (i.e. has /native)
+                         */
+                        (void) snprintf(tmpfsdir, sizeof (tmpfsdir),
+                            "%s/native%s", rootdir, DLMGMT_TMPFS_DIR);
                 if (mkdir(tmpfsdir, (mode_t)0755) < 0)
                         return (errno);
+                }
         } else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
                 return (ENOTDIR);
         }
 
         if ((chmod(tmpfsdir, 0755) < 0) ||
             (chown(tmpfsdir, UID_DLADM, GID_NETADM) < 0)) {
                 return (EPERM);
         }
 
-        if ((err = dlmgmt_db_init(zoneid)) != 0)
+        if ((err = dlmgmt_db_init(zoneid, rootdir)) != 0)
                 return (err);
         return (dlmgmt_door_attach(zoneid, rootdir));
 }
 
 /*

@@ -260,10 +278,12 @@
                 dlmgmt_log(LOG_ERR, "signal() for SIGTERM/INT failed: %s",
                     strerror(err));
                 return (err);
         }
 
+        (void) unlink(ZONE_LOCK);
+
         /*
          * First derive the name of the cache file from the FMRI name. This
          * cache name is used to keep active datalink configuration.
          */
         if (debug) {