diff options
author | smitsohu <smitsohu@gmail.com> | 2020-12-21 17:23:58 +0100 |
---|---|---|
committer | smitsohu <smitsohu@gmail.com> | 2020-12-21 17:23:58 +0100 |
commit | 10d75c3f4439dd58cc0f4d1fbad7140d0fca7492 (patch) | |
tree | 02c696e5cb22a015ab568aa92bd3a2e19957ed0a | |
parent | remove trailing whitespaces (diff) | |
download | firejail-10d75c3f4439dd58cc0f4d1fbad7140d0fca7492.tar.gz firejail-10d75c3f4439dd58cc0f4d1fbad7140d0fca7492.tar.zst firejail-10d75c3f4439dd58cc0f4d1fbad7140d0fca7492.zip |
minor cleanup, cosmetics
-rw-r--r-- | src/firejail/util.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index 6cc1bc720..a3927cc88 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | #include <termios.h> | 30 | #include <termios.h> |
31 | #include <sys/wait.h> | 31 | #include <sys/wait.h> |
32 | #include <sys/syscall.h> | ||
33 | #include <limits.h> | 32 | #include <limits.h> |
34 | 33 | ||
35 | #include <fcntl.h> | 34 | #include <fcntl.h> |
@@ -37,6 +36,7 @@ | |||
37 | #define O_PATH 010000000 | 36 | #define O_PATH 010000000 |
38 | #endif | 37 | #endif |
39 | 38 | ||
39 | #include <sys/syscall.h> | ||
40 | #ifdef __NR_openat2 | 40 | #ifdef __NR_openat2 |
41 | #include <linux/openat2.h> | 41 | #include <linux/openat2.h> |
42 | #endif | 42 | #endif |
@@ -1013,12 +1013,8 @@ int create_empty_dir_as_user(const char *dir, mode_t mode) { | |||
1013 | if (chmod(dir, mode) == -1) | 1013 | if (chmod(dir, mode) == -1) |
1014 | {;} // do nothing | 1014 | {;} // do nothing |
1015 | } | 1015 | } |
1016 | else if (arg_debug) { | 1016 | else if (arg_debug) |
1017 | char *str; | 1017 | printf("Directory %s not created: %s\n", dir, strerror(errno)); |
1018 | if (asprintf(&str, "Directory %s not created", dir) == -1) | ||
1019 | errExit("asprintf"); | ||
1020 | perror(str); | ||
1021 | } | ||
1022 | #ifdef HAVE_GCOV | 1018 | #ifdef HAVE_GCOV |
1023 | __gcov_flush(); | 1019 | __gcov_flush(); |
1024 | #endif | 1020 | #endif |
@@ -1165,12 +1161,12 @@ void disable_file_path(const char *path, const char *file) { | |||
1165 | 1161 | ||
1166 | // open an existing file without following any symbolic link | 1162 | // open an existing file without following any symbolic link |
1167 | int safe_fd(const char *path, int flags) { | 1163 | int safe_fd(const char *path, int flags) { |
1164 | flags |= O_NOFOLLOW; | ||
1168 | assert(path); | 1165 | assert(path); |
1169 | if (*path != '/' || strstr(path, "..")) { | 1166 | if (*path != '/' || strstr(path, "..")) { |
1170 | fprintf(stderr, "Error: invalid path %s\n", path); | 1167 | fprintf(stderr, "Error: invalid path %s\n", path); |
1171 | exit(1); | 1168 | exit(1); |
1172 | } | 1169 | } |
1173 | flags |= O_NOFOLLOW; | ||
1174 | int fd = -1; | 1170 | int fd = -1; |
1175 | 1171 | ||
1176 | #ifdef __NR_openat2 // kernel 5.6 or better | 1172 | #ifdef __NR_openat2 // kernel 5.6 or better |