From b3067c16d7808ed234ec3eac78a508d0e3529b15 Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Thu, 7 Oct 2004 09:49:59 +0000 Subject: dropping privileges for shell process svn path=/trunk/externals/ggee/; revision=2067 --- control/shell.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'control/shell.c') diff --git a/control/shell.c b/control/shell.c index 5476e97..78e6e03 100755 --- a/control/shell.c +++ b/control/shell.c @@ -8,12 +8,15 @@ #include #include +#include #include #include #include #include +#include void sys_rmpollfn(int fd); +void sys_addpollfn(int fd, void* fn, void *ptr); /* ------------------------ shell ----------------------------- */ @@ -22,6 +25,17 @@ void sys_rmpollfn(int fd); static t_class *shell_class; +static void drop_priority(void) +{ +#ifdef _POSIX_PRIORITY_SCHEDULING + struct sched_param par; + int p1 ,p2, p3; + par.sched_priority = 0; + sched_setscheduler(0,SCHED_OTHER,&par); +#endif +} + + typedef struct _shell { t_object x_obj; @@ -242,6 +256,11 @@ static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) /* reassign stdout */ dup2(x->fdpipe[1],1); dup2(x->fdinpipe[1],0); + + /* drop privileges */ + drop_priority(); + seteuid(getuid()); /* lose setuid priveliges */ + post("executing %s",cmd); system(cmd); // execvp(s->s_name,argv); -- cgit v1.2.1