Skip to contentSkip to conversation

libselinux: mark security_context_t typedef as deprecated

PATCH Superseded Christian Göttsche 4 participants 7 messages Apr 20, 2020 – May 1, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: mark security_context_t typedef as deprecated

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

Use a wrapper macro, because swig does not accept typedef attributes.

---
 libselinux/include/selinux/selinux.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
libselinux/include/selinux/selinux.h +9 -1
index 6a512b38..f88a0363 100644
@@ -8,13 +8,21 @@
 extern "C" {
 #endif
 
+#ifndef _selinux_deprecated
+#ifdef __GNUC__
+#define _selinux_deprecated __attribute__ ((deprecated))
+#else
+#define _selinux_deprecated
+#endif
+#endif
+
 /* Return 1 if we are running on a SELinux kernel, or 0 otherwise. */
 extern int is_selinux_enabled(void);
 /* Return 1 if we are running on a SELinux MLS kernel, or 0 otherwise. */
 extern int is_selinux_mls_enabled(void);
 
 /* No longer used; here for compatibility with legacy callers. */
-typedef char *security_context_t;
+typedef char *security_context_t _selinux_deprecated;
 
 /* Free the memory allocated for a context by any of the below get* calls. */
 extern void freecon(char * con);
Signature · 1 line
2.26.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian Göttsche

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

Use a wrapper macro, because swig does not accept typedef attributes.

If nobody raises an objection, I will merge the patch tomorrow.

Thanks,
Nicolas

Quoted 34 lines
---
 libselinux/include/selinux/selinux.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
libselinux/include/selinux/selinux.h +9 -2
index 6a512b38..f88a0363 100644
@@ -8,13 +8,21 @@
 extern "C" {
 #endif
 
+#ifndef _selinux_deprecated
+#ifdef __GNUC__
+#define _selinux_deprecated __attribute__ ((deprecated))
+#else
+#define _selinux_deprecated
+#endif
+#endif
+
 /* Return 1 if we are running on a SELinux kernel, or 0 otherwise. */
 extern int is_selinux_enabled(void);
 /* Return 1 if we are running on a SELinux MLS kernel, or 0 otherwise. */
 extern int is_selinux_mls_enabled(void);
 
 /* No longer used; here for compatibility with legacy callers. */
-typedef char *security_context_t;
+typedef char *security_context_t _selinux_deprecated;
 
 /* Free the memory allocated for a context by any of the below get* calls. */
 extern void freecon(char * con);
--

2.26.1

#2 lore raw

Am So., 26. Apr. 2020 um 20:14 Uhr schrieb Nicolas Iooss <[email protected]>:

Quoted 6 lines
Quoted 3 lines · Christian Göttsche

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

Quoted 7 lines
Quoted 3 lines

Use a wrapper macro, because swig does not accept typedef attributes.

If nobody raises an objection, I will merge the patch tomorrow.

Maybe this should be delayed after the deprecation patch series from William Roberts to match the same style;
e.g. this patch uses a helper macro.

I'll prepare an updated patch.

#3 lore raw
Quoted 15 lines · Christian Göttsche

Am So., 26. Apr. 2020 um 20:14 Uhr schrieb Nicolas Iooss <[email protected]>:

Quoted 12 lines
Quoted 6 lines · Christian Göttsche

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

Use a wrapper macro, because swig does not accept typedef attributes.

Quoted 7 lines
Quoted 1 line

If nobody raises an objection, I will merge the patch tomorrow.

Maybe this should be delayed after the deprecation patch series from William Roberts to match the same style;
e.g. this patch uses a helper macro.

I'll prepare an updated patch.

I was just about to look at this and suggest the same thing. I didn't put a macro like this in selinux.h for the simple
reason that I didn't want to make it something considered public API. I avoided if SWIG, since its really
a gnuc extension that most compilers support, and its inline with the other extensions that get buy the
SWIG build.

I would nack it for those two reasons.

I just sent V4 of the series, so hopefully that one sticks. If you wan't you can update the style now and resubmit. As we can merge it in parallel to my series (there is no hard dependency), so you don't have to wait for my series to land.

#4 lore raw

PATCH v2 1/1 libselinux: mark security_context_t typedef as deprecated

In reply to Christian Göttsche

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

---
v2: use the common deprecation style

 libselinux/include/selinux/selinux.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
libselinux/include/selinux/selinux.h +5 -1
index aaf28ffd..c22834e5 100644
@@ -14,7 +14,11 @@ extern int is_selinux_enabled(void);
 extern int is_selinux_mls_enabled(void);
 
 /* No longer used; here for compatibility with legacy callers. */
-typedef char *security_context_t;
+typedef char *security_context_t
+#ifdef __GNUC__
+__attribute__ ((deprecated))
+#endif
+;
 
 /* Free the memory allocated for a context by any of the below get* calls. */
 extern void freecon(char * con);
Signature · 1 line
2.26.2
Acked-by on v2 1/1
#5 lore raw
Quoted 34 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christian Göttsche
Sent: Thursday, April 30, 2020 10:03 AM
To: [email protected]
Subject: [PATCH v2] libselinux: mark security_context_t typedef as deprecated

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

---
v2: use the common deprecation style

 libselinux/include/selinux/selinux.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
libselinux/include/selinux/selinux.h +5 -0
index aaf28ffd..c22834e5 100644
@@ -14,7 +14,11 @@ extern int is_selinux_enabled(void);  extern int
 is_selinux_mls_enabled(void);
 
 /* No longer used; here for compatibility with legacy callers. */ -typedef char
 *security_context_t;
+typedef char *security_context_t
+#ifdef __GNUC__
+__attribute__ ((deprecated))
+#endif
+;
 
 /* Free the memory allocated for a context by any of the below get* calls. */
Quoted 3 lines

extern void freecon(char * con);
--
2.26.2

#6 lore raw
Quoted 33 lines
Quoted 33 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christian Göttsche
Sent: Thursday, April 30, 2020 10:03 AM
To: [email protected]
Subject: [PATCH v2] libselinux: mark security_context_t typedef as deprecated

Follow-up of: 9eb9c9327563014ad6a807814e7975424642d5b9 ("Get rid of security_context_t and fix const declarations.")

---
v2: use the common deprecation style

 libselinux/include/selinux/selinux.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
libselinux/include/selinux/selinux.h +5 -0
index aaf28ffd..c22834e5 100644
@@ -14,7 +14,11 @@ extern int is_selinux_enabled(void);  extern int
 is_selinux_mls_enabled(void);
 
 /* No longer used; here for compatibility with legacy callers. */ -typedef char
 *security_context_t;
+typedef char *security_context_t
+#ifdef __GNUC__
+__attribute__ ((deprecated))
+#endif
+;
 
Quoted 6 lines
Quoted 4 lines
libselinux/include/selinux/selinux.h +0 -0
 /* Free the memory allocated for a context by any of the below get* calls. */

extern void freecon(char * con);
--
2.26.2

Merged:
https://github.com/SELinuxProject/selinux/pull/233

Thanks