aboutsummaryrefslogtreecommitdiff
path: root/control/shell.c
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2004-10-07 09:49:59 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2004-10-07 09:49:59 +0000
commitb3067c16d7808ed234ec3eac78a508d0e3529b15 (patch)
treef7a7454e09f805c8fe9a4ee137cfa5937763c95c /control/shell.c
parent9e2ddf8e4cfe2c31fb2733670761c72948238331 (diff)
dropping privileges for shell process
svn path=/trunk/externals/ggee/; revision=2067
Diffstat (limited to 'control/shell.c')
-rwxr-xr-xcontrol/shell.c19
1 files changed, 19 insertions, 0 deletions
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 <unistd.h>
#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
+#include <sched.h>
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);