]> git.ipfire.org Git - thirdparty/coreutils.git/commit
maint: port from matchpathcon to selabel_lookup
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Nov 2020 00:59:25 +0000 (16:59 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Nov 2020 02:41:25 +0000 (18:41 -0800)
commit3aaa42deaaf0c63589ddc23df5549d4dedb0c817
treecfdd67ccd30f7a57f0b61fbe4fdfefb980649a67
parent5c8e2716b3f206bc063dcc0b7eb509ecd2804cf5
maint: port from matchpathcon to selabel_lookup

Ubuntu 20.10 is using a newer version of libselinux that
complains that matchpathcon is obsolete.  Rewrite the code
that it uses the recommended selabel_lookup instead.
* m4/jm-macros.m4 (coreutils_MACROS): Do not check for
matchpathcon_init_prefix, as it is no longer used.
* src/copy.c (set_file_security_ctx): Omit process_local arg,
as it is equivalent to !x->set_security_context.  All callers changed.
* src/copy.h (struct cp_options): set_security_context is now of
type struct selabel_handle *, not bool.  All uses changed.
* src/cp.c, src/install.c, src/mkdir.c, src/mkfifo.c, src/mknod.c:
* src/mv.c: Include selinux/label.h.
(main): Use selabel_open for set_security context.
* src/install.c (matchpathcon_init_prefix): Remove; now unused.
(get_labeling_handle): New static function.
(setdefaultfilecon, main): Use it.
(setdefaultfilecon): Do something regardless of
ENABLE_MATCHPATHCON, which seems to be a revenant macro.
(setdefaultfilecon): Use selabel_lookup instead of the obsolescent
matchpathcon.  Report an error unless it fails due to ENOENT.
* src/local.mk (src_ginstall_CPPFLAGS): Remove.
* src/selinux.c: Include selinux/label.h
Do not include die.h, error.h, canonicalize.h.
(defaultcon, restorecon_private, restorecon):
New arg HANDLE.  All callers changed.
Use selabel_lookup rather than matchpathcon.
(restorecon_private, restorecon): Don’t lose track of errno.
* src/selinux.c, src/selinux.h:
(restorecon): Don’t call ‘error’; that’s the caller’s job.
Use HAVE_SELINUX_LABEL_H, not HAVE_SELINUX_SELINUX_H,
in case there is some weird system with the former but not the latter.
* src/selinux.h (struct selinux_handle): Add forward decl.
12 files changed:
m4/jm-macros.m4
src/copy.c
src/copy.h
src/cp.c
src/install.c
src/local.mk
src/mkdir.c
src/mkfifo.c
src/mknod.c
src/mv.c
src/selinux.c
src/selinux.h