/****************************************************************************** update-simscan.c John Simpson 2007-07-31 Simple wrapper to call "simscanmk -g" as root. If you are running simscan as the "simscan" user and clamav as the "clamav" user, and have added the clamav user to the simscan group as suggested in the documentation, then the resulting binary should be configured as: # gcc -s -o update-simscan update-simscan.c # chown root:simscan update-simscan # chmod 4110 update-simscan This will make it run as root, and only be executable to members of the "simscan" group- which allows the clamav user to run it, but not every user on the machine. ******************************************************************************* Copyright (C) 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 as published by the Free Software Foundation, either version 2 or version 3 of the license, at your option. 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 . ******************************************************************************/ #include #include #include /* the program it will run (not the full command, just the executable) */ #define CMD "/var/qmail/bin/simscanmk" /* array of args for that program. first must be the program name, then args, then NULL to end the list. */ char *newargv[] = { "/var/qmail/bin/simscanmk" , "-g" , NULL } ; /****************************************************************************** ******************************************************************************* ******************************************************************************/ int main ( void ) { #ifdef DEBUG printf ( "uid = %d\neuid = %d\ngid = %d\negid = %d\n\n" , getuid() , geteuid() , getgid() , getegid() ) ; #endif if ( setgid ( 0 ) ) { perror ( "setgid()" ) ; return 1 ; } #ifdef DEBUG else puts ( "setgid(): OK" ) ; #endif if ( setuid ( 0 ) ) { perror ( "setuid()" ) ; return 1 ; } #ifdef DEBUG else puts ( "setuid(): OK" ) ; printf ( "\nuid = %d\neuid = %d\ngid = %d\negid = %d\n\n" , getuid() , geteuid() , getgid() , getegid() ) ; puts ( "execvp()...\n" ) ; #endif execv ( CMD , newargv ) ; perror ( "execv()" ) ; return 1 ; }