Skip to content

Commit bc7a70e

Browse files
committed
libselinux: ignore internal use of deprecated interfaces
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 <[email protected]>
1 parent e010fa2 commit bc7a70e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

libselinux/src/compute_user.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ int security_compute_user(const char * scon,
9696
if (selinux_trans_to_raw_context(scon, &rscon))
9797
return -1;
9898

99+
IGNORE_DEPRECATED_BEGIN
99100
ret = security_compute_user_raw(rscon, user, con);
101+
IGNORE_DEPRECATED_END
100102

101103
freecon(rscon);
102104
if (!ret) {

libselinux/src/matchpathcon.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ int matchpathcon_init_prefix(const char *path, const char *subset)
367367

368368
int matchpathcon_init(const char *path)
369369
{
370+
IGNORE_DEPRECATED_BEGIN
370371
return matchpathcon_init_prefix(path, NULL);
372+
IGNORE_DEPRECATED_END
371373
}
372374

373375
void matchpathcon_fini(void)
@@ -439,6 +441,8 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con)
439441
{
440442
char stackpath[PATH_MAX + 1];
441443
char *p = NULL;
444+
445+
IGNORE_DEPRECATED_BEGIN
442446
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
443447
return -1;
444448

@@ -450,6 +454,7 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con)
450454
if (p)
451455
path = p;
452456
}
457+
IGNORE_DEPRECATED_END
453458

454459
return notrans ?
455460
selabel_lookup_raw(hnd, con, path, mode) :
@@ -507,8 +512,10 @@ int selinux_file_context_verify(const char *path, mode_t mode)
507512
char *p = NULL;
508513

509514
if (S_ISLNK(mode)) {
515+
IGNORE_DEPRECATED_BEGIN
510516
if (!realpath_not_final(path, stackpath))
511517
path = stackpath;
518+
IGNORE_DEPRECATED_END
512519
} else {
513520
p = realpath(path, stackpath);
514521
if (p)
@@ -523,8 +530,10 @@ int selinux_file_context_verify(const char *path, mode_t mode)
523530
return 0;
524531
}
525532

533+
IGNORE_DEPRECATED_BEGIN
526534
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
527535
return -1;
536+
IGNORE_DEPRECATED_END
528537

529538
if (selabel_lookup_raw(hnd, &fcontext, path, mode) != 0) {
530539
if (errno != ENOENT)
@@ -554,8 +563,10 @@ int selinux_lsetfilecon_default(const char *path)
554563
if (lstat(path, &st) != 0)
555564
return rc;
556565

566+
IGNORE_DEPRECATED_BEGIN
557567
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
558568
return -1;
569+
IGNORE_DEPRECATED_END
559570

560571
/* If there's an error determining the context, or it has none,
561572
return to allow default context */

libselinux/src/selinux_internal.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ extern int selinux_page_size ;
9494

9595
extern int has_selinux_config ;
9696

97+
#ifdef __GNUC__
98+
# define IGNORE_DEPRECATED_BEGIN \
99+
_Pragma("GCC diagnostic push") \
100+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
101+
#else
102+
# define IGNORE_DEPRECATED_BEGIN
103+
#endif
104+
105+
#ifdef __GNUC__
106+
# define IGNORE_DEPRECATED_END _Pragma("GCC diagnostic pop")
107+
#else
108+
# define IGNORE_DEPRECATED_END
109+
#endif
110+
97111
#ifndef HAVE_STRLCPY
98112
size_t strlcpy(char *dest, const char *src, size_t size);
99113
#endif

0 commit comments

Comments
 (0)