Skip to contentSkip to conversation

selinux programming: security_get_sids

DISCUSSION Carsten Grohmann 2 participants 2 messages Apr 23, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

is it possible to call security_get_sids and others with nel=0? Thus I could allocate the necessary memory without to check to less memory and call realloc.

Carsten

--
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.

#1 lore raw
Quoted 5 lines · Carsten Grohmann

Hi,

is it possible to call security_get_sids and others with nel=0? Thus I could allocate the necessary memory without to check to less memory and call realloc.

Yes, you can call security_get_sids with nel=0, and likewise for other calls that return variable length data (e.g. security_sid_to_context), in which case they will set the nel or len to the necessary value, set errno to ENOSPC and return -1. However, we typically allocate an initial buffer and pass its length on the initial call, then realloc and call again if that fails, so that in the common case, only a single call is necessary.

Please note that the API is being significantly changed for mainline 2.5, and that SIDs are no longer exported to userspace. The new process attribute API (/proc/pid/attr) and file attribute API ([gs]etxattr) pass security contexts directly, as does the new policy API (selinuxfs).

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
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.