[lxc-devel] [lxc/master] tools: fix lxc-create with global config value II

brauner on Github lxc-bot at linuxcontainers.org
Fri May 25 17:35:53 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180525/1aeafc43/attachment.bin>
-------------- next part --------------
From 49938fbcd9780c558d9aee5e43a97cefc41389cc Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 25 May 2018 19:35:00 +0200
Subject: [PATCH] tools: fix lxc-create with global config value II

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/tools/lxc_create.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/lxc/tools/lxc_create.c b/src/lxc/tools/lxc_create.c
index dba252112..3dd2e01b8 100644
--- a/src/lxc/tools/lxc_create.c
+++ b/src/lxc/tools/lxc_create.c
@@ -267,24 +267,19 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (geteuid()) {
-		if (!my_args.lxcpath[0])
-			my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath");
 
-		if (mkdir_p(my_args.lxcpath[0], 0755))
-			exit(EXIT_FAILURE);
+	if (!my_args.lxcpath[0])
+		my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath");
+
+	if (mkdir_p(my_args.lxcpath[0], 0755))
+		exit(EXIT_FAILURE);
 
+	if (geteuid())
 		if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
-			fprintf(stderr, "You lack access to %s\n", my_args.lxcpath[0]);
+			fprintf(stderr, "You lack access to %s\n",
+				my_args.lxcpath[0]);
 			exit(EXIT_FAILURE);
 		}
-		if (strcmp(my_args.bdevtype, "dir") && strcmp(my_args.bdevtype, "_unset") &&
-				strcmp(my_args.bdevtype, "btrfs")) {
-			fprintf(stderr, "Unprivileged users cannot create %s containers.\n", my_args.bdevtype);
-			exit(EXIT_FAILURE);
-		}
-	}
-
 
 	c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
 	if (!c) {


More information about the lxc-devel mailing list