Skip to contentSkip to conversation

libselinux: drop error return from is_selinux_enabled.3

PATCH In review Christian Göttsche 3 participants 8 messages Feb 7, 2020 – Feb 18, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: drop error return from is_selinux_enabled.3

is_selinux_enabled() does never return -1, do not say so in the manpage.

---
 libselinux/man/man3/is_selinux_enabled.3 | 1 -
 1 file changed, 1 deletion(-)
libselinux/man/man3/is_selinux_enabled.3 +0 -1
index df62c225..a887b48c 100644
@@ -15,7 +15,6 @@ is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu
 .SH "DESCRIPTION"
 .BR is_selinux_enabled ()
 returns 1 if SELinux is running or 0 if it is not. 
-On error, \-1 is returned.
 
 .BR is_selinux_mls_enabled ()
 returns 1 if SELinux is capable of running in MLS mode or 0 if it is not. To
Signature · 1 line
2.25.0
#1 lore raw
Quoted 12 lines · Christian Göttsche

is_selinux_enabled() does never return -1, do not say so in the manpage.

---
 libselinux/man/man3/is_selinux_enabled.3 | 1 -
 1 file changed, 1 deletion(-)
libselinux/man/man3/is_selinux_enabled.3 +0 -0
index df62c225..a887b48c 100644

libselinux/man/man3/is_selinux_enabled.3 is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu · line 20

Quoted 7 lines
libselinux/man/man3/is_selinux_enabled.3 +0 -1
@@ -15,7 +15,6 @@ is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu
 .SH "DESCRIPTION"
 .BR is_selinux_enabled ()
 returns 1 if SELinux is running or 0 if it is not. 
-On error, \-1 is returned.
 
 .BR is_selinux_mls_enabled ()
 returns 1 if SELinux is capable of running in MLS mode or 0 if it is not. To

There's also

libselinux/include/selinux/selinux.h:

/* Return 1 if we are running on a SELinux kernel, or 0 if not or -1 if we get an error. */ extern int is_selinux_enabled(void);

Would you mind to update this as well?

Thanks,

Petr

#2 lore raw
Quoted 4 lines · Petr Lautrbach
Quoted 1 line · Christian Göttsche

is_selinux_enabled() does never return -1, do not say so in the manpage.

Just as a historical footnote: it used to be possible that it would return -1 prior to commit e3cab998b48ab293a9962faf9779d70ca339c65d circa release 20120216.

Quoted 34 lines
Quoted 11 lines
---
  libselinux/man/man3/is_selinux_enabled.3 | 1 -
  1 file changed, 1 deletion(-)
libselinux/man/man3/is_selinux_enabled.3 +0 -0
index df62c225..a887b48c 100644

libselinux/man/man3/is_selinux_enabled.3 is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu · line 20

Quoted 7 lines
libselinux/man/man3/is_selinux_enabled.3 +0 -1
@@ -15,7 +15,6 @@ is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu
  .SH "DESCRIPTION"
  .BR is_selinux_enabled ()
  returns 1 if SELinux is running or 0 if it is not.
-On error, \-1 is returned.
 
  .BR is_selinux_mls_enabled ()
  returns 1 if SELinux is capable of running in MLS mode or 0 if it is not. To

There's also

libselinux/include/selinux/selinux.h:

/* Return 1 if we are running on a SELinux kernel, or 0 if not or -1 if we get an error. */ extern int is_selinux_enabled(void);

Would you mind to update this as well?

Thanks,

Petr

#3 lore raw

Am Fr., 7. Feb. 2020 um 18:51 Uhr schrieb Stephen Smalley <[email protected]>:

Quoted 6 lines · Petr Lautrbach
Quoted 4 lines
Quoted 1 line · Christian Göttsche

is_selinux_enabled() does never return -1, do not say so in the manpage.

I am having second thoughts about this:
With the current inaccurate documentation the worst effect are dead error handlers in client code.
But when removed now, after a potential SELinux rework (either kernel or userland) in some years it might be way harder to re-introduce error checking in all client applications.

#4 lore raw
Quoted 6 lines · Christian Göttsche

Am Fr., 7. Feb. 2020 um 18:51 Uhr schrieb Stephen Smalley <[email protected]>:

Quoted 5 lines · Petr Lautrbach
Quoted 3 lines

Christian Göttsche <[email protected]> writes:

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

is_selinux_enabled() does never return -1, do not say so in the manpage.

I am having second thoughts about this:
With the current inaccurate documentation the worst effect are dead error handlers in client code.
But when removed now, after a potential SELinux rework (either kernel or userland) in some years it might be way harder to re-introduce error checking in all client applications.

Looking around at callers via codesearch, I don't see any actual error handlers for is_selinux_enabled() < 0. There is also inconsistent handling of the < 0 case; some code handles it the same as 0 (disabled) while other code handles any non-zero result as selinux-enabled. Probably better to fix the man page and header.

#5 lore raw

PATCH 1/1 libselinux: drop error return from is_selinux_enabled documentation

In reply to Christian Göttsche

Since commit e3cab998b48ab293a9962faf9779d70ca339c65d ("libselinux mountpoint changing patch.") for version 20120216 is_selinux_enabled() does never return -1; drop mentions in the man-page and header file.

---
 libselinux/include/selinux/selinux.h     | 2 +-
 libselinux/man/man3/is_selinux_enabled.3 | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
libselinux/include/selinux/selinux.h +1 -1
index 7922d96b..883d8b85 100644
@@ -8,7 +8,7 @@
 extern "C" {
 #endif
 
-/* Return 1 if we are running on a SELinux kernel, or 0 if not or -1 if we get an error. */
+/* 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);
libselinux/man/man3/is_selinux_enabled.3 +0 -1
index df62c225..a887b48c 100644
@@ -15,7 +15,6 @@ is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu
 .SH "DESCRIPTION"
 .BR is_selinux_enabled ()
 returns 1 if SELinux is running or 0 if it is not. 
-On error, \-1 is returned.
 
 .BR is_selinux_mls_enabled ()
 returns 1 if SELinux is capable of running in MLS mode or 0 if it is not. To
Signature · 1 line
2.25.0
Acked-by on v1 1/1
#6 lore raw

Re: [PATCH] libselinux: drop error return from is_selinux_enabled documentation

Quoted 5 lines · Christian Göttsche

Since commit e3cab998b48ab293a9962faf9779d70ca339c65d ("libselinux mountpoint changing patch.") for version 20120216 is_selinux_enabled() does never return -1; drop mentions in the man-page and header file.

Quoted 31 lines
---
  libselinux/include/selinux/selinux.h     | 2 +-
  libselinux/man/man3/is_selinux_enabled.3 | 1 -
  2 files changed, 1 insertion(+), 2 deletions(-)
libselinux/include/selinux/selinux.h +1 -1
index 7922d96b..883d8b85 100644
@@ -8,7 +8,7 @@
  extern "C" {
  #endif
 
-/* Return 1 if we are running on a SELinux kernel, or 0 if not or -1 if we get an error. */
+/* 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);
libselinux/man/man3/is_selinux_enabled.3 +0 -1
index df62c225..a887b48c 100644
@@ -15,7 +15,6 @@ is_selinux_mls_enabled \- check whether SELinux is enabled for (Multi Level Secu
  .SH "DESCRIPTION"
  .BR is_selinux_enabled ()
  returns 1 if SELinux is running or 0 if it is not.
-On error, \-1 is returned.
 
  .BR is_selinux_mls_enabled ()
  returns 1 if SELinux is capable of running in MLS mode or 0 if it is not. To
#7 lore raw

Re: [PATCH] libselinux: drop error return from is_selinux_enabled documentation

Quoted 8 lines · Stephen Smalley
Quoted 5 lines · Christian Göttsche

Since commit e3cab998b48ab293a9962faf9779d70ca339c65d ("libselinux mountpoint changing patch.") for version 20120216 is_selinux_enabled() does never return -1; drop mentions in the man-page and header file.

Thanks, applied.