All of lore.kernel.org
 help / color / mirror / Atom feed
* PythonSELinux binding problem
@ 2011-07-21 21:33 rarob
  2011-07-22 13:44 ` Stephen Smalley
  2011-07-22 13:46 ` Daniel J Walsh
  0 siblings, 2 replies; 4+ messages in thread
From: rarob @ 2011-07-21 21:33 UTC (permalink / raw)
  To: selinux

Hi,
  I'm using the python selinux bindings to determine if SELinux is
disable/permissive/enforcing.  The following snippet of code works just
fine on RH5 and F10 regardless of the SELinux mode, but fails with an
error on F11/12/13 and RH6 if SELinux is disabled.

$ python -c 'import selinux ; print selinux.security_getenforce()'

Under RH5 and F10 I correctly get the -1/0/1 returns for
disabled/permissive/enforcing, as specified in the man pages for
'security_getenforce'.  Under F11/12/13 and RH6 for permissive and
enforcing I get the correct return values, but if the system is in
disabled mode instead an OSError is thrown for 'No such file or
directory'.  I haven't look at the source for the underlying
security_getenforce() system call, but I suspect is is assuming that the
/selinux pseudo filesystem is populated (as in permissive/enforcing mode),
and is not handling the case where that pseudo filesystem is empty.

For now I've got my python calls wrapped in try/except blocks treating any
exception as SELinux in disabled mode.

I wasn't sure where the best place to log this as a bug is, either for the
libselinux-python package or libselinux itself.

-Rob



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-22 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-21 21:33 PythonSELinux binding problem rarob
2011-07-22 13:44 ` Stephen Smalley
2011-07-22 14:00   ` Eric Paris
2011-07-22 13:46 ` Daniel J Walsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.