public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* syscall: sys_promote
@ 2005-08-26  9:25 Coywolf Qi Hunt
  2005-08-26 11:02 ` Coywolf Qi Hunt
  2005-08-26 12:47 ` Erik Mouw
  0 siblings, 2 replies; 13+ messages in thread
From: Coywolf Qi Hunt @ 2005-08-26  9:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: dhommel

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@fc-cn.com>
---

 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)
 {
 	/*

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-08-31  7:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-26  9:25 syscall: sys_promote Coywolf Qi Hunt
2005-08-26 11:02 ` Coywolf Qi Hunt
2005-08-26 15:19   ` Alan Cox
2005-08-29  3:54     ` qiyong
2005-08-29 12:29       ` Alan Cox
2005-08-29 16:15         ` Trond Myklebust
     [not found]         ` <a36005b505082908415d9202d5@mail.gmail.com>
2005-08-31  7:53           ` Qi Yong
2005-08-31  7:58         ` Qi Yong
2005-08-26 12:47 ` Erik Mouw
2005-08-29  3:55   ` qiyong
2005-08-29  7:53     ` Bernd Petrovitsch
2005-08-29  8:16       ` Coywolf Qi Hunt
2005-08-29  8:53         ` Bernd Petrovitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox