diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-06 21:23:03 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-06 21:24:03 +0900 |
commit | 835d18ba20525f8ae41f643e8531e0e67f87bfd0 (patch) | |
tree | 3427f4d49a2b3920756fb0316353e3bc26444930 | |
parent | 57512c893eacbafdad5d91df43ac4cd43b328993 (diff) | |
download | systemd-835d18ba20525f8ae41f643e8531e0e67f87bfd0.tar.gz systemd-835d18ba20525f8ae41f643e8531e0e67f87bfd0.tar.bz2 systemd-835d18ba20525f8ae41f643e8531e0e67f87bfd0.zip |
fileio: introduce WRITE_STRING_FILE_NOFOLLOW flag for write_string_file() and friends
-rw-r--r-- | src/basic/fileio.c | 2 | ||||
-rw-r--r-- | src/basic/fileio.h | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c index f14afa5dce..fa6084e602 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -160,7 +160,7 @@ int write_string_file_ts( /* We manually build our own version of fopen(..., "we") that * works without O_CREAT */ - fd = open(fn, O_WRONLY|O_CLOEXEC|O_NOCTTY); + fd = open(fn, O_WRONLY|O_CLOEXEC|O_NOCTTY | ((flags & WRITE_STRING_FILE_NOFOLLOW) ? O_NOFOLLOW : 0)); if (fd < 0) { r = -errno; goto fail; diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 102d33d75f..f809848408 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -17,6 +17,7 @@ typedef enum { WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 3, WRITE_STRING_FILE_SYNC = 1 << 4, WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 5, + WRITE_STRING_FILE_NOFOLLOW = 1 << 6, /* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file() |