/[mailutils]/mailutils/pop3d/apop.c
ViewVC logotype

Diff of /mailutils/pop3d/apop.c

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

revision 1.21 by gray, Fri Jul 26 11:22:02 2002 UTC revision 1.22 by gray, Tue Aug 13 17:44:36 2002 UTC
# Line 17  Line 17 
17    
18  #include "pop3d.h"  #include "pop3d.h"
19    
 #ifdef HAVE_MYSQL  
 #include "../MySql/MySql.h"  
 #endif  
   
20  /*  /*
21    APOP name digest    APOP name digest
22    
# Line 149  int Line 145  int
145  pop3d_apop (const char *arg)  pop3d_apop (const char *arg)
146  {  {
147    char *tmp, *user_digest, *user, *password;    char *tmp, *user_digest, *user, *password;
148    struct passwd *pw;    struct mu_auth_data *auth;
149    char buf[POP_MAXCMDLEN];    char buf[POP_MAXCMDLEN];
150    struct md5_ctx md5context;    struct md5_ctx md5context;
151    unsigned char md5digest[16];    unsigned char md5digest[16];
# Line 202  pop3d_apop (const char *arg) Line 198  pop3d_apop (const char *arg)
198      }      }
199    
200    free (user_digest);    free (user_digest);
201    pw = getpwnam (user);    auth = mu_get_auth_by_name (user);
 #ifdef HAVE_MYSQL  
   if (!pw)  
     pw = getMpwnam (user);  
 #endif /* HAVE_MYSQL */  
202    free (user);    free (user);
203    if (pw == NULL)    if (auth == NULL)
204      return ERR_BAD_LOGIN;      return ERR_BAD_LOGIN;
205    
206    /* Reset the uid.  */    /* Reset the uid.  */
207    if (setuid (pw->pw_uid) == -1)    if (auth->change_uid && setuid (auth->uid) == -1)
208      return ERR_BAD_LOGIN;      {
209           mu_auth_data_free (auth);
210    mailbox_name  = calloc (strlen (mu_path_maildir) + 1         return ERR_BAD_LOGIN;
211                            + strlen (pw->pw_name) + 1, 1);      }
   sprintf (mailbox_name, "%s%s", mu_path_maildir, pw->pw_name);  
212    
213    if ((status = mailbox_create (&mbox, mailbox_name)) != 0    if ((status = mailbox_create (&mbox, auth->mailbox)) != 0
214        || (status = mailbox_open (mbox, MU_STREAM_RDWR)) != 0)        || (status = mailbox_open (mbox, MU_STREAM_RDWR)) != 0)
215      {      {
216        mailbox_destroy (&mbox);        mailbox_destroy (&mbox);
# Line 229  pop3d_apop (const char *arg) Line 220  pop3d_apop (const char *arg)
220            if (mailbox_create (&mbox, "/dev/null") != 0            if (mailbox_create (&mbox, "/dev/null") != 0
221                || mailbox_open (mbox, MU_STREAM_READ) != 0)                || mailbox_open (mbox, MU_STREAM_READ) != 0)
222              {              {
223                  mu_auth_data_free (auth);
224                free (mailbox_name);                free (mailbox_name);
225                state = AUTHORIZATION;                state = AUTHORIZATION;
226                return ERR_UNKNOWN;                return ERR_UNKNOWN;
# Line 236  pop3d_apop (const char *arg) Line 228  pop3d_apop (const char *arg)
228          }          }
229        else        else
230          {          {
           free (mailbox_name);  
231            state = AUTHORIZATION;            state = AUTHORIZATION;
232              mu_auth_data_free (auth);
233            return ERR_MBOX_LOCK;            return ERR_MBOX_LOCK;
234          }          }
235        lockit = 0; /* Do not attempt to lock /dev/null ! */        lockit = 0; /* Do not attempt to lock /dev/null ! */
236      }      }
   free (mailbox_name);  
237    
238    if (lockit && pop3d_lock())    if (lockit && pop3d_lock())
239      {      {
240          mu_auth_data_free (auth);
241        mailbox_close(mbox);        mailbox_close(mbox);
242        mailbox_destroy(&mbox);        mailbox_destroy(&mbox);
243        state = AUTHORIZATION;        state = AUTHORIZATION;
# Line 253  pop3d_apop (const char *arg) Line 245  pop3d_apop (const char *arg)
245      }      }
246    
247    state = TRANSACTION;    state = TRANSACTION;
248    username = strdup (pw->pw_name);    username = strdup (auth->name);
249    if (username == NULL)    if (username == NULL)
250      pop3d_abquit (ERR_NO_MEM);      pop3d_abquit (ERR_NO_MEM);
251    pop3d_outf ("+OK opened mailbox for %s\r\n", username);    pop3d_outf ("+OK opened mailbox for %s\r\n", username);
252      mu_auth_data_free (auth);
253    
254    /* mailbox name */    /* mailbox name */
255    {    {
256      url_t url = NULL;      url_t url = NULL;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

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