Only use O_NOFOLLOW in fchownat and fchmodat if defined
This commit is contained in:
parent
342d6e5158
commit
43f47ebbdd
|
@ -174,8 +174,10 @@ fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag)
|
||||||
# ifndef HAVE_FCHOWN
|
# ifndef HAVE_FCHOWN
|
||||||
return chown(pathname, owner, group);
|
return chown(pathname, owner, group);
|
||||||
# else
|
# else
|
||||||
|
# ifdef O_NOFOLLOW
|
||||||
if (flag & AT_SYMLINK_NOFOLLOW)
|
if (flag & AT_SYMLINK_NOFOLLOW)
|
||||||
oflags |= O_NOFOLLOW;
|
oflags |= O_NOFOLLOW;
|
||||||
|
# endif /* O_NOFOLLOW */
|
||||||
if ((fd = open(path, oflags)) == -1)
|
if ((fd = open(path, oflags)) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
ret = fchown(fd, owner, group);
|
ret = fchown(fd, owner, group);
|
||||||
|
@ -203,8 +205,10 @@ fchmodat(int fd, const char *path, mode_t mode, int flag)
|
||||||
# ifndef HAVE_FCHMOD
|
# ifndef HAVE_FCHMOD
|
||||||
return chown(pathname, owner, group);
|
return chown(pathname, owner, group);
|
||||||
# else
|
# else
|
||||||
|
# ifdef O_NOFOLLOW
|
||||||
if (flag & AT_SYMLINK_NOFOLLOW)
|
if (flag & AT_SYMLINK_NOFOLLOW)
|
||||||
oflags |= O_NOFOLLOW;
|
oflags |= O_NOFOLLOW;
|
||||||
|
# endif /* O_NOFOLLOW */
|
||||||
if ((fd = open(path, oflags)) == -1)
|
if ((fd = open(path, oflags)) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
ret = fchmod(fd, mode);
|
ret = fchmod(fd, mode);
|
||||||
|
|
Loading…
Reference in New Issue