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) ...@@ -95,14 +95,17 @@ pop3_abquit (int reason)
95 fprintf (ofile, "-ERR Out of memory, quitting\r\n"); 95 fprintf (ofile, "-ERR Out of memory, quitting\r\n");
96 syslog (LOG_ERR, "Out of memory"); 96 syslog (LOG_ERR, "Out of memory");
97 break; 97 break;
98
98 case ERR_DEAD_SOCK: 99 case ERR_DEAD_SOCK:
99 fprintf (ofile, "-ERR Socket closed, quitting\r\n"); 100 fprintf (ofile, "-ERR Socket closed, quitting\r\n");
100 syslog (LOG_ERR, "Socket closed"); 101 syslog (LOG_ERR, "Socket closed");
101 break; 102 break;
103
102 case ERR_SIGNAL: 104 case ERR_SIGNAL:
103 fprintf (ofile, "-ERR Quitting on signal\r\n"); 105 fprintf (ofile, "-ERR Quitting on signal\r\n");
104 syslog (LOG_ERR, "Quitting on signal"); 106 syslog (LOG_ERR, "Quitting on signal");
105 break; 107 break;
108
106 case ERR_TIMEOUT: 109 case ERR_TIMEOUT:
107 fprintf (ofile, "-ERR Session timed out\r\n"); 110 fprintf (ofile, "-ERR Session timed out\r\n");
108 if (state == TRANSACTION) 111 if (state == TRANSACTION)
...@@ -110,12 +113,19 @@ pop3_abquit (int reason) ...@@ -110,12 +113,19 @@ pop3_abquit (int reason)
110 else 113 else
111 syslog (LOG_INFO, "Session timed out for no user"); 114 syslog (LOG_INFO, "Session timed out for no user");
112 break; 115 break;
116
117 case ERR_NO_OFILE:
118 syslog (LOG_INFO, "No socket to send to");
119 break;
120
113 default: 121 default:
114 fprintf (ofile, "-ERR Quitting (reason unknown)\r\n"); 122 fprintf (ofile, "-ERR Quitting (reason unknown)\r\n");
115 syslog (LOG_ERR, "Unknown quit"); 123 syslog (LOG_ERR, "Unknown quit");
116 break; 124 break;
117 } 125 }
118 fflush (ofile); 126
127 if (ofile)
128 fflush (ofile);
119 closelog(); 129 closelog();
120 exit (1); 130 exit (1);
121 } 131 }
......
...@@ -213,6 +213,7 @@ pop3_mainloop (int infile, int outfile) ...@@ -213,6 +213,7 @@ pop3_mainloop (int infile, int outfile)
213 state = AUTHORIZATION; 213 state = AUTHORIZATION;
214 curr_time = time (NULL); 214 curr_time = time (NULL);
215 215
216 /* FIXME: Retreive hostname with getpeername() and log. */
216 syslog (LOG_INFO, "Incoming connection opened"); 217 syslog (LOG_INFO, "Incoming connection opened");
217 218
218 /* Prepare the shared secret for APOP. */ 219 /* Prepare the shared secret for APOP. */
......
...@@ -134,18 +134,14 @@ pop3_user (const char *arg) ...@@ -134,18 +134,14 @@ pop3_user (const char *arg)
134 134
135 pw = getpwnam (arg); 135 pw = getpwnam (arg);
136 #ifndef USE_LIBPAM 136 #ifndef USE_LIBPAM
137 if (pw == NULL) 137 if (pw == NULL || pw->pw_uid < 1)
138 return ERR_BAD_LOGIN;
139 if (pw->pw_uid < 1)
140 return ERR_BAD_LOGIN; 138 return ERR_BAD_LOGIN;
141 if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) 139 if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd)))
142 { 140 {
143 #ifdef HAVE_SHADOW_H 141 #ifdef HAVE_SHADOW_H
144 struct spwd *spw; 142 struct spwd *spw;
145 spw = getspnam (arg); 143 spw = getspnam (arg);
146 if (spw == NULL) 144 if (spw == NULL || strcmp (spw->sp_pwdp, crypt (pass, spw->sp_pwdp)))
147 return ERR_BAD_LOGIN;
148 if (strcmp (spw->sp_pwdp, crypt (pass, spw->sp_pwdp)))
149 #endif /* HAVE_SHADOW_H */ 145 #endif /* HAVE_SHADOW_H */
150 return ERR_BAD_LOGIN; 146 return ERR_BAD_LOGIN;
151 } 147 }
......