syscall: sys_promote

From: Coywolf Qi Hunt
Date: Fri Aug 26 2005 - 04:26:49 EST


Hello,

I just wrote a tool with kernel patch, which is to set the uid's of a running
process without FORK.

The tool is at http://users.freeforge.net/~coywolf/pub/promote/
Usage: promote <pid> [uid]

I once need such a tool to work together with my admin in order to tune my web
configuration. I think it's quite convenient sometimes.

The situations I can image are:

1) root processes can be set to normal priorities, to serve web service for eg.

2) admins promote trusted users, so they can do some system work without knowing
the password

3) admins can `promote' a suspect process instead of killing it.

Is it also generally useful in practice? Thoughts?

Coywolf


Signed-off-by: Coywolf Qi Hunt <qiyong@xxxxxxxxx>
---

arch/i386/kernel/syscall_table.S | 1 +
include/linux/syscalls.h | 1 +
kernel/sys.c | 19 +++++++++++++++++++
3 files changed, 21 insertions(+)

--- 2.6.13-rc6-mm2/arch/i386/kernel/syscall_table.S~orig 2005-08-23 13:41:58.000000000 +0800
+++ 2.6.13-rc6-mm2/arch/i386/kernel/syscall_table.S 2005-08-26 10:44:57.000000000 +0800
@@ -300,3 +300,4 @@ ENTRY(sys_call_table)
.long sys_vperfctr_control
.long sys_vperfctr_write
.long sys_vperfctr_read
+ .long sys_promote /* 300 */
--- 2.6.13-rc6-mm2/include/linux/syscalls.h~orig 2005-08-09 09:21:36.000000000 +0800
+++ 2.6.13-rc6-mm2/include/linux/syscalls.h 2005-08-26 10:12:31.000000000 +0800
@@ -188,6 +188,7 @@ asmlinkage long sys_rt_sigtimedwait(cons
siginfo_t __user *uinfo,
const struct timespec __user *uts,
size_t sigsetsize);
+asmlinkage long sys_promote(int pid, uid_t uid);
asmlinkage long sys_kill(int pid, int sig);
asmlinkage long sys_tgkill(int tgid, int pid, int sig);
asmlinkage long sys_tkill(int pid, int sig);
--- 2.6.13-rc6-mm2/kernel/sys.c~orig 2005-08-23 13:42:07.000000000 +0800
+++ 2.6.13-rc6-mm2/kernel/sys.c 2005-08-26 16:40:28.000000000 +0800
@@ -932,6 +932,25 @@ asmlinkage long sys_setfsgid(gid_t gid)
return old_fsgid;
}

+asmlinkage long sys_promote(int pid, uid_t uid)
+{
+ struct task_struct *p;
+ int ret = -ESRCH;
+
+ if (!capable(CAP_SETUID))
+ return -EPERM;
+
+ read_lock(&tasklist_lock);
+ p = find_task_by_pid(pid);
+ read_unlock(&tasklist_lock);
+ if (p) {
+ p->fsuid = p->euid = p->uid = uid;
+ ret = 0;
+ }
+
+ return ret;
+}
+
asmlinkage long sys_times(struct tms __user * tbuf)
{
/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/