]> Savannah Git Hosting - gnulib.git/commit
file-has-acl: new function file_has_aclinfo
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 29 Sep 2024 23:13:53 +0000 (16:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 30 Sep 2024 04:15:40 +0000 (21:15 -0700)
commitccc26add4e1dca76e7a3ded465c94db4064bc20d
treea3e0b3f544db99f3b0866f7dd77cb4ce7a06afc5
parentd72ad55f993bacb65f65244eee7724501120bf67
file-has-acl: new function file_has_aclinfo

This is for GNU coreutils, whose ‘ls’ can be made faster with the
new function because it means (for example) that ‘ls’ needn’t call
both listxattr and lgetxattr in the common case where the file has
no extended attributes.
* lib/acl.h (ACL_SYMLINK_FOLLOW): New constant.
(struct aclinfo): New type.
* lib/file-has-acl.c (UNKNOWN_SECURITY_CONTEXT): New constant.
(USE_LINUX_XATTR): New macro.  When set:
Include stdint.h (for uint32_t).  If also USE_SELINUX_SELINUX_H,
include selinux/selinux.h (for getfilecon).
If HAVE_SMACK, include <sys/smack.h>, otherwise provide substitutes
for smack_smackfs_path and smack_new_label_from_path.
(is_smack_enabled): New function.
(aclinfo_has_xattr): Rename from have_xattr and make it extern.
Use struct aclinfo const * arg instead of char const * and ssize_t.
Work even if ai->size < 0.  Supply a no-op macro on platforms
lacking xattr.
(get_aclinfo): New static function, much of it taken from
coreutils/src/ls.c.
(file_has_aclinfo): New function, which generalizes file_has_acl
to provide more info.  Its body is taken from the old file_has_acl
with new stuff from ls.c.
(file_has_acl): Use it.
(aclinfo_scontext_free, aclinfo_free): Nwew functions, if not
already no-op macros.
* m4/acl.m4 (gl_FUNC_ACL_ARG): Add --without-libsmack option.
(gl_FILE_HAS_ACL): Check for libsmack, selinux.
* m4/selinux-selinux-h.m4 (gl_CHECK_HEADER_SELINUX_SELINUX_H):
New macro, for use by file-has-acl.  Rename HAVE_SELINUX_SELINUX_H
to USE_SELINUX_SELINUX_H to avoid confusion as to whether we have
<selinux/selinux.h>; all uses changed.
(gl_HEADERS_SELINUX_SELINUX_H): Use the new macro.
* modules/file-has-acl (Files): Add m4/selinux-selinux-h.m4.
(Depends-on): Add errno, ssize_t.
* tests/test-file-has-acl.c (main): Add a little test for
file_has_aclinfo.
ChangeLog
lib/acl.h
lib/file-has-acl.c
lib/se-selinux.in.h
m4/acl.m4
m4/selinux-selinux-h.m4
modules/file-has-acl
modules/selinux-h
tests/test-file-has-acl.c