Skip to content

Commit 1f32136

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. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20200813012735.GC11663@paquier.xyz
1 parent a9306f1 commit 1f32136

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
@@ -120,7 +120,7 @@ sepgsql_set_client_label(const char *new_label)
120120
tcontext = client_label_peer;
121121
else
122122
{
123-
if (security_check_context_raw((security_context_t) new_label) < 0)
123+
if (security_check_context_raw(new_label) < 0)
124124
ereport(ERROR,
125125
(errcode(ERRCODE_INVALID_NAME),
126126
errmsg("SELinux: invalid security label: \"%s\"",
@@ -453,9 +453,9 @@ sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
453453
object.objectSubId = subId;
454454

455455
label = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG);
456-
if (!label || security_check_context_raw((security_context_t) label))
456+
if (!label || security_check_context_raw(label))
457457
{
458-
security_context_t unlabeled;
458+
char *unlabeled;
459459

460460
if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
461461
ereport(ERROR,
@@ -487,7 +487,7 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
487487
* context of selinux.
488488
*/
489489
if (seclabel &&
490-
security_check_context_raw((security_context_t) seclabel) < 0)
490+
security_check_context_raw(seclabel) < 0)
491491
ereport(ERROR,
492492
(errcode(ERRCODE_INVALID_NAME),
493493
errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
@@ -725,7 +725,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
725725
char *objname;
726726
int objtype = 1234;
727727
ObjectAddress object;
728-
security_context_t context;
728+
char *context;
729729

730730
/*
731731
* 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
@@ -768,8 +768,8 @@ sepgsql_compute_avd(const char *scontext,
768768
* Ask SELinux what is allowed set of permissions on a pair of the
769769
* security contexts and the given object class.
770770
*/
771-
if (security_compute_av_flags_raw((security_context_t) scontext,
772-
(security_context_t) tcontext,
771+
if (security_compute_av_flags_raw(scontext,
772+
tcontext,
773773
tclass_ex, 0, &avd_ex) < 0)
774774
ereport(ERROR,
775775
(errcode(ERRCODE_INTERNAL_ERROR),
@@ -838,7 +838,7 @@ sepgsql_compute_create(const char *scontext,
838838
uint16 tclass,
839839
const char *objname)
840840
{
841-
security_context_t ncontext;
841+
char *ncontext;
842842
security_class_t tclass_ex;
843843
const char *tclass_name;
844844
char *result;
@@ -853,8 +853,8 @@ sepgsql_compute_create(const char *scontext,
853853
* Ask SELinux what is the default context for the given object class on a
854854
* pair of security contexts
855855
*/
856-
if (security_compute_create_name_raw((security_context_t) scontext,
857-
(security_context_t) tcontext,
856+
if (security_compute_create_name_raw(scontext,
857+
tcontext,
858858
tclass_ex,
859859
objname,
860860
&ncontext) < 0)

contrib/sepgsql/uavc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ sepgsql_avc_unlabeled(void)
171171
{
172172
if (!avc_unlabeled)
173173
{
174-
security_context_t unlabeled;
174+
char *unlabeled;
175175

176176
if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
177177
ereport(ERROR,
@@ -216,7 +216,7 @@ sepgsql_avc_compute(const char *scontext, const char *tcontext, uint16 tclass)
216216
* policy is reloaded, validation status shall be kept, so we also cache
217217
* whether the supplied security context was valid, or not.
218218
*/
219-
if (security_check_context_raw((security_context_t) tcontext) != 0)
219+
if (security_check_context_raw(tcontext) != 0)
220220
ucontext = sepgsql_avc_unlabeled();
221221

222222
/*

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