--- capability.c 2003-12-07 17:06:40.228670848 +0800 +++ capability.c.new 2003-12-07 17:06:51.908895184 +0800 @@ -56,6 +56,36 @@ /* flag to keep track of how we were registered */ static int secondary; +static void recompute_capability_creds(struct task_struct *task) +{ + if(task->pid <= 1) + return; + + task_lock(task); + task->keep_capabilities = 0; + + if ((task->uid && task->euid && task->suid) && !task->keep_capabilities) + cap_clear (task->cap_permitted); + else + task->cap_permitted = CAP_INIT_EFF_SET; + + + if (task->euid != 0){ + cap_clear (task->cap_effective); + } + else{ + task->cap_effective = CAP_INIT_EFF_SET; + } + + if(task->fsuid) + task->cap_effective &= ~CAP_FS_MASK; + else + task->cap_effective |= CAP_FS_MASK; + + task_unlock(task); + + return; +} static int __init capability_init (void) { @@ -72,6 +102,15 @@ secondary = 1; } printk (KERN_INFO "Capability LSM initialized\n"); + + struct task_struct *task; + + read_lock(&tasklist_lock); + for_each_process(task){ + recompute_capability_creds(task); + } + read_unlock(&tasklist_lock); + return 0; }