/[mailutils]/mailutils/imap4d/imap4d.c
ViewVC logotype

Diff of /mailutils/imap4d/imap4d.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by gray, Fri Jul 26 11:19:04 2002 UTC revision 1.25 by gray, Mon Aug 5 08:09:17 2002 UTC
# Line 25  FILE *ofile; Line 25  FILE *ofile;
25  mailbox_t mbox;  mailbox_t mbox;
26  char *homedir;  char *homedir;
27  int state = STATE_NONAUTH;  int state = STATE_NONAUTH;
28    int debug_mode = 0;
29    
30  struct daemon_param daemon_param = {  struct daemon_param daemon_param = {
31    MODE_INTERACTIVE,     /* Start in interactive (inetd) mode */    MODE_INTERACTIVE,     /* Start in interactive (inetd) mode */
# Line 114  main (int argc, char **argv) Line 115  main (int argc, char **argv)
115      pam_service = "gnu-imap4d";      pam_service = "gnu-imap4d";
116  #endif  #endif
117    
118    /* First we want our group to be mail so we can access the spool.  */    if (isatty (0))
   gr = getgrnam ("mail");  
   if (gr == NULL)  
119      {      {
120        perror ("Error getting mail group");        /* If input is a tty, switch to debug mode */
121        exit (1);        debug_mode = 1;
122      }      }
123      else
   if (setgid (gr->gr_gid) == -1)  
124      {      {
125        perror ("Error setting mail group");        /* Normal operation: */
126        exit (1);        /* First we want our group to be mail so we can access the spool.  */
127          gr = getgrnam ("mail");
128          if (gr == NULL)
129            {
130              perror ("Error getting mail group");
131              exit (1);
132            }
133          
134          if (setgid (gr->gr_gid) == -1)
135            {
136              perror ("Error setting mail group");
137              exit (1);
138            }
139      }      }
140    
141    /* Register the desire formats. We only need Mbox mail format.  */    /* Register the desired formats. */
142    {    {
143      list_t bookie;      list_t bookie;
144      registrar_get_list (&bookie);      registrar_get_list (&bookie);
# Line 190  main (int argc, char **argv) Line 200  main (int argc, char **argv)
200  static int  static int
201  imap4d_mainloop (int infile, int outfile)  imap4d_mainloop (int infile, int outfile)
202  {  {
203      char *text;
204      
205    /* Reset hup to exit.  */    /* Reset hup to exit.  */
206    signal (SIGHUP, imap4d_signal);    signal (SIGHUP, imap4d_signal);
207    /* Timeout alarm.  */    /* Timeout alarm.  */
# Line 202  imap4d_mainloop (int infile, int outfile Line 214  imap4d_mainloop (int infile, int outfile
214    
215    setvbuf(ofile, NULL, _IOLBF, 0);    setvbuf(ofile, NULL, _IOLBF, 0);
216    
   syslog (LOG_INFO, "Incoming connection opened");  
   
217    /* log information on the connecting client */    /* log information on the connecting client */
218    {    if (!debug_mode)
219      struct sockaddr_in cs;      {
220      int len = sizeof cs;        struct sockaddr_in cs;
221      if (getpeername (infile, (struct sockaddr*)&cs, &len) < 0)        int len = sizeof cs;
       syslog (LOG_ERR, "can't obtain IP address of client: %s",  
               strerror (errno));  
     else  
       syslog (LOG_INFO, "connect from %s", inet_ntoa(cs.sin_addr));  
   }  
222    
223          syslog (LOG_INFO, "Incoming connection opened");
224          if (getpeername (infile, (struct sockaddr*)&cs, &len) < 0)
225            syslog (LOG_ERR, "can't obtain IP address of client: %s",
226                    strerror (errno));
227          else
228            syslog (LOG_INFO, "connect from %s", inet_ntoa(cs.sin_addr));
229          text = "IMAP4rev1";
230        }
231      else
232        {
233          syslog (LOG_INFO, "Started in debugging mode");
234          text = "IMAP4rev1 Debugging mode";
235        }
236      
237    /* Greetings.  */    /* Greetings.  */
238    util_out (RESP_OK, "IMAP4rev1 GNU " PACKAGE " " VERSION);    util_out (RESP_OK, text);
239    fflush (ofile);    fflush (ofile);
240    
241    while (1)    while (1)

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26