Skip to content

Commit 0f5812d

Browse files
committed
Fix compilation warnings with libselinux 3.1 in contrib/sepgsql/
Upstream SELinux has recently marked security_context_t as officially deprecated, causing warnings with -Wdeprecated-declarations. This is considered as legacy code for some time now by upstream as security_context_t got removed from most of the code tree during the development of 2.3 back in 2014. This removes all the references to security_context_t in sepgsql/ to be consistent with SELinux, fixing the warnings. Note that this does not impact the minimum version of libselinux supported. This has been applied first as 1f32136 for 14~, but no other branches got the call. This is in line with the recent project policy to have no warnings in branches where builds should still be supported (9.2~ as of today). Per discussion with Tom Lane and Álvaro Herrera. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20200813012735.GC11663@paquier.xyz Discussion: https://postgr.es/m/20221103181028.raqta27jcuypor4l@alvherre.pgsql Backpatch-through: 9.2
1 parent 57dfb6c commit 0f5812d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

contrib/sepgsql/label.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ sepgsql_set_client_label(const char *new_label)
130130
tcontext = client_label_peer;
131131
else
132132
{
133-
if (security_check_context_raw((security_context_t) new_label) < 0)
133+
if (security_check_context_raw(new_label) < 0)
134134
ereport(ERROR,
135135
(errcode(ERRCODE_INVALID_NAME),
136136
errmsg("SELinux: invalid security label: \"%s\"",
@@ -470,9 +470,9 @@ sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
470470
object.objectSubId = subId;
471471

472472
label = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG);
473-
if (!label || security_check_context_raw((security_context_t) label))
473+
if (!label || security_check_context_raw(label))
474474
{
475-
security_context_t unlabeled;
475+
char *unlabeled;
476476

477477
if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
478478
ereport(ERROR,
@@ -507,7 +507,7 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
507507
* context of selinux.
508508
*/
509509
if (seclabel &&
510-
security_check_context_raw((security_context_t) seclabel) < 0)
510+
security_check_context_raw(seclabel) < 0)
511511
ereport(ERROR,
512512
(errcode(ERRCODE_INVALID_NAME),
513513
errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
@@ -746,7 +746,7 @@ exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId)
746746
char *objname;
747747
int objtype = 1234;
748748
ObjectAddress object;
749-
security_context_t context;
749+
char *context;
750750

751751
/*
752752
* The way to determine object name depends on object classes. So, any

contrib/sepgsql/selinux.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ sepgsql_compute_avd(const char *scontext,
767767
* Ask SELinux what is allowed set of permissions on a pair of the
768768
* security contexts and the given object class.
769769
*/
770-
if (security_compute_av_flags_raw((security_context_t) scontext,
771-
(security_context_t) tcontext,
770+
if (security_compute_av_flags_raw(scontext,
771+
tcontext,
772772
tclass_ex, 0, &avd_ex) < 0)
773773
ereport(ERROR,
774774
(errcode(ERRCODE_INTERNAL_ERROR),
@@ -839,7 +839,7 @@ sepgsql_compute_create(const char *scontext,
839839
uint16 tclass,
840840
const char *objname)
841841
{
842-
security_context_t ncontext;
842+
char *ncontext;
843843
security_class_t tclass_ex;
844844
const char *tclass_name;
845845
char *result;
@@ -854,8 +854,8 @@ sepgsql_compute_create(const char *scontext,
854854
* Ask SELinux what is the default context for the given object class on a
855855
* pair of security contexts
856856
*/
857-
if (security_compute_create_name_raw((security_context_t) scontext,
858-
(security_context_t) tcontext,
857+
if (security_compute_create_name_raw(scontext,
858+
tcontext,
859859
tclass_ex,
860860
objname,
861861
&ncontext) < 0)

contrib/sepgsql/uavc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ sepgsql_avc_unlabeled(void)
177177
{
178178
if (!avc_unlabeled)
179179
{
180-
security_context_t unlabeled;
180+
char *unlabeled;
181181

182182
if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
183183
ereport(ERROR,
@@ -225,7 +225,7 @@ sepgsql_avc_compute(const char *scontext, const char *tcontext, uint16 tclass)
225225
* policy is reloaded, validation status shall be kept, so we also cache
226226
* whether the supplied security context was valid, or not.
227227
*/
228-
if (security_check_context_raw((security_context_t) tcontext) != 0)
228+
if (security_check_context_raw(tcontext) != 0)
229229
ucontext = sepgsql_avc_unlabeled();
230230

231231
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy