summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2019-03-31 19:22:19 -0700
committerTim Rice <tim@multitalents.net>2019-03-31 19:22:19 -0700
commit43f47ebbdd4037b569c23b8f4f7981f53b567f1d (patch)
treed485f3cf2d4f6cd168059fa89feaa51a4ff96f01 /openbsd-compat
parent342d6e51589b184c337cccfc4c788b60ff8b3765 (diff)
Only use O_NOFOLLOW in fchownat and fchmodat if defined
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-misc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 3c85a12a..aa1c7d7a 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -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);