]> Savannah Git Hosting - gnulib.git/commit
qacl: Reimplement qset_acl and qcopy_acl (Bug#20666)
authorAndreas Gruenbacher <andreas.gruenbacher@gmail.com>
Sat, 11 Apr 2015 12:44:30 +0000 (14:44 +0200)
committerAndreas Gruenbacher <andreas.gruenbacher@gmail.com>
Wed, 27 May 2015 21:37:53 +0000 (23:37 +0200)
commit2d5ce445d63109b3999402effbc6f8c1db4e8920
tree3307f3e46478ede63f2fe05fff4a3270ca8fd5f2
parentf1b37e3afb1ba17be1c11012f86ff14e5cc357af
qacl: Reimplement qset_acl and qcopy_acl (Bug#20666)

Implement get_permissions and set_permissions primitives for getting all
the permissions of a file, storing them, and later setting them. (In the
minimal case, the permissions consist only of a file mode.) Reimplement
qset_acl and qcopy_acl based on these new primitives: this avoids code
duplication and makes error handling more consistent.

The Solaris and Cygwin code still uses duplicate code paths for setting
a file mode while making sure that no acls exist and setting an explicit
acl; this is no worse than before, but could be cleaned up.  The AIX
code still doesn't read ACLs, it only makes sure that acls don't get in
the way when setting a file mode.

* lib/acl-internal.h (struct permission_context): New data structure.
(get_permissions, set_permissions, free_permission_context): Declare.
* lib/acl-internal.c (free_permission_context): New helper function.
* lib/get-permissions.c (get_permissions): New helper function split off
from qcopy_acl.
* lib/set-permissions.c: (set_acls_from_mode): On Solaris, Cygwin, and
AIX, set a file's permissions based only on a file mode.
(acl_from_mode, context_acl_from_mode, context_aclv_from_mode): All
other platforms construct a temporary acl from the file mode and set
that acl in the same way as setting an acl read from the source file.
This should help avoid code duplication and inconsistent / buggy
behavior.
(set_acls): New helper function Split off from qcopy_acl.
(chmod_or_fchmod): Moved here from qset-acl.c.
(set_permissions): New helper function.
* lib/qcopy-acl.c (qcopy_acl): Rewrite using get_permissions and
set_permissions.
* lib/qset-acl.c (qset_acl): Rewrite using set_permissions.
* modules/qacl: Add get-permissions.c and set-permissions.c.
ChangeLog
lib/acl-internal.c
lib/acl-internal.h
lib/get-permissions.c [new file with mode: 0644]
lib/qcopy-acl.c
lib/qset-acl.c
lib/set-permissions.c [new file with mode: 0644]
modules/qacl