Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285033
b: refs/heads/master
c: 25e7570
h: refs/heads/master
i:
  285031: 623200e
v: v3
  • Loading branch information
Eric Paris committed Jan 5, 2012
1 parent 52a9be9 commit e42a184
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 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: 2920a8409de5a51575d03deca07e5bb2be6fc98d
refs/heads/master: 25e75703410a84b80623da3653db6b70282e5c6a
26 changes: 10 additions & 16 deletions trunk/kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,47 +287,41 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data)
}

/**
* has_capability - Does a task have a capability in init_user_ns
* has_ns_capability - Does a task have a capability 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 the initial user namespace, false if not.
* currently in effect to the specified user namespace, false if not.
*
* Note that this does not set PF_SUPERPRIV on the task.
*/
bool has_capability(struct task_struct *t, int cap)
bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap)
{
int ret;

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

return (ret == 0);
}

/**
* has_capability - Does a task have a capability in a specific user ns
* has_capability - Does a task have a capability in init_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 the specified user namespace, false if not.
* currently in effect to the initial user namespace, false if not.
*
* Note that this does not set PF_SUPERPRIV on the task.
*/
bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap)
bool has_capability(struct task_struct *t, int cap)
{
int ret;

rcu_read_lock();
ret = security_capable(__task_cred(t), ns, cap);
rcu_read_unlock();

return (ret == 0);
return has_ns_capability(t, &init_user_ns, cap);
}

/**
Expand Down

0 comments on commit e42a184

Please sign in to comment.