attach: Fix -c command

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>
This commit is contained in:
Maximilian Blenk 2021-08-23 15:39:28 +02:00
parent 6446bf47d3
commit 9becf309a8

View File

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