You are not logged in Log in Join
You are here: Home » Members » Stefan's Home » postfixwrapper.c » View File

Log in
Name

Password

 

postfixwrapper.c

File details
Size
1 K
File type
text/plain

File contents

/*
 *
 *      postfixwrapper.c
 *      wrapper to start/stop postfix as unprivileged user
 *      executable must be SUID root!
 *
 *      2000-12-07, [email protected]
 *
 */

#include <unistd.h>
#include <stdlib.h>

const char* mtactl = "/usr/sbin/postfix";
const char* start  = "start";
const char* stop   = "stop";

int main( int argc, char** argv )
{
  // decouple from Zope
  if ( fork() != 0 )
    exit( 0 );

  // do the bad stuff (cough)
  setreuid( 0, 0 );

  // start/stop postfix safely (cough, cough)
  if ( strcmp(argv[1], start) == 0 )
    execl( mtactl, mtactl, start, NULL );
  else if ( strcmp(argv[1], stop) == 0 )
    execl( mtactl, mtactl, stop, NULL );
  else
    return 1;

  return 0;
}