[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.1.10.0805021602160.6463@fbirervta.pbzchgretzou.qr>
Date: Fri, 2 May 2008 16:07:46 +0200 (CEST)
From: Jan Engelhardt <jengelh@...ozas.de>
To: Enrico Weigelt <weigelt@...ux.de>
cc: linux kernel list <linux-kernel@...r.kernel.org>
Subject: Re: API for changing UIDs of other processes
On Friday 2008-05-02 14:16, Enrico Weigelt wrote:
>Hi folks,
>
>
>I'd like to build some authentication daemon which alters the
>privileges of another process (like factotum does on plan9).
>But I couldn't find any interface for that (setuid() and friends
>only operate on the current process). So I'm now going to create
>my own interface.
>
>As a little learning example I just added a few files to the
>per-pid dirs: uid, euid, suid, fsuid. This was trivial :)
>
>Now I'd like to add an write capability to these files:
>simply writing another number changes the (|s|fs)uid.
>
>But this doesnt seem that trivial. Perhaps someone could give
>me some advice ?
Not really hard, is it? Just look at something like oom_adj
static ssize_t myprocpid_euid_write(struct file *file,
const char __user *inbuf, size_t size)
{
struct task_struct *task;
char buf[sizeof("4294967296")];
unsigned int amount = min(size, sizeof(buf) - 1);
if (copy_from_user(buf, inbuf, amount) != 0)
return -EFAULT;
buf[amount] = '\0';
task = get_proc_task(file->f_path.dentry->d_inode);
if (task == NULL)
return -ESRCH;
/* do error checking */
task->euid = simple_strtoul(buf, NULL, 0);
put_task_struct(task);
return size;
}
So far the theory..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists