Skip to content

Commit

Permalink
file_utils: use O_NOCTTY | O_NOFOLLOW
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 Dec 9, 2019
1 parent 1d40942 commit afb9722
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lxc/file_utils.c
Expand Up @@ -44,7 +44,8 @@ int lxc_writeat(int dirfd, const char *filename, const void *buf, size_t count)
__do_close_prot_errno int fd = -EBADF;
ssize_t ret;

fd = openat(dirfd, filename, O_WRONLY | O_CLOEXEC);
fd = openat(dirfd, filename,
O_WRONLY | O_CLOEXEC | O_NOCTTY | O_NOFOLLOW);
if (fd < 0)
return -1;

Expand All @@ -60,7 +61,7 @@ int lxc_write_openat(const char *dir, const char *filename, const void *buf,
{
__do_close_prot_errno int dirfd = -EBADF;

dirfd = open(dir, O_DIRECTORY | O_RDONLY | O_CLOEXEC);
dirfd = open(dir, O_DIRECTORY | O_RDONLY | O_CLOEXEC | O_NOCTTY | O_NOFOLLOW);
if (dirfd < 0)
return -1;

Expand Down

0 comments on commit afb9722

Please sign in to comment.