diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2016-08-23 23:19:49 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2016-08-23 23:25:38 +0200 |
commit | 38f32ea1865bcc44185f4118fde469cb962cff68 (patch) | |
tree | 6004ed163b751e1a9089f0fe1b603ef21bebbcab | |
parent | ea3c6bb711e76d91759f8bf5475e1900362a3142 (diff) | |
download | acl-38f32ea1865bcc44185f4118fde469cb962cff68.tar.gz |
setfacl: Preserve special mode bits on filesystems without POSIX ACL support
When the ACL to be set is equivalent to a file mode, on filesystems
without POSIX ACL support, setfacl falls back to chmod(1) for setting
the file mode to the equivalent of the ACL.
Unfortunately it did not preserve the set-user-ID, set-group-ID, and
sticky bits in that case; fix that.
-rwxr-xr-x | test/runwrapper | 1 | ||||
-rw-r--r-- | tools/do_set.c | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/test/runwrapper b/test/runwrapper index 38de337..8281a15 100755 --- a/test/runwrapper +++ b/test/runwrapper @@ -1,4 +1,5 @@ #!/bin/bash + if [ -e "$PWD/.libs/libtestlookup.so" ]; then export LD_PRELOAD="$PWD/.libs/libtestlookup.so" fi diff --git a/tools/do_set.c b/tools/do_set.c index 60da837..ecde210 100644 --- a/tools/do_set.c +++ b/tools/do_set.c @@ -478,8 +478,15 @@ do_set( if (errno == ENOSYS || errno == ENOTSUP) { if (equiv_mode != 0) goto fail; - else if (chmod(path_p, mode) != 0) - goto fail; + else { + struct stat st; + + if (stat(path_p, &st) != 0) + goto fail; + mode |= st.st_mode & 07000; + if (chmod(path_p, mode) != 0) + goto fail; + } } else goto fail; } |