]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: no need to pass excess flags to open()/openat() if O_PATH is passed 2779/head
authorAlexander Kuleshov <kuleshovmail@gmail.com>
Tue, 1 Mar 2016 18:25:09 +0000 (00:25 +0600)
committerAlexander Kuleshov <kuleshovmail@gmail.com>
Tue, 1 Mar 2016 18:42:49 +0000 (00:42 +0600)
As described in the documentation:

When O_PATH is specified in flags, flag bits other than O_CLOEXEC,
O_DIRECTORY, and O_NOFOLLOW are ignored.

So, we can remove unnecessary flags in a case when O_PATH is passed
to the open() or openat().

src/basic/mount-util.c
src/basic/xattr-util.c
src/tmpfiles/tmpfiles.c

index 33f2ee96d8f9badf7e79a5db2482f0fd85a9a6dc..5faa2eba055b04da668eb7882bfefdaa8ac044b9 100644 (file)
@@ -47,7 +47,7 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id
         if ((flags & AT_EMPTY_PATH) && isempty(filename))
                 xsprintf(path, "/proc/self/fdinfo/%i", fd);
         else {
-                subfd = openat(fd, filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH);
+                subfd = openat(fd, filename, O_CLOEXEC|O_PATH);
                 if (subfd < 0)
                         return -errno;
 
@@ -230,7 +230,7 @@ int path_is_mount_point(const char *t, int flags) {
         if (!parent)
                 return -ENOMEM;
 
-        fd = openat(AT_FDCWD, parent, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_PATH);
+        fd = openat(AT_FDCWD, parent, O_DIRECTORY|O_CLOEXEC|O_PATH);
         if (fd < 0)
                 return -errno;
 
index 8d7f14f3827e457cf027874ec4dfa1e5c5f05323..8256899edae347260027a1495823a9de4c2d1b63 100644 (file)
@@ -110,7 +110,7 @@ ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute,
 
         /* The kernel doesn't have a fgetxattrat() command, hence let's emulate one */
 
-        fd = openat(dirfd, filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH|(flags & AT_SYMLINK_NOFOLLOW ? O_NOFOLLOW : 0));
+        fd = openat(dirfd, filename, O_CLOEXEC|O_PATH|(flags & AT_SYMLINK_NOFOLLOW ? O_NOFOLLOW : 0));
         if (fd < 0)
                 return -errno;
 
index 7b105a6bd402e7b4583e4197067e771d77fc93a3..2ab0468c127881c8b4cc33f932c251746bde35e5 100644 (file)
@@ -613,7 +613,7 @@ static int path_set_perms(Item *i, const char *path) {
          * with AT_SYMLINK_NOFOLLOW, hence we emulate it here via
          * O_PATH. */
 
-        fd = open(path, O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_NOATIME);
+        fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH);
         if (fd < 0)
                 return log_error_errno(errno, "Adjusting owner and mode for %s failed: %m", path);
 
@@ -804,7 +804,7 @@ static int path_set_acls(Item *item, const char *path) {
         assert(item);
         assert(path);
 
-        fd = open(path, O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_NOATIME);
+        fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH);
         if (fd < 0)
                 return log_error_errno(errno, "Adjusting ACL of %s failed: %m", path);