Commit fddedb53 fddedb53f2435215728b3c4313819335e4dae839 by Alain Magloire

extra.c : in pop3_quit() put a case for ERR_NO_FILE since the fdopen()

failed ofile == NULL we should not attempt to fprintf(ofile, ..) nor
fflush().  Buglet discover when working on imap4d.
pop3d.[ch]/user.c : indentation and comments.
1 parent 3f342f1e
......@@ -95,14 +95,17 @@ pop3_abquit (int reason)
fprintf (ofile, "-ERR Out of memory, quitting\r\n");
syslog (LOG_ERR, "Out of memory");
break;
case ERR_DEAD_SOCK:
fprintf (ofile, "-ERR Socket closed, quitting\r\n");
syslog (LOG_ERR, "Socket closed");
break;
case ERR_SIGNAL:
fprintf (ofile, "-ERR Quitting on signal\r\n");
syslog (LOG_ERR, "Quitting on signal");
break;
case ERR_TIMEOUT:
fprintf (ofile, "-ERR Session timed out\r\n");
if (state == TRANSACTION)
......@@ -110,12 +113,19 @@ pop3_abquit (int reason)
else
syslog (LOG_INFO, "Session timed out for no user");
break;
case ERR_NO_OFILE:
syslog (LOG_INFO, "No socket to send to");
break;
default:
fprintf (ofile, "-ERR Quitting (reason unknown)\r\n");
syslog (LOG_ERR, "Unknown quit");
break;
}
fflush (ofile);
if (ofile)
fflush (ofile);
closelog();
exit (1);
}
......
......@@ -213,6 +213,7 @@ pop3_mainloop (int infile, int outfile)
state = AUTHORIZATION;
curr_time = time (NULL);
/* FIXME: Retreive hostname with getpeername() and log. */
syslog (LOG_INFO, "Incoming connection opened");
/* Prepare the shared secret for APOP. */
......
......@@ -134,18 +134,14 @@ pop3_user (const char *arg)
pw = getpwnam (arg);
#ifndef USE_LIBPAM
if (pw == NULL)
return ERR_BAD_LOGIN;
if (pw->pw_uid < 1)
if (pw == NULL || pw->pw_uid < 1)
return ERR_BAD_LOGIN;
if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd)))
{
#ifdef HAVE_SHADOW_H
struct spwd *spw;
spw = getspnam (arg);
if (spw == NULL)
return ERR_BAD_LOGIN;
if (strcmp (spw->sp_pwdp, crypt (pass, spw->sp_pwdp)))
if (spw == NULL || strcmp (spw->sp_pwdp, crypt (pass, spw->sp_pwdp)))
#endif /* HAVE_SHADOW_H */
return ERR_BAD_LOGIN;
}
......