1 --- src/main/festival_main.cc
2 +++ src/main/festival_main.cc
5 /*=======================================================================*/
7 +#include <sys/types.h>
16 int real_number_of_files = 0;
17 int heap_size = FESTIVAL_HEAP_SIZE;
18 + unsigned int uid = -1;
19 + unsigned int gid = -1;
22 if (festival_check_script_mode(argc,argv) == TRUE)
23 { // Need to check this directly as in script mode args are
25 " english, spanish and welsh are available\n"+
26 "--server Run in server mode waiting for clients\n"+
27 " of server_port (1314)\n"+
28 + "--chroot <string> Run server in chroot\n"+
29 + "--uid <string> Run server as given user\n"+
30 + "--gid <int> Run server with this group\n"+
32 " Used in #! scripts, runs in batch mode on\n"+
33 " file and passes all other args to Scheme\n"+
38 + if( al.present( "--uid" ) )
40 + EST_String b = al.sval( "--uid" );
42 + pw = getpwnam( b.str() );
50 + printf("unknow user\n");
55 + if( al.present( "--gid" ) )
57 + gid = al.ival( "--gid" );
58 + if( al.present( "--uid" ) )
60 + printf( "useless without --uid\n" );
65 + if( al.present( "--chroot" ) )
67 + if( !al.present( "--uid" ) )
69 + printf( "chroot only makes sense in combination with uid switching\n" );
73 + EST_String a = al.sval( "--chroot" );
74 + printf( "chroot to %s\n", a.str() );
75 + if( chdir( a.str() ) )
79 + if( chroot( a.str() ) )
89 + if( al.present( "--uid" ) )
91 + if( setgroups( 1, &gid ) < 0 )
96 + if( setgid( gid ) != 0 )
98 + printf( "can't setgid\n" );
102 + if( setuid( uid ) != 0 )
104 + printf( "can't setuid\n" );
109 if (al.present("--libdir"))
110 festival_libdir = wstrdup(al.val("--libdir"));
111 else if (getenv("FESTLIBDIR") != 0)