]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Only use O_NOFOLLOW in fchownat and fchmodat if defined
authorTim Rice <tim@multitalents.net>
Mon, 1 Apr 2019 02:22:19 +0000 (19:22 -0700)
committerTim Rice <tim@multitalents.net>
Mon, 1 Apr 2019 02:22:19 +0000 (19:22 -0700)
openbsd-compat/bsd-misc.c

index 3c85a12a6f0ad9a10197aa189802c17075bfc3ba..aa1c7d7a3dd6a63b239c14333dd8a68c98938e8d 100644 (file)
@@ -174,8 +174,10 @@ fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag)
 # ifndef HAVE_FCHOWN
        return chown(pathname, owner, group);
 # else
+#  ifdef O_NOFOLLOW
        if (flag & AT_SYMLINK_NOFOLLOW)
                oflags |= O_NOFOLLOW;
+#  endif /* O_NOFOLLOW */
        if ((fd = open(path, oflags)) == -1)
                return -1;
        ret = fchown(fd, owner, group);
@@ -203,8 +205,10 @@ fchmodat(int fd, const char *path, mode_t mode, int flag)
 # ifndef HAVE_FCHMOD
        return chown(pathname, owner, group);
 # else
+#  ifdef O_NOFOLLOW
        if (flag & AT_SYMLINK_NOFOLLOW)
                oflags |= O_NOFOLLOW;
+#  endif /* O_NOFOLLOW */
        if ((fd = open(path, oflags)) == -1)
                return -1;
        ret = fchmod(fd, mode);