]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: Fix -c command 3954/head
authorMaximilian Blenk <Maximilian.Blenk@bmw.de>
Mon, 23 Aug 2021 13:39:28 +0000 (15:39 +0200)
committerMaximilian Blenk <Maximilian.Blenk@bmw.de>
Mon, 30 Aug 2021 11:06:35 +0000 (13:06 +0200)
Currently, the -c command (to set the selinux context) seems to be
broken because the passed context is ignored and always overwritten by
the context specified in the config file. The intention behind the -c
imho was to be able to manually overwrite this behavior. This patch
ensures that the selinux context will be set if passed via the command
line.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
src/lxc/tools/lxc_attach.c

index 0374d980b41c744a2decbd8e90b703d2dad6cfbf..e6b388b20c4b0150bc2646f05c35866bccdd10f1 100644 (file)
@@ -379,7 +379,10 @@ int main(int argc, char *argv[])
                attach_options.gid = my_args.gid;
 
        // selinux_context will be NULL if not set
-       attach_options.lsm_label = selinux_context;
+       if (selinux_context) {
+               attach_options.attach_flags |= LXC_ATTACH_LSM_LABEL;
+               attach_options.lsm_label = selinux_context;
+       }
 
        if (command.program) {
                ret = c->attach_run_wait(c, &attach_options, command.program,