Ignore internal use of deprecated interfaces within deprecated interfaces. compute_user.c: In function ‘security_compute_user’: compute_user.c:93:9: error: ‘security_compute_user_raw’ is deprecated: Use get_ordered_context_list(3) family [-Werror=deprecated-declarations] 93 | ret = security_compute_user_raw(rscon, user, con); | ^~~ compute_user.c:13:5: note: declared here 13 | int security_compute_user_raw(const char * scon, | ^~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libselinux/src/compute_user.c | 2 ++ libselinux/src/matchpathcon.c | 11 +++++++++++ libselinux/src/selinux_internal.h | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/libselinux/src/compute_user.c b/libselinux/src/compute_user.c index f55f945a..5f54e16a 100644 --- a/libselinux/src/compute_user.c +++ b/libselinux/src/compute_user.c @@ -96,7 +96,9 @@ int security_compute_user(const char * scon, if (selinux_trans_to_raw_context(scon, &rscon)) return -1; +IGNORE_DEPRECATED_BEGIN ret = security_compute_user_raw(rscon, user, con); +IGNORE_DEPRECATED_END freecon(rscon); if (!ret) { diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c index bf2da083..f4e34df0 100644 --- a/libselinux/src/matchpathcon.c +++ b/libselinux/src/matchpathcon.c @@ -367,7 +367,9 @@ int matchpathcon_init_prefix(const char *path, const char *subset) int matchpathcon_init(const char *path) { +IGNORE_DEPRECATED_BEGIN return matchpathcon_init_prefix(path, NULL); +IGNORE_DEPRECATED_END } void matchpathcon_fini(void) @@ -439,6 +441,8 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con) { char stackpath[PATH_MAX + 1]; char *p = NULL; + +IGNORE_DEPRECATED_BEGIN if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0)) return -1; @@ -450,6 +454,7 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con) if (p) path = p; } +IGNORE_DEPRECATED_END return notrans ? selabel_lookup_raw(hnd, con, path, mode) : @@ -507,8 +512,10 @@ int selinux_file_context_verify(const char *path, mode_t mode) char *p = NULL; if (S_ISLNK(mode)) { +IGNORE_DEPRECATED_BEGIN if (!realpath_not_final(path, stackpath)) path = stackpath; +IGNORE_DEPRECATED_END } else { p = realpath(path, stackpath); if (p) @@ -523,8 +530,10 @@ int selinux_file_context_verify(const char *path, mode_t mode) return 0; } +IGNORE_DEPRECATED_BEGIN if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0)) return -1; +IGNORE_DEPRECATED_END if (selabel_lookup_raw(hnd, &fcontext, path, mode) != 0) { if (errno != ENOENT) @@ -554,8 +563,10 @@ int selinux_lsetfilecon_default(const char *path) if (lstat(path, &st) != 0) return rc; +IGNORE_DEPRECATED_BEGIN if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0)) return -1; +IGNORE_DEPRECATED_END /* If there's an error determining the context, or it has none, return to allow default context */ diff --git a/libselinux/src/selinux_internal.h b/libselinux/src/selinux_internal.h index 06f2c038..583dc205 100644 --- a/libselinux/src/selinux_internal.h +++ b/libselinux/src/selinux_internal.h @@ -94,6 +94,20 @@ extern int selinux_page_size ; extern int has_selinux_config ; +#ifdef __GNUC__ +# define IGNORE_DEPRECATED_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#else +# define IGNORE_DEPRECATED_BEGIN +#endif + +#ifdef __GNUC__ +# define IGNORE_DEPRECATED_END _Pragma("GCC diagnostic pop") +#else +# define IGNORE_DEPRECATED_END +#endif + #ifndef HAVE_STRLCPY size_t strlcpy(char *dest, const char *src, size_t size); #endif -- 2.40.1