Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 27553
b: refs/heads/master
c: c749b29
h: refs/heads/master
i:
  27551: 3237c9b
v: v3
  • Loading branch information
James Morris authored and David S. Miller committed Jun 18, 2006
1 parent 6fc0ada commit c3e230d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 29a395eac4c320c570e73f0a90d8953d80da8359
refs/heads/master: c749b29fae74ed59c507d84025b3298202b42609
32 changes: 32 additions & 0 deletions trunk/include/linux/selinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ void selinux_get_ipc_sid(const struct kern_ipc_perm *ipcp, u32 *sid);
*/
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);

/**
* selinux_relabel_packet_permission - check permission to relabel a packet
* @sid: ID value to be applied to network packet (via SECMARK, most likely)
*
* Returns 0 if the current task is allowed to label packets with the
* supplied security ID. Note that it is implicit that the packet is always
* being relabeled from the default unlabled value, and that the access
* control decision is made in the AVC.
*/
int selinux_relabel_packet_permission(u32 sid);

#else

Expand Down Expand Up @@ -172,6 +193,17 @@ static inline void selinux_get_task_sid(struct task_struct *tsk, u32 *sid)
*sid = 0;
}

static inline int selinux_string_to_sid(const char *str, u32 *sid)
{
*sid = 0;
return 0;
}

static inline int selinux_relabel_packet_permission(u32 sid)
{
return 0;
}

#endif /* CONFIG_SECURITY_SELINUX */

#endif /* _LINUX_SELINUX_H */
22 changes: 22 additions & 0 deletions trunk/security/selinux/exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,25 @@ void selinux_get_task_sid(struct task_struct *tsk, u32 *sid)
*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);

int selinux_relabel_packet_permission(u32 sid)
{
if (selinux_enabled) {
struct task_security_struct *tsec = current->security;

return avc_has_perm(tsec->sid, sid, SECCLASS_PACKET,
PACKET__RELABELTO, NULL);
}
return 0;
}
EXPORT_SYMBOL_GPL(selinux_relabel_packet_permission);

0 comments on commit c3e230d

Please sign in to comment.