X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstat%2Ffchmodat.c;h=d94667aed5e1a4aa1e924bd89a8ba3aa3ec6aa16;hb=71392a91c333d47b6b3c8f99c897e3b5a7eb6d58;hp=afa6d44b5401da8caec81c3cb78dea9b344b4748;hpb=dd5f50da6f6c3df5647e922e47f8568a8896a752;p=musl diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c index afa6d44b..d94667ae 100644 --- a/src/stat/fchmodat.c +++ b/src/stat/fchmodat.c @@ -21,7 +21,7 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) if (S_ISLNK(st.st_mode)) return __syscall_ret(-EOPNOTSUPP); - if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY)) < 0) { + if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC)) < 0) { if (fd2 == -ELOOP) return __syscall_ret(-EOPNOTSUPP); return __syscall_ret(fd2); @@ -29,8 +29,10 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) __procfdname(proc, fd2); ret = __syscall(SYS_fstatat, AT_FDCWD, proc, &st, 0); - if (!ret && !S_ISLNK(st.st_mode)) - ret = __syscall(SYS_fchmodat, AT_FDCWD, proc, mode); + if (!ret) { + if (S_ISLNK(st.st_mode)) ret = -EOPNOTSUPP; + else ret = __syscall(SYS_fchmodat, AT_FDCWD, proc, mode); + } __syscall(SYS_close, fd2); return __syscall_ret(ret);