Export selinux_string_to_sid from SELinux (fwd)
Subsystems (2)
RFC 2/8 Export selinux_string_to_sid from SELinux (fwd)
---------- Forwarded message ----------
Date: Sun, 7 May 2006 11:34:17 -0400 (EDT)
From: James Morris <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Stephen Smalley <[email protected]>, Daniel J Walsh <[email protected]>
Subject: [RFC][SECMARK 02/08] Export selinux_string_to_sid from SELinux
This patch exports adds a new function to the in-kernel SELinux API: selinux_string_to_sid(). It maps a text security context to an SELiux security ID (SID).
Signed-off-by James Morris <[email protected]>
---
include/linux/selinux.h | 16 ++++++++++++++++ security/selinux/exports.c | 11 +++++++++++ 2 files changed, 27 insertions(+)
include/linux/selinux.h +16 -0
@@ -118,6 +118,16 @@ void selinux_get_ipc_sid(const struct ke*/ void selinux_get_task_sid (struct task_struct *tsk,u32 *sid); +/** +* selinux_string_to_sid - map a security context string to a security ID +* @str: the security context string to be mapped +* @sid: ID value returned via this. +* +* Returns 0 if successful, with the SID stored in sid. A value +* of zero for sid indicates no SID could be determined (but no error +* occurred). +*/ +int selinux_string_to_sid (char *str,u32 *sid);#else
@@ -172,6 +182,12 @@ static inline void selinux_get_task_sid( *sid =0 ; } +static inline int selinux_string_to_sid (const char *str,u32 *sid) +{ + *sid =0 ; +return 0 ; +} +#endif /* CONFIG_SECURITY_SELINUX */ #endif /* _LINUX_SELINUX_H */
security/selinux/exports.c +11 -0
@@ -72,3 +72,14 @@ void selinux_get_task_sid(struct task_st *sid =0 ; } +int selinux_string_to_sid (char *str,u32 *sid) +{ +if (selinux_enabled) +return security_context_to_sid (str,strlen (str), sid); +else { + *sid =0 ; +return 0 ; + } +} +EXPORT_SYMBOL_GPL (selinux_string_to_sid); +