Skip to contentSkip to conversation

libselinux: 0/2 Refactor Handling of /proc/pid/attr/*

PATCH New Eric Paris 1 participant 1 message Jun 26, 2006 SELinux security module

lore
Share & tools
lore

Eric Paris

author
#0 lore raw

PATCH 1/1 libselinux: 0/2 Refactor Handling of /proc/pid/attr/*

The follow patch set will rework libselinux to now include generic get and set functions for reading and writing contexts to the interfaces found in /proc/pid/attr/ The individual libselinux calls will tell the generic function the path to the attr along with the context information.

Patch 1/2: Introduce {get,set}procattrcon - These are the 2 functions that will actually do the work of reading and writing. reads and writes are now wrapped in do{}while (ret < 1 && errno == EINTR) to stop early unneeded failure (suggested by steve g) errno is now saved across close(fd) in both get and set to make sure that read/write errors are propagated back up the stack rather than close errno which we don't check anyway (suggested by james antill). get still uses strdup since the malloc is a whole page and leaving that much space unused is just wasteful (mentioned by steve g).

Patch 2/2: Convert old users to new generic function -{get,set}fscreatecon()
-{get,set}execcon()
-{get,set}con() the old setcon() had a special check for attempting to write null and would fail with -1; From my testing this is the same thing that happens if you actually try to write null to
the /proc/self/attr/current file so special casing this was not needed. -getpidcon()
-getprevcon()

Eric

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.