Back to index

courier  0.68.2
Defines | Functions
sendmail-esmtpd-wrapper.c File Reference
#include "courier.h"
#include "bindir.h"
#include "sbindir.h"
#include "maxlongsize.h"
#include "numlib/numlib.h"
#include <sys/types.h>
#include <pwd.h>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define EX_NOUSER   67
#define EX_TEMPFAIL   75
#define EX_NOPERM   77

Functions

void esmtpd ()

Define Documentation

#define EX_NOPERM   77

Definition at line 25 of file sendmail-esmtpd-wrapper.c.

#define EX_NOUSER   67

Definition at line 23 of file sendmail-esmtpd-wrapper.c.

#define EX_TEMPFAIL   75

Definition at line 24 of file sendmail-esmtpd-wrapper.c.


Function Documentation

void esmtpd ( )

Definition at line 49 of file sendmail-esmtpd-wrapper.c.

{
uid_t orig_uid=getuid();
char   ubuf[NUMBUFSIZE];
char   remoteinfobuf[NUMBUFSIZE+30];
char   *environ[6];
char   *argv[2];
int    pipefd[2];
pid_t  pid;

       sprintf(remoteinfobuf, "TCPREMOTEINFO=uid %s",
              libmail_str_uid_t(orig_uid, ubuf));

       if (pipe(pipefd) < 0)
       {
              perror("pipe");
              exit(EX_TEMPFAIL);
       }

       if (chdir(courierdir()) < 0)
       {
              perror("chdir");
              exit(EX_TEMPFAIL);
       }

       pid=fork();
       if (pid < 0)
       {
              perror("fork");
              exit(EX_TEMPFAIL);
       }
       if (pid == 0)
       {
              dup2(pipefd[1], 1);
              close(pipefd[0]);
              close(pipefd[1]);
              execl(BINDIR "/addcr", "addcr", (char *)0);
              perror("exec");
              exit(EX_TEMPFAIL);
       }
       dup2(pipefd[0], 0);
       close(pipefd[0]);
       close(pipefd[1]);
       close(2); open("/dev/null", O_WRONLY); /* Pine temper tantrum */

       environ[0]="TCPREMOTEIP=127.0.0.1";
       environ[1]="TCPREMOTEHOST=localhost";
       environ[2]=remoteinfobuf;
       environ[3]="RELAYCLIENT=";
       environ[4]="FAXRELAYCLIENT=";
       environ[5]=0;
       argv[0]="sendmail";
       argv[1]=0;
       execve(SBINDIR "/courieresmtpd", argv, environ);
       perror("exec");
       exit(EX_TEMPFAIL);
}

Here is the call graph for this function:

Here is the caller graph for this function: