Back to index

courier  0.68.2
Classes | Functions | Variables
imaplogin.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
#include "imaptoken.h"
#include "imapwrite.h"
#include "proxy.h"
#include <courierauth.h>
#include <courierauthdebug.h>
#include "tcpd/spipe.h"
#include "numlib/numlib.h"
#include "tcpd/tlsclient.h"

Go to the source code of this file.

Classes

struct  imapproxyinfo

Functions

void initcapability ()
void mainloop ()
void imapcapability ()
int have_starttls ()
int tlsrequired ()
int authenticate (const char *, char *, int)
void rfc2045_error (const char *p)
void cmdfail (const char *, const char *)
void cmdsuccess (const char *, const char *)
static int starttls (const char *tag)
static int login_imap (int, const char *, void *)
int login_callback (struct authinfo *ainfo, void *dummy)
int do_imap_command (const char *tag)
void ignorepunct ()
int main (int argc, char **argv)
void bye ()
static void imap_write_str (const char *c, void(*cb_func)(const char *, size_t, void *), void *cb_arg)
static void imap_login_cmd (struct imapproxyinfo *ipi, void(*cb_func)(const char *, size_t, void *), void *cb_arg)
static void imap_capability_cmd (struct imapproxyinfo *ipi, void(*cb_func)(const char *, size_t, void *), void *cb_arg)
static void cb_cnt (const char *c, size_t l, void *arg)
static void cb_cpy (const char *c, size_t l, void *arg)
static char * get_imap_cmd (struct imapproxyinfo *ipi, void(*cmd)(struct imapproxyinfo *ipi, void(*cb_func)(const char *, size_t, void *), void *cb_arg))

Variables

FILE * debugfile = 0
unsigned long header_count = 0
unsigned long body_count = 0
unsigned long bytes_received_count
unsigned long bytes_sent_count
int main_argc
char ** main_argv
time_t start_time
static const char * imapd
static const char * defaultmaildir

Class Documentation

struct imapproxyinfo

Definition at line 135 of file imaplogin.c.

Class Members
const char * pwd
const char * tag
const char * uid

Function Documentation

int authenticate ( const char *  ,
char *  ,
int   
)

Definition at line 77 of file authenticate_auth.c.

{
struct imaptoken *tok=nexttoken();
char   *authmethod;
char   *initreply=0;
char   *authtype, *authdata;
char   authservice[40];
char   *p ;
int    rc;

       switch (tok->tokentype)     {
       case IT_ATOM:
       case IT_QUOTED_STRING:
              break;
       default:
              return (0);
       }

       authmethod=my_strdup(tok->tokenbuf);
       if (methodbuf)
              snprintf(methodbuf, methodbuflen, "%s", authmethod);

       tok=nexttoken_nouc();
       if (tok->tokentype != IT_EOL)
       {
              switch (tok->tokentype)     {
              case IT_ATOM:
              case IT_NUMBER:
                     break;
              default:
                     return (0);
              }
              initreply=my_strdup(tok->tokenbuf);
              if (strcmp(initreply, "=") == 0)
                     *initreply=0;
              tok=nexttoken_nouc();
       }

       if (tok->tokentype != IT_EOL)      return (0);

       read_eol();
       if ((rc = auth_sasl_ex(authmethod, initreply, imap_externalauth(),
                            &send_auth_reply, NULL,
                            &authtype, &authdata)) != 0)
       {
              free(authmethod);
              if (initreply)
                     free(initreply);
              return (rc);
       }

       free(authmethod);
       if (initreply)
              free(initreply);

       strcat(strcpy(authservice, "AUTHSERVICE"),
                      getenv("TCPLOCALPORT"));
       p=getenv(authservice);

       if (!p || !*p)
              p="imap";

       rc=auth_generic(p, authtype, authdata, login_callback, (void *)tag);
       free(authtype);
       free(authdata);
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bye ( )

Definition at line 470 of file imaplogin.c.

{
       exit(0);
}

Here is the call graph for this function:

static void cb_cnt ( const char *  c,
size_t  l,
void *  arg 
) [static]

Definition at line 537 of file imaplogin.c.

{
       *(size_t *)arg += l;
}

Here is the caller graph for this function:

static void cb_cpy ( const char *  c,
size_t  l,
void *  arg 
) [static]

Definition at line 543 of file imaplogin.c.

{
       char **p=(char **)arg;

       memcpy(*p, c, l);
       *p += l;
}

Here is the caller graph for this function:

void cmdfail ( const char *  ,
const char *   
)

Definition at line 70 of file mainloop.c.

{
#if SMAP
       const char *p=getenv("PROTOCOL");

       if (p && strcmp(p, "SMAP1") == 0)
              writes("-ERR ");
       else
#endif
       {
              writes(tag);
              writes(" NO ");
       }
       writes(msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cmdsuccess ( const char *  ,
const char *   
)

Definition at line 86 of file mainloop.c.

{
#if SMAP
       const char *p=getenv("PROTOCOL");

       if (p && strcmp(p, "SMAP1") == 0)
              writes("+OK ");
       else
#endif
       {
              writes(tag);
              writes(" OK ");
       }
       writes(msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int do_imap_command ( const char *  tag)

Definition at line 248 of file imaplogin.c.

{
       struct imaptoken *curtoken=nexttoken();
       char authservice[40];

#if SMAP
       if (strcmp(tag, "\\SMAP1") == 0)
       {
              const char *p=getenv("SMAP_CAPABILITY");

              if (p && *p)
                     putenv("PROTOCOL=SMAP1");
              else
                     return -1;
       }
#endif

       courier_authdebug_login( 1, "command=%s", curtoken->tokenbuf );

       if (strcmp(curtoken->tokenbuf, "LOGOUT") == 0)
       {
              if (nexttoken()->tokentype != IT_EOL)   return (-1);
              writes("* BYE Courier-IMAP server shutting down\r\n");
              cmdsuccess(tag, "LOGOUT completed\r\n");
              writeflush();
              fprintf(stderr, "INFO: LOGOUT, ip=[%s], rcvd=%lu, sent=%lu\n",
                     getenv("TCPREMOTEIP"), bytes_received_count, bytes_sent_count);
              exit(0);
       }
       if (strcmp(curtoken->tokenbuf, "NOOP") == 0)
       {
              if (nexttoken()->tokentype != IT_EOL)     return (-1);
              cmdsuccess(tag, "NOOP completed\r\n");
              return (0);
       }
       if (strcmp(curtoken->tokenbuf, "CAPABILITY") == 0)
       {
              if (nexttoken()->tokentype != IT_EOL)     return (-1);

              writes("* CAPABILITY ");
              imapcapability();
              writes("\r\n");
              cmdsuccess(tag, "CAPABILITY completed\r\n");
              return (0);
       }

       if (strcmp(curtoken->tokenbuf, "STARTTLS") == 0)
       {
              if (!have_starttls())       return (-1);
              if (starttls(tag))          return (-2);
              putenv("IMAP_STARTTLS=NO");
              putenv("IMAP_TLS_REQUIRED=0");
              putenv("IMAP_TLS=1");

              return (0);
       }

       if (strcmp(curtoken->tokenbuf, "LOGIN") == 0)
       {
       struct imaptoken *tok=nexttoken_nouc();
       char   *userid;
       char   *passwd;
       const char *p;
       int    rc;

              if (have_starttls() && tlsrequired())     /* Not yet */
              {
                     cmdfail(tag, "STARTTLS required\r\n");
                     return (0);
              }

              switch (tok->tokentype)     {
              case IT_ATOM:
              case IT_NUMBER:
              case IT_QUOTED_STRING:
                     break;
              default:
                     return (-1);
              }

              userid=strdup(tok->tokenbuf);
              if (!userid)
                     write_error_exit(0);
              tok=nexttoken_nouc_okbracket();
              switch (tok->tokentype)     {
              case IT_ATOM:
              case IT_NUMBER:
              case IT_QUOTED_STRING:
                     break;
              default:
                     free(userid);
                     return (-1);
              }

              passwd=my_strdup(tok->tokenbuf);

              if (nexttoken()->tokentype != IT_EOL)
              {
                     free(userid);
                     free(passwd);
                     return (-1);
              }

              strcat(strcpy(authservice, "AUTHSERVICE"),
                     getenv("TCPLOCALPORT"));

              p=getenv(authservice);

              if (!p || !*p)
                     p="imap";

              rc=auth_login(p, userid, passwd, login_callback, (void *)tag);
              courier_safe_printf("INFO: LOGIN FAILED, user=%s, ip=[%s]",
                              userid, getenv("TCPREMOTEIP"));
              free(userid);
              free(passwd);
              if (rc > 0)
              {
                     perror("ERR: authentication error");
                     writes("* BYE Temporary problem, please try again later\r\n");
                     writeflush();
                     exit(1);
              }
              sleep(5);
              cmdfail(tag, "Login failed.\r\n");
              return (0);
       }

       if (strcmp(curtoken->tokenbuf, "AUTHENTICATE") == 0)
       {
       char   method[32];
       int    rc;

              if (have_starttls() && tlsrequired())     /* Not yet */
              {
                     cmdfail(tag, "STARTTLS required\r\n");
                     return (0);
              }
              rc=authenticate(tag, method, sizeof(method));
              courier_safe_printf("INFO: LOGIN FAILED, method=%s, ip=[%s]",
                              method, getenv("TCPREMOTEIP"));
              if (rc > 0)
              {
                     perror("ERR: authentication error");
                     writes("* BYE Temporary problem, please try again later\r\n");
                     writeflush();
                     exit(1);
              }
              sleep(5);
              cmdfail(tag, "Login failed.\r\n");
              writeflush();
              return (-2);
       }

       return (-1);
}
static char* get_imap_cmd ( struct imapproxyinfo ipi,
void(*)(struct imapproxyinfo *ipi, void(*cb_func)(const char *, size_t, void *), void *cb_arg)  cmd 
) [static]

Definition at line 552 of file imaplogin.c.

{
       size_t cnt=1;
       char *buf;
       char *p;

       (*cmd)(ipi, &cb_cnt, &cnt);

       buf=malloc(cnt);

       if (!buf)
       {
              fprintf(stderr, "CRIT: Out of memory!\n");
              return NULL;
       }

       p=buf;
       (*cmd)(ipi, &cb_cpy, &p);
       *p=0;
       return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int have_starttls ( )

Definition at line 29 of file capability.c.

{
const char *p;

       if ((p=getenv("IMAP_STARTTLS")) == 0)     return (0);
       if (*p != 'y' && *p != 'Y')        return (0);

       p=getenv("COURIERTLS");
       if (!p || !*p)       return (0);
       if (access(p, X_OK)) return (0);
       return (1);
}
void ignorepunct ( )

Definition at line 196 of file imaptoken.c.

Here is the caller graph for this function:

static void imap_capability_cmd ( struct imapproxyinfo ipi,
void(*)(const char *, size_t, void *)  cb_func,
void *  cb_arg 
) [static]

Definition at line 527 of file imaplogin.c.

{
       (*cb_func)(ipi->tag, strlen(ipi->tag), cb_arg);
       (*cb_func)(" CAPABILITY\r\n", 13, cb_arg);
}

Here is the caller graph for this function:

static void imap_login_cmd ( struct imapproxyinfo ipi,
void(*)(const char *, size_t, void *)  cb_func,
void *  cb_arg 
) [static]

Definition at line 513 of file imaplogin.c.

{
       (*cb_func)(ipi->tag, strlen(ipi->tag), cb_arg);
       (*cb_func)(" LOGIN ", 7, cb_arg);
       imap_write_str(ipi->uid, cb_func, cb_arg);
       (*cb_func)(" ", 1, cb_arg);
       imap_write_str(ipi->pwd, cb_func, cb_arg);
       (*cb_func)("\r\n", 2, cb_arg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void imap_write_str ( const char *  c,
void(*)(const char *, size_t, void *)  cb_func,
void *  cb_arg 
) [static]

Definition at line 475 of file imaplogin.c.

{
       if (c == NULL)
       {
              (*cb_func)("NIL", 3, cb_arg);
       }

       (*cb_func)("\"", 1, cb_arg);

       while (*c)
       {
              size_t n;

              for (n=0; c[n]; n++)
                     if (c[n] == '"' || c[n] == '\\')
                            break;

              if (n)
              {
                     (*cb_func)(c, n, cb_arg);

                     c += n;
              }

              if (*c)
              {
                     (*cb_func)("\\", 1, cb_arg);
                     (*cb_func)(c, 1, cb_arg);
                     ++c;
              }
       }
       (*cb_func)("\"", 1, cb_arg);
}

Here is the caller graph for this function:

void imapcapability ( )

Definition at line 83 of file capability.c.

{
       const char *p;

       if ((p=getenv("IMAP_TLS")) && atoi(p) &&
           (p=getenv("IMAP_CAPABILITY_TLS")) && *p)
              writes(p);
       else if ((p=getenv("IMAP_CAPABILITY")) != 0 && *p)
              writes(p);
       else
              writes("IMAP4rev1");

#if SMAP
       p=getenv("SMAP_CAPABILITY");

       if (p && *p)
       {
              writes(" ");
              writes(p);

              if (keywords())
                     writes(" KEYWORDS");
       }
#endif

       if ((p=getenv("IMAP_ACL")) && atoi(p))
              writes(" ACL ACL2=UNION");

       if (have_starttls())
       {
              writes(" STARTTLS");
              if (tlsrequired())
                     writes(" LOGINDISABLED");
       }
       else
       {
              if (imap_externalauth())
                     writes(" AUTH=EXTERNAL");
       }
                     

       p=getenv("OUTBOX");

       if (p && *p)
       {
              writes(" XCOURIEROUTBOX=INBOX");
              writes(p);
       }

       if (magictrash())
              writes(" XMAGICTRASH");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void initcapability ( )

Definition at line 22 of file capability.c.

{
       const char *p=getenv("IMAP_KEYWORDS");

       if (p) capa_keywords=atoi(p);
}

Here is the caller graph for this function:

int login_callback ( struct authinfo *  ainfo,
void *  dummy 
)

Definition at line 143 of file imaplogin.c.

{
       int rc;
       const char *tag=(const char *)dummy;
       char *p;

       p=getenv("IMAP_PROXY");

       if (p && atoi(p))
       {
              if (ainfo->options == NULL ||
                  (p=auth_getoption(ainfo->options,
                                  "mailhost")) == NULL)
              {
                     fprintf(stderr, "WARN: proxy enabled, but no proxy"
                             " host defined for %s\n",
                             ainfo->address);

                     /* Fallthru to account login */

              }
              else if (ainfo->clearpasswd == NULL)
              {
                     free(p);
                     fprintf(stderr, "WARN: proxy enabled, but no password"
                             " for %s\n", ainfo->address);
                     return -1;
              }
              else
              {
                     struct proxyinfo pi;
                     struct imapproxyinfo ipi;
                     struct servent *se;
                     int fd;

                     se=getservbyname("imap", NULL);

                     pi.host=p;
                     pi.port=se ? ntohs(se->s_port):143;

                     ipi.uid=ainfo->address;
                     ipi.pwd=ainfo->clearpasswd;
                     ipi.tag=tag;

                     pi.connected_func=login_imap;
                     pi.void_arg=&ipi;

                     if ((fd=connect_proxy(&pi)) < 0)
                     {
                            free(p);
                            return -1;
                     }
                     free(p);
                     if (fd > 0)
                     {
                            alarm(0);
                            proxyloop(fd);
                            exit(0);
                     }

                     /* FALLTHRU */
              }
       }

       rc=auth_callback_default(ainfo);

       if (rc == 0)
       {
              p=malloc(sizeof("OPTIONS=") + strlen(ainfo->options ?
                                               ainfo->options:""));

              if (p)
              {
                     strcat(strcpy(p, "OPTIONS="),
                            ainfo->options ? ainfo->options:"");
                     putenv(p);

                     p=malloc(sizeof("IMAPLOGINTAG=")+strlen(tag));
                     if (p)
                     {
                            strcat(strcpy(p, "IMAPLOGINTAG="), tag);
                            putenv(p);

                            p=malloc(sizeof("AUTHENTICATED=")+
                                    strlen(ainfo->address));
                            if (p)
                            {
                                   strcat(strcpy(p, "AUTHENTICATED="),
                                          ainfo->address);
                                   putenv(p);
                                   alarm(0);
                                   execl(imapd, imapd,
                                         ainfo->maildir ?
                                         ainfo->maildir:defaultmaildir,
                                         NULL);
                                   fprintf(stderr, "ERR: exec(%s) failed!!\n",
                                                         imapd);
                            }
                     }
              }
       }

       return(rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int login_imap ( int  fd,
const char *  hostname,
void *  void_arg 
) [static]

Definition at line 580 of file imaplogin.c.

{
       struct imapproxyinfo *ipi=(struct imapproxyinfo *)void_arg;
       struct proxybuf pb;
       char linebuf[256];
       const char *p;
       char *cmd;

       DPRINTF("Proxy connected to %s", hostname);

       memset(&pb, 0, sizeof(pb));

       if (proxy_readline(fd, &pb, linebuf, sizeof(linebuf), 1) < 0)
              return -1;

       DPRINTF("%s: %s", hostname, linebuf);

       if ((p=strtok(linebuf, " \t")) == NULL ||
           strcmp(p, "*") ||
           (p=strtok(NULL, " \t")) == NULL ||
           strcasecmp(p, "OK"))
       {
              fprintf(stderr, "WARN: Did not receive greeting from %s\n",
                     hostname);
              return -1;
       }

       cmd=get_imap_cmd(ipi, imap_login_cmd);

       if (!cmd)
              return -1;

       if (proxy_write(fd, hostname, cmd, strlen(cmd)))
       {
              free(cmd);
              return -1;
       }
       free(cmd);

#if SMAP
       if (strcmp(ipi->tag, "\\SMAP1") == 0)
       {
              do
              {
                     if (proxy_readline(fd, &pb, linebuf, sizeof(linebuf),
                                      0) < 0)
                            return -1;

                     DPRINTF("%s: %s", hostname, linebuf);

              } while (linebuf[0] != '+' && linebuf[0] != '-');


              if (linebuf[0] != '+')
              {
                     fprintf(stderr, "WARN: Login to %s failed\n", hostname);
                     return -1;
              }

              if (fcntl(1, F_SETFL, 0) < 0 ||
                  (printf("+OK connected to proxy server.\r\n"),
                   fflush(stdout)) < 0)
                     return -1;
              return (0);
       }
#endif


       for (;;)
       {
              if (proxy_readline(fd, &pb, linebuf, sizeof(linebuf), 1) < 0)
                     return -1;

              DPRINTF("%s: %s", hostname, linebuf);

              if ((p=strtok(linebuf, " \t")) == NULL ||
                  strcmp(p, ipi->tag) ||
                  (p=strtok(NULL, " \t")) == NULL)
                     continue;

              if (strcasecmp(p, "OK"))
              {
                     fprintf(stderr, "WARN: Login to %s failed\n", hostname);
                     return -1;
              }
              break;
       }

       p=getenv("IMAP_PROXY_FOREIGN");

       if (p && atoi(p))
       {
              cmd=get_imap_cmd(ipi, imap_capability_cmd);

              if (!cmd)
                     return -1;

              if (proxy_write(fd, hostname, cmd, strlen(cmd)))
              {
                     free(cmd);
                     return -1;
              }
              free(cmd);
       }
       else
       {
              if (fcntl(1, F_SETFL, 0) < 0 ||
                  (printf("%s OK connected to proxy server.\r\n",
                         ipi->tag), fflush(stdout)) < 0)
                     return -1;
       }

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 407 of file imaplogin.c.

{
       const char    *ip;

#ifdef HAVE_SETVBUF_IOLBF
       setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
#endif

       if (argc != 3)
       {
              printf("* BYE imaplogin expected exactly two arguments.\r\n");
              fflush(stdout);
              exit(1);
       }

       alarm(60);
       imapd=argv[1];
       defaultmaildir=argv[2];
       initcapability();

       ip=getenv("TCPREMOTEIP");
       if (!ip)
              putenv("TCPREMOTEIP=127.0.0.1");
       ip=getenv("TCPREMOTEIP");

       if (!getenv("TCPLOCALPORT"))
              putenv("TCPLOCALPORT=143");

       time(&start_time);

#if    IMAP_CLIENT_BUGS

       ignorepunct();

#endif

       courier_authdebug_login_init();

       /* We use select() with a timeout, so use non-blocking filedescs */

       if (fcntl(0, F_SETFL, O_NONBLOCK) ||
           fcntl(1, F_SETFL, O_NONBLOCK))
       {
              perror("fcntl");
              exit(1);
       }

       writes("* OK [CAPABILITY ");
       imapcapability();
       writes("] Courier-IMAP ready. "
              "Copyright 1998-2011 Double Precision, Inc.  "
              "See COPYING for distribution information.\r\n");
       fprintf(stderr, "DEBUG: Connection, ip=[%s]\n", ip);
       writeflush();
       main_argc=argc;
       main_argv=argv;

       putenv("PROTOCOL=IMAP");

       mainloop();
       return (0);
}

Here is the call graph for this function:

void mainloop ( )

Definition at line 102 of file mainloop.c.

{
       int noerril = 0;

       signal(SIGTERM, sigexit);
       signal(SIGHUP, sigexit);
       signal(SIGINT, sigexit);

       for (;;)
       {
       char   tag[IT_MAX_ATOM_SIZE+1];
       struct imaptoken *curtoken;

              read_timeout(30 * 60);
              curtoken=nexttoken_nouc();
              tag[0]=0;
              if (curtoken->tokentype == IT_ATOM ||
                     curtoken->tokentype == IT_NUMBER)
              {
              int    rc;

                     if (strlen(tag)+strlen(curtoken->tokenbuf) > IT_MAX_ATOM_SIZE)
                            write_error_exit("max atom size too small");
                            
                     strncat(tag, curtoken->tokenbuf, IT_MAX_ATOM_SIZE);
                     rc=do_imap_command(tag);

                     if (rc == 0)
                     {
                            noerril = 0;
                            writeflush();
                            read_eol();
                            continue;
                     }
                     if (rc == -2)
                            continue;
              }

              noerril++;
              if (noerril > 9)
              {
                     errno = 0;
                     write_error_exit("TOO MANY CONSECUTIVE PROTOCOL VIOLATIONS");
              }
              read_eol();
              cmdfail(tag[0] ? tag:"*",
                     "Error in IMAP command received by server.\r\n");
              writeflush();
       }
}

Here is the call graph for this function:

void rfc2045_error ( const char *  p)

Definition at line 61 of file imaplogin.c.

{
       if (write(2, p, strlen(p)) < 0)
              _exit(1);
       _exit(0);
}
static int starttls ( const char *  tag) [static]

Definition at line 71 of file imaplogin.c.

{
       char *argvec[4];

       char localfd_buf[NUMBUFSIZE+40];
       char buf2[NUMBUFSIZE];
       struct couriertls_info cinfo;
       int pipefd[2];

       if (libmail_streampipe(pipefd))
       {
              cmdfail(tag, "libmail_streampipe() failed.\r\n");
              return (-1);
       }

       couriertls_init(&cinfo);
       fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);

       strcat(strcpy(localfd_buf, "-localfd="),
              libmail_str_size_t(pipefd[1], buf2));

       argvec[0]=localfd_buf;
       argvec[1]="-tcpd";
       argvec[2]="-server";
       argvec[3]=NULL;

       cmdsuccess(tag, "Begin SSL/TLS negotiation now.\r\n");
       writeflush();

       if (couriertls_start(argvec, &cinfo))
       {
              close(pipefd[0]);
              close(pipefd[1]);
              cmdfail(tag, "STARTTLS failed: ");
              writes(cinfo.errmsg);
              writes("\r\n");
              couriertls_destroy(&cinfo);
              return (-1);
       }

       couriertls_export_subject_environment(&cinfo);
       couriertls_destroy(&cinfo);

       close(pipefd[1]);
       close(0);
       close(1);
       if (dup(pipefd[0]) != 0 || dup(pipefd[0]) != 1)
       {
              perror("dup");
              exit(1);
       }
       close(pipefd[0]);

       /* We use select() with a timeout, so use non-blocking filedescs */

       if (fcntl(0, F_SETFL, O_NONBLOCK) ||
           fcntl(1, F_SETFL, O_NONBLOCK))
       {
              perror("fcntl");
              exit(1);
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tlsrequired ( )

Definition at line 43 of file capability.c.

{
const char *p=getenv("IMAP_TLS_REQUIRED");

       if (p && atoi(p))       return (1);
       return (0);
}

Here is the caller graph for this function:


Variable Documentation

unsigned long body_count = 0

Definition at line 49 of file imaplogin.c.

unsigned long bytes_received_count

Definition at line 41 of file imaptoken.c.

unsigned long bytes_sent_count

Definition at line 42 of file imaptoken.c.

FILE* debugfile = 0

Definition at line 42 of file imaplogin.c.

const char* defaultmaildir [static]

Definition at line 59 of file imaplogin.c.

unsigned long header_count = 0

Definition at line 49 of file imaplogin.c.

const char* imapd [static]

Definition at line 58 of file imaplogin.c.

int main_argc

Definition at line 54 of file imaplogin.c.

char** main_argv

Definition at line 55 of file imaplogin.c.

time_t start_time

Definition at line 33 of file imaptoken.c.