VIR_DEBUG("container support is enabled");
return 0;
}
+
+int lxcContainerChown(virDomainDefPtr def, const char *path)
+{
+ uid_t uid;
+ gid_t gid;
+
+ if (!def->idmap.uidmap)
+ return 0;
+
+ uid = def->idmap.uidmap[0].target;
+ gid = def->idmap.gidmap[0].target;
+
+ if (chown(path, uid, gid) < 0) {
+ virReportSystemError(errno,
+ _("Failed to change owner of %s to %u:%u"),
+ path, uid, gid);
+ return -1;
+ }
+
+ return 0;
+}
return rc;
}
-static int
-virLXCControllerChown(virLXCControllerPtr ctrl, char *path)
-{
- uid_t uid;
- gid_t gid;
-
- if (!ctrl->def->idmap.uidmap)
- return 0;
-
- uid = ctrl->def->idmap.uidmap[0].target;
- gid = ctrl->def->idmap.gidmap[0].target;
-
- if (chown(path, uid, gid) < 0) {
- virReportSystemError(errno,
- _("Failed to change owner of %s to %u:%u"),
- path, uid, gid);
- return -1;
- }
-
- return 0;
-}
static int
virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
goto cleanup;
}
- if (virLXCControllerChown(ctrl, dev) < 0)
+ if (lxcContainerChown(ctrl->def, dev) < 0)
goto cleanup;
ret = 0;
goto cleanup;
}
- if (virLXCControllerChown(ctrl, path) < 0)
+ if (lxcContainerChown(ctrl->def, path) < 0)
goto cleanup;
VIR_FREE(path);
goto cleanup;
}
- if (virLXCControllerChown(ctrl, dst) < 0)
+ if (lxcContainerChown(ctrl->def, dst) < 0)
goto cleanup;
/* Labelling normally operates on src, but we need
goto cleanup;
}
- if ((virLXCControllerChown(ctrl, ctrl->devptmx) < 0) ||
- (virLXCControllerChown(ctrl, devpts) < 0))
+ if ((lxcContainerChown(ctrl->def, ctrl->devptmx) < 0) ||
+ (lxcContainerChown(ctrl->def, devpts) < 0))
goto cleanup;
ret = 0;
}
/* Change the owner of tty device to the root user of container */
- if (virLXCControllerChown(ctrl, ttyHostPath) < 0)
+ if (lxcContainerChown(ctrl->def, ttyHostPath) < 0)
goto cleanup;
VIR_FREE(ttyHostPath);