Skip to content

Commit 312b725

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 06efe1c commit 312b725

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
@@ -370,7 +370,9 @@ int matchpathcon_init_prefix(const char *path, const char *subset)
370370

371371
int matchpathcon_init(const char *path)
372372
{
373+
IGNORE_DEPRECATED_BEGIN
373374
return matchpathcon_init_prefix(path, NULL);
375+
IGNORE_DEPRECATED_END
374376
}
375377

376378
void matchpathcon_fini(void)
@@ -442,6 +444,8 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con)
442444
{
443445
char stackpath[PATH_MAX + 1];
444446
char *p = NULL;
447+
448+
IGNORE_DEPRECATED_BEGIN
445449
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
446450
return -1;
447451

@@ -453,6 +457,7 @@ static int matchpathcon_internal(const char *path, mode_t mode, char ** con)
453457
if (p)
454458
path = p;
455459
}
460+
IGNORE_DEPRECATED_END
456461

457462
return notrans ?
458463
selabel_lookup_raw(hnd, con, path, mode) :
@@ -510,8 +515,10 @@ int selinux_file_context_verify(const char *path, mode_t mode)
510515
char *p = NULL;
511516

512517
if (S_ISLNK(mode)) {
518+
IGNORE_DEPRECATED_BEGIN
513519
if (!realpath_not_final(path, stackpath))
514520
path = stackpath;
521+
IGNORE_DEPRECATED_END
515522
} else {
516523
p = realpath(path, stackpath);
517524
if (p)
@@ -526,8 +533,10 @@ int selinux_file_context_verify(const char *path, mode_t mode)
526533
return 0;
527534
}
528535

536+
IGNORE_DEPRECATED_BEGIN
529537
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
530538
return -1;
539+
IGNORE_DEPRECATED_END
531540

532541
if (selabel_lookup_raw(hnd, &fcontext, path, mode) != 0) {
533542
if (errno != ENOENT)
@@ -557,8 +566,10 @@ int selinux_lsetfilecon_default(const char *path)
557566
if (lstat(path, &st) != 0)
558567
return rc;
559568

569+
IGNORE_DEPRECATED_BEGIN
560570
if (!hnd && (matchpathcon_init_prefix(NULL, NULL) < 0))
561571
return -1;
572+
IGNORE_DEPRECATED_END
562573

563574
/* If there's an error determining the context, or it has none,
564575
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)