Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285034
b: refs/heads/master
c: 7b61d64
h: refs/heads/master
v: v3
  • Loading branch information
Eric Paris committed Jan 5, 2012
1 parent e42a184 commit 7846090
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25e75703410a84b80623da3653db6b70282e5c6a
refs/heads/master: 7b61d648499e74dbec3d4ce645675e0ae040ae78
2 changes: 2 additions & 0 deletions trunk/include/linux/capability.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ extern bool has_capability(struct task_struct *t, int cap);
extern bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap);
extern bool has_capability_noaudit(struct task_struct *t, int cap);
extern bool has_ns_capability_noaudit(struct task_struct *t,
struct user_namespace *ns, int cap);
extern bool capable(int cap);
extern bool ns_capable(struct user_namespace *ns, int cap);
extern bool task_ns_capable(struct task_struct *t, int cap);
Expand Down
30 changes: 25 additions & 5 deletions trunk/kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,47 @@ bool has_capability(struct task_struct *t, int cap)
}

/**
* has_capability_noaudit - Does a task have a capability (unaudited)
* has_ns_capability_noaudit - Does a task have a capability (unaudited)
* in a specific user ns.
* @t: The task in question
* @ns: target user namespace
* @cap: The capability to be tested for
*
* Return true if the specified task has the given superior capability
* currently in effect to init_user_ns, false if not. Don't write an
* audit message for the check.
* currently in effect to the specified user namespace, false if not.
* Do not write an audit message for the check.
*
* Note that this does not set PF_SUPERPRIV on the task.
*/
bool has_capability_noaudit(struct task_struct *t, int cap)
bool has_ns_capability_noaudit(struct task_struct *t,
struct user_namespace *ns, int cap)
{
int ret;

rcu_read_lock();
ret = security_capable_noaudit(__task_cred(t), &init_user_ns, cap);
ret = security_capable_noaudit(__task_cred(t), ns, cap);
rcu_read_unlock();

return (ret == 0);
}

/**
* has_capability_noaudit - Does a task have a capability (unaudited) in the
* initial user ns
* @t: The task in question
* @cap: The capability to be tested for
*
* Return true if the specified task has the given superior capability
* currently in effect to init_user_ns, false if not. Don't write an
* audit message for the check.
*
* Note that this does not set PF_SUPERPRIV on the task.
*/
bool has_capability_noaudit(struct task_struct *t, int cap)
{
return has_ns_capability_noaudit(t, &init_user_ns, cap);
}

/**
* capable - Determine if the current task has a superior capability in effect
* @cap: The capability to be tested for
Expand Down

0 comments on commit 7846090

Please sign in to comment.