Skip to content

Commit

Permalink
lxc_init: add missing O_CLOEXEC
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Mar 25, 2020
1 parent ed58616 commit 591f6f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lxc/cmd/lxc_init.c
Expand Up @@ -87,7 +87,8 @@ static void prevent_forking(void)
return;

while (getline(&line, &len, f) != -1) {
int fd, ret;
__do_close int fd = -EBADF;
int ret;
char *p, *p2;

p = strchr(line, ':');
Expand Down Expand Up @@ -118,7 +119,7 @@ static void prevent_forking(void)
return;
}

fd = open(path, O_WRONLY);
fd = open(path, O_WRONLY | O_CLOEXEC);
if (fd < 0) {
if (my_args.quiet)
fprintf(stderr, "Failed to open \"%s\"\n", path);
Expand All @@ -129,7 +130,6 @@ static void prevent_forking(void)
if (ret != 1 && !my_args.quiet)
fprintf(stderr, "Failed to write to \"%s\"\n", path);

close(fd);
return;
}
}
Expand Down

0 comments on commit 591f6f4

Please sign in to comment.