From: William Roberts <william.c.roberts@xxxxxxxxx> Not that the matchpathcon library interfaces are deprecated, matchpathcon needs to use the 2 variants and statically link. Signed-off-by: William Roberts <william.c.roberts@xxxxxxxxx> --- libselinux/src/matchpathcon.c | 6 +++++- libselinux/src/matchpathcon_internal.h | 2 ++ libselinux/utils/Makefile | 6 ++++++ libselinux/utils/matchpathcon.c | 9 ++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c index 88539e627f5d..d71e792c3f8e 100644 --- a/libselinux/src/matchpathcon.c +++ b/libselinux/src/matchpathcon.c @@ -352,10 +352,14 @@ int matchpathcon_init_prefix(const char *path, const char *subset) return hnd ? 0 : -1; } +int matchpathcon_init2(const char *path) +{ + return matchpathcon_init_prefix(path, NULL); +} int matchpathcon_init(const char *path) { - return matchpathcon_init_prefix(path, NULL); + return matchpathcon_init2(path); } void matchpathcon_fini2(void) diff --git a/libselinux/src/matchpathcon_internal.h b/libselinux/src/matchpathcon_internal.h index c63bcecfec89..73f0c78fc9d0 100644 --- a/libselinux/src/matchpathcon_internal.h +++ b/libselinux/src/matchpathcon_internal.h @@ -1,6 +1,8 @@ #ifndef SRC_MATCHPATHCON_INTERNAL_H_ #define SRC_MATCHPATHCON_INTERNAL_H_ +int matchpathcon_init2(const char *path); + void matchpathcon_fini2(void); int matchpathcon2(const char *path, mode_t mode, char ** con); diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile index a5632b7c38ec..5f16ab957610 100644 --- a/libselinux/utils/Makefile +++ b/libselinux/utils/Makefile @@ -58,6 +58,12 @@ sefcontext_compile: LDLIBS += $(PCRE_LDLIBS) ../src/libselinux.a -lsepol sefcontext_compile: sefcontext_compile.o ../src/regex.o +matchpathcon: LDLIBS += $(PCRE_LDLIBS) ../src/libselinux.a + +matchpathcon: CFLAGS += -I../src + +matchpathcon: matchpathcon.o ../src/regex.o + all: $(TARGETS) install: all diff --git a/libselinux/utils/matchpathcon.c b/libselinux/utils/matchpathcon.c index eb39a1881066..3d94af365071 100644 --- a/libselinux/utils/matchpathcon.c +++ b/libselinux/utils/matchpathcon.c @@ -11,6 +11,9 @@ #include <limits.h> #include <stdlib.h> +#include "matchpathcon_internal.h" + + static __attribute__ ((__noreturn__)) void usage(const char *progname) { fprintf(stderr, @@ -22,7 +25,7 @@ static __attribute__ ((__noreturn__)) void usage(const char *progname) static int printmatchpathcon(const char *path, int header, int mode) { char *buf; - int rc = matchpathcon(path, mode, &buf); + int rc = matchpathcon2(path, mode, &buf); if (rc < 0) { if (errno == ENOENT) { buf = strdup("<<none>>"); @@ -103,7 +106,7 @@ int main(int argc, char **argv) exit(1); } init = 1; - if (matchpathcon_init(optarg)) { + if (matchpathcon_init2(optarg)) { fprintf(stderr, "Error while processing %s: %s\n", optarg, @@ -195,6 +198,6 @@ int main(int argc, char **argv) error |= printmatchpathcon(path, header, mode); } } - matchpathcon_fini(); + matchpathcon_fini2(); return error; } -- 2.17.1