提交 25aa0532 编写于 作者: D Daniel P. Berrange

Move security manager into virLXCControllerPtr object

Move the security manager object into the virLXCControllerPtr
object. Also simplify the code creating it in the first place
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 37441d89
...@@ -122,6 +122,8 @@ struct _virLXCController { ...@@ -122,6 +122,8 @@ struct _virLXCController {
size_t nloopDevs; size_t nloopDevs;
int *loopDevFds; int *loopDevFds;
virSecurityManagerPtr securityManager;
}; };
static void virLXCControllerFree(virLXCControllerPtr ctrl); static void virLXCControllerFree(virLXCControllerPtr ctrl);
...@@ -222,6 +224,8 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl) ...@@ -222,6 +224,8 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
virLXCControllerStopInit(ctrl); virLXCControllerStopInit(ctrl);
virSecurityManagerFree(ctrl->securityManager);
for (i = 0 ; i < ctrl->nveths ; i++) for (i = 0 ; i < ctrl->nveths ; i++)
VIR_FREE(ctrl->veths[i]); VIR_FREE(ctrl->veths[i]);
VIR_FREE(ctrl->veths); VIR_FREE(ctrl->veths);
...@@ -1544,7 +1548,6 @@ cleanup: ...@@ -1544,7 +1548,6 @@ cleanup:
static int static int
virLXCControllerRun(virLXCControllerPtr ctrl, virLXCControllerRun(virLXCControllerPtr ctrl,
virSecurityManagerPtr securityDriver,
int monitor, int monitor,
int client) int client)
{ {
...@@ -1604,7 +1607,8 @@ virLXCControllerRun(virLXCControllerPtr ctrl, ...@@ -1604,7 +1607,8 @@ virLXCControllerRun(virLXCControllerPtr ctrl,
* marked as shared * marked as shared
*/ */
if (root) { if (root) {
mount_options = virSecurityManagerGetMountOptions(securityDriver, ctrl->def); mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager,
ctrl->def);
char *opts; char *opts;
VIR_DEBUG("Setting up private /dev/pts"); VIR_DEBUG("Setting up private /dev/pts");
...@@ -1698,7 +1702,7 @@ virLXCControllerRun(virLXCControllerPtr ctrl, ...@@ -1698,7 +1702,7 @@ virLXCControllerRun(virLXCControllerPtr ctrl,
goto cleanup; goto cleanup;
if ((ctrl->initpid = lxcContainerStart(ctrl->def, if ((ctrl->initpid = lxcContainerStart(ctrl->def,
securityDriver, ctrl->securityManager,
ctrl->nveths, ctrl->nveths,
ctrl->veths, ctrl->veths,
control[1], control[1],
...@@ -1793,9 +1797,9 @@ int main(int argc, char *argv[]) ...@@ -1793,9 +1797,9 @@ int main(int argc, char *argv[])
}; };
int *ttyFDs = NULL; int *ttyFDs = NULL;
size_t nttyFDs = 0; size_t nttyFDs = 0;
virSecurityManagerPtr securityDriver = NULL;
virLXCControllerPtr ctrl = NULL; virLXCControllerPtr ctrl = NULL;
size_t i; size_t i;
const char *securityDriver = "none";
if (setlocale(LC_ALL, "") == NULL || if (setlocale(LC_ALL, "") == NULL ||
bindtextdomain(PACKAGE, LOCALEDIR) == NULL || bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
...@@ -1860,13 +1864,7 @@ int main(int argc, char *argv[]) ...@@ -1860,13 +1864,7 @@ int main(int argc, char *argv[])
break; break;
case 'S': case 'S':
if (!(securityDriver = virSecurityManagerNew(optarg, securityDriver = optarg;
LXC_DRIVER_NAME,
false, false, false))) {
fprintf(stderr, "Cannot create security manager '%s'",
optarg);
goto cleanup;
}
break; break;
case 'h': case 'h':
...@@ -1888,16 +1886,6 @@ int main(int argc, char *argv[]) ...@@ -1888,16 +1886,6 @@ int main(int argc, char *argv[])
} }
} }
if (securityDriver == NULL) {
if (!(securityDriver = virSecurityManagerNew("none",
LXC_DRIVER_NAME,
false, false, false))) {
fprintf(stderr, "%s: cannot initialize nop security manager", argv[0]);
goto cleanup;
}
}
if (name == NULL) { if (name == NULL) {
fprintf(stderr, "%s: missing --name argument for configuration\n", argv[0]); fprintf(stderr, "%s: missing --name argument for configuration\n", argv[0]);
goto cleanup; goto cleanup;
...@@ -1921,6 +1909,11 @@ int main(int argc, char *argv[]) ...@@ -1921,6 +1909,11 @@ int main(int argc, char *argv[])
ctrl->handshakeFd = handshakeFd; ctrl->handshakeFd = handshakeFd;
if (!(ctrl->securityManager = virSecurityManagerNew(securityDriver,
LXC_DRIVER_NAME,
false, false, false)))
goto cleanup;
VIR_DEBUG("Security model %s type %s label %s imagelabel %s", VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
NULLSTR(ctrl->def->seclabel.model), NULLSTR(ctrl->def->seclabel.model),
virDomainSeclabelTypeToString(ctrl->def->seclabel.type), virDomainSeclabelTypeToString(ctrl->def->seclabel.type),
...@@ -1987,7 +1980,7 @@ int main(int argc, char *argv[]) ...@@ -1987,7 +1980,7 @@ int main(int argc, char *argv[])
goto cleanup; goto cleanup;
} }
rc = virLXCControllerRun(ctrl, securityDriver, rc = virLXCControllerRun(ctrl,
monitor, client); monitor, client);
cleanup: cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册