/* wrapper.c jms1@jms1.net 1997-11-20 general-purpose setuid wrapper header files etc. written for linux, compiles ok on solaris 2.6 compile using a command like this: gcc -DPROG=\"/usr/local/bin/blah.sh\" -o blah wrapper1.c then set permissions on the resulting binary to be owned by root and have the setuid bit turned on. any parameters on the command line when the compiled wrapper is run will be passed along to the script or program being run. --------------------------------------------------------------------- Copyright (C) 1997,2007 John Simpson. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef PROG #error Please define PROG and try again. #endif #include #include int main ( int argc , char *argv[] , char *envp[] ) { if ( setuid ( 0 ) ) { perror ( "setuid" ) ; return 1 ; } if ( seteuid ( 0 ) ) { perror ( "seteuid" ) ; return 1 ; } argv[0] = PROG ; execve ( PROG , argv , envp ) ; perror ( "execv" ) ; return 1 ; }