[PD-cvs] externals/ggee/control shell.c,1.7,1.8

Guenter Geiger ggeiger at users.sourceforge.net
Thu Oct 7 11:50:01 CEST 2004


Update of /cvsroot/pure-data/externals/ggee/control
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31976

Modified Files:
	shell.c 
Log Message:
dropping privileges for  shell process

Index: shell.c
===================================================================
RCS file: /cvsroot/pure-data/externals/ggee/control/shell.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** shell.c	12 Aug 2004 08:39:19 -0000	1.7
--- shell.c	7 Oct 2004 09:49:59 -0000	1.8
***************
*** 9,18 ****
--- 9,21 ----
  #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 ----------------------------- */
***************
*** 23,26 ****
--- 26,40 ----
  
  
+ 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
  {
***************
*** 243,246 ****
--- 257,265 ----
  	  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);





More information about the Pd-cvs mailing list