While browsing Linux kernel code, I found the following two functions in kernel/capability.c
.
1)
bool has_capability(struct task_struct *t, int cap)
/*Does a task have a capability in init_user_ns.*/
2)
bool has_ns_capability(struct task_struct *t, struct user_namespace *ns, int cap)
/*Does a task have a capability in a specific user ns.*/
What is the init_user
namespace mentioned in the first function?
From what I know, a process either has a capability (let us not worry about the different capability sets of a process for now), or it doesn't, so how can a process be said to have a capability with respect to a namespace?
If you look at the definition of cap_get_target_pid()
, in the same file, it just talks about getting capabilities of a process with the given pid, without worrying about the user namespace. This looks more natural to me.