From: Christian Brauner Date: Tue, 17 Mar 2020 17:07:50 +0000 (+0100) Subject: tools: fix -g -u parameters for lxc-execute and lxc-attach X-Git-Tag: lxc-4.0.0~22^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc94aaf3f929bc2eb911f3d5eb71806f13412cb2;p=thirdparty%2Flxc.git tools: fix -g -u parameters for lxc-execute and lxc-attach Closes #3188. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c index 44c8e8dae..a8f493aa7 100644 --- a/src/lxc/tools/lxc_attach.c +++ b/src/lxc/tools/lxc_attach.c @@ -132,6 +132,8 @@ Options :\n\ .checker = NULL, .log_priority = "ERROR", .log_file = "none", + .uid = LXC_INVALID_UID, + .gid = LXC_INVALID_GID, }; static int my_parser(struct lxc_arguments *args, int c, char *arg) @@ -345,10 +347,10 @@ int main(int argc, char *argv[]) goto out; } - if (my_args.uid) + if (my_args.uid != LXC_INVALID_UID) attach_options.uid = my_args.uid; - if (my_args.gid) + if (my_args.gid != LXC_INVALID_GID) attach_options.gid = my_args.gid; if (command.program) { diff --git a/src/lxc/tools/lxc_execute.c b/src/lxc/tools/lxc_execute.c index 9cb281f9f..6352114ec 100644 --- a/src/lxc/tools/lxc_execute.c +++ b/src/lxc/tools/lxc_execute.c @@ -63,6 +63,8 @@ Options :\n\ .log_priority = "ERROR", .log_file = "none", .daemonize = 0, + .uid = LXC_INVALID_UID, + .gid = LXC_INVALID_GID, }; static int my_parser(struct lxc_arguments *args, int c, char *arg) @@ -190,7 +192,7 @@ int main(int argc, char *argv[]) if (!bret) goto out; - if (my_args.uid) { + if (my_args.uid != LXC_INVALID_UID) { char buf[256]; ret = snprintf(buf, 256, "%d", my_args.uid); @@ -202,7 +204,7 @@ int main(int argc, char *argv[]) goto out; } - if (my_args.gid) { + if (my_args.gid != LXC_INVALID_GID) { char buf[256]; ret = snprintf(buf, 256, "%d", my_args.gid);