Patches from Sergey, se Changelog for details:
2001-04-23 Sergey Poznyakoff
Showing
20 changed files
with
172 additions
and
98 deletions
1 | 2001-05-03 Alain Magloire | ||
2 | |||
3 | * argp/argp-help.c (hol_entry_help): Some compiler like Watcomm | ||
4 | can not initialize a local structure struct .. = { .. }. Do it | ||
5 | explicitely field by field. | ||
6 | * argp/arpg-parse.c: Watcomm choke on N_() macro. | ||
7 | (parser_init): Watcomm does not like operation on a void * pointer. | ||
8 | |||
9 | * imap4d/login.c: Cast the return of crypt(), since some platforms | ||
10 | do not provide a prototype in <unistd.h> | ||
11 | |||
12 | * pop3d/user.c: Cast the return of crypt(), since in may not be | ||
13 | declare in <unistd.h>. | ||
14 | |||
15 | * lib/snprintf.c: Use only __STDC__ to detect <stdar.h> | ||
16 | * lib/snprintf.h: Use only __STDC__. | ||
17 | |||
18 | * mail/mail.h: The global variable should be declare extern. | ||
19 | * mail/pipe.c: Use 512 buffer instead of BUFSIZ, go easy on the stack. | ||
20 | * mail/print.c: Use 512 buffer instead of BUFSIZ, go easy on the stack. | ||
21 | * mail/write.c: Use 512 buffer instead of BUFSIZ, go easy on the stack. | ||
22 | |||
23 | * mailbox/folder_imap.c: Declare strtock_r (). | ||
24 | |||
25 | 2001-05-03 Sergey Poznyakoff | ||
26 | |||
27 | * pop3d/user.c: Misplace parentheses around the mailbox_xx() calls. | ||
28 | Do not free (buf) since it is now static storage. Unfortunately most | ||
29 | of the pam modules do openlog() on their own, thus after | ||
30 | authentication all logging output flows to where the last pam module | ||
31 | has directed it, which is usually `auth' facility. | ||
32 | Put back closelog()/openlog(). | ||
33 | * pop3d/pop3d.h: ifile is now FILE *. | ||
34 | pop3d_realine () take FILE * as a prototype. | ||
35 | * pop3d/pop3d.c (pop3d_mainloop): Refresh lock, pop3d_touchlock(). | ||
36 | Register SIGALRM in the child. | ||
37 | Do not free (buf) since it is now static storage. | ||
38 | * pop3d/extra.c (pop3d_readline): Change to use | ||
39 | fgets () and alarm (). | ||
40 | With small modification from Alain. | ||
41 | (pop3d_signal): ofile will be NULL in the *child* process: | ||
42 | whereas in the parent one, ofile will always be NULL, since it lives | ||
43 | in the BSS (FILE *ofile;) and gets initialized only in the child | ||
44 | process. Thus, when the parent receives any signal, SIGTERM for | ||
45 | example, it does pop3d_abquit(ERR_SIGNAL) and dies doing | ||
46 | fprintf(ofile, ...) | ||
47 | |||
1 | 2001-05-02 Alain Magloire | 48 | 2001-05-02 Alain Magloire |
2 | 49 | ||
3 | Some of the Makefile.am contain gcc specific options | 50 | Some of the Makefile.am contain gcc specific options | ... | ... |
... | @@ -1054,7 +1054,14 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state, | ... | @@ -1054,7 +1054,14 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state, |
1054 | int old_wm = __argp_fmtstream_wmargin (stream); | 1054 | int old_wm = __argp_fmtstream_wmargin (stream); |
1055 | /* PEST is a state block holding some of our variables that we'd like to | 1055 | /* PEST is a state block holding some of our variables that we'd like to |
1056 | share with helper functions. */ | 1056 | share with helper functions. */ |
1057 | struct pentry_state pest = { entry, stream, hhstate, 1, state }; | 1057 | /* Some loosing compiler can not handle this ... lets play nice. */ |
1058 | /* struct pentry_state pest = { entry, stream, hhstate, 1, state }; */ | ||
1059 | struct pentry_state pest; | ||
1060 | pest.entry = entry; | ||
1061 | pest.stream = stream; | ||
1062 | pest.hhstate = hhstate; | ||
1063 | pest.first = 1; | ||
1064 | pest.state = state; | ||
1058 | 1065 | ||
1059 | if (! odoc (real)) | 1066 | if (! odoc (real)) |
1060 | for (opt = real, num = entry->num; num > 0; opt++, num--) | 1067 | for (opt = real, num = entry->num; num > 0; opt++, num--) | ... | ... |
... | @@ -43,7 +43,7 @@ | ... | @@ -43,7 +43,7 @@ |
43 | # endif | 43 | # endif |
44 | #endif | 44 | #endif |
45 | #ifndef N_ | 45 | #ifndef N_ |
46 | # define N_(msgid) (msgid) | 46 | # define N_(msgid) msgid |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #if _LIBC - 0 | 49 | #if _LIBC - 0 |
... | @@ -525,9 +525,14 @@ parser_init (struct parser *parser, const struct argp *argp, | ... | @@ -525,9 +525,14 @@ parser_init (struct parser *parser, const struct argp *argp, |
525 | return ENOMEM; | 525 | return ENOMEM; |
526 | 526 | ||
527 | parser->groups = parser->storage; | 527 | parser->groups = parser->storage; |
528 | /* To please Watcom CC | ||
528 | parser->child_inputs = parser->storage + GLEN; | 529 | parser->child_inputs = parser->storage + GLEN; |
529 | parser->long_opts = parser->storage + GLEN + CLEN; | 530 | parser->long_opts = parser->storage + GLEN + CLEN; |
530 | parser->short_opts = parser->storage + GLEN + CLEN + LLEN; | 531 | parser->short_opts = parser->storage + GLEN + CLEN + LLEN; |
532 | */ | ||
533 | parser->child_inputs = (char *)(parser->storage) + GLEN; | ||
534 | parser->long_opts = (char *)(parser->storage) + GLEN + CLEN; | ||
535 | parser->short_opts = (char *)(parser->storage) + GLEN + CLEN + LLEN; | ||
531 | 536 | ||
532 | memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *)); | 537 | memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *)); |
533 | parser_convert (parser, argp, flags); | 538 | parser_convert (parser, argp, flags); | ... | ... |
... | @@ -100,7 +100,7 @@ imap4d_login (struct imap4d_command *command, char *arg) | ... | @@ -100,7 +100,7 @@ imap4d_login (struct imap4d_command *command, char *arg) |
100 | #ifndef USE_LIBPAM | 100 | #ifndef USE_LIBPAM |
101 | if (pw == NULL || pw->pw_uid < 1) | 101 | if (pw == NULL || pw->pw_uid < 1) |
102 | return util_finish (command, RESP_NO, "User name or passwd rejected"); | 102 | return util_finish (command, RESP_NO, "User name or passwd rejected"); |
103 | if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) | 103 | if (strcmp (pw->pw_passwd, (char *)crypt (pass, pw->pw_passwd))) |
104 | { | 104 | { |
105 | #ifdef HAVE_SHADOW_H | 105 | #ifdef HAVE_SHADOW_H |
106 | struct spwd *spw; | 106 | struct spwd *spw; | ... | ... |
... | @@ -18,8 +18,8 @@ | ... | @@ -18,8 +18,8 @@ |
18 | #include "imap4d.h" | 18 | #include "imap4d.h" |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * | 21 | FIXME: Renaming a mailbox we must change the UIDVALIDITY |
22 | */ | 22 | of the mailbox. */ |
23 | 23 | ||
24 | int | 24 | int |
25 | imap4d_rename (struct imap4d_command *command, char *arg) | 25 | imap4d_rename (struct imap4d_command *command, char *arg) | ... | ... |
... | @@ -340,6 +340,51 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...) | ... | @@ -340,6 +340,51 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...) |
340 | return status; | 340 | return status; |
341 | } | 341 | } |
342 | 342 | ||
343 | #if 0 | ||
344 | /* Need a replacement for readline that can support literals. */ | ||
345 | char * | ||
346 | imap4d_readline (FILE *fp) | ||
347 | { | ||
348 | char buffer[512]; | ||
349 | char *line; | ||
350 | size_t len; | ||
351 | |||
352 | alarm (timeout); | ||
353 | line = fgets (buffer, sizeof (buffer), fp); | ||
354 | alarm (0); | ||
355 | if (!line) | ||
356 | util_quit (1); | ||
357 | line = strdup (buffer); | ||
358 | len = strlen (buffer); | ||
359 | if (len > 2) | ||
360 | { | ||
361 | len--; /* C arrays are 0-based. */ | ||
362 | if (line[len] == '\n' && line[len - 1] == '}') | ||
363 | { | ||
364 | while (len && line[len] != '{') len--; | ||
365 | if (line [len] == '{') | ||
366 | { | ||
367 | char *sp = NULL; | ||
368 | long number = strtoul (line + len + 1, &sp, 10); | ||
369 | if (*sp != '+') | ||
370 | util_send ("+ GO AHEAD\r\n"); | ||
371 | line[len] = '\0'; | ||
372 | while (number > 0) | ||
373 | { | ||
374 | char *literal = imap4d_readline (fd); | ||
375 | size_t n = strlen (literal); | ||
376 | line = realloc (line, strlen (line) + n + 1); | ||
377 | strcat (line, literal); | ||
378 | number -= n; | ||
379 | free (literal); | ||
380 | } | ||
381 | } | ||
382 | } | ||
383 | } | ||
384 | return line; | ||
385 | } | ||
386 | #endif | ||
387 | |||
343 | char * | 388 | char * |
344 | imap4d_readline (int fd) | 389 | imap4d_readline (int fd) |
345 | { | 390 | { | ... | ... |
... | @@ -642,7 +642,7 @@ va_list args; | ... | @@ -642,7 +642,7 @@ va_list args; |
642 | #ifndef HAVE_SNPRINTF | 642 | #ifndef HAVE_SNPRINTF |
643 | 643 | ||
644 | PUBLIC int | 644 | PUBLIC int |
645 | #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ | 645 | #if __STDC__ |
646 | snprintf(char *string, size_t length, const char * format, ...) | 646 | snprintf(char *string, size_t length, const char * format, ...) |
647 | #else | 647 | #else |
648 | snprintf(string, length, format, va_alist) | 648 | snprintf(string, length, format, va_alist) |
... | @@ -655,7 +655,7 @@ va_dcl | ... | @@ -655,7 +655,7 @@ va_dcl |
655 | int rval; | 655 | int rval; |
656 | va_list args; | 656 | va_list args; |
657 | 657 | ||
658 | #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ | 658 | #if __STDC__ |
659 | va_start(args, format); | 659 | va_start(args, format); |
660 | #else | 660 | #else |
661 | va_start(args); | 661 | va_start(args); | ... | ... |
... | @@ -39,7 +39,7 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca | ... | @@ -39,7 +39,7 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca |
39 | #include <config.h> | 39 | #include <config.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ | 42 | #if __STDC__ |
43 | #include <stdarg.h> | 43 | #include <stdarg.h> |
44 | #else | 44 | #else |
45 | #include <varargs.h> | 45 | #include <varargs.h> | ... | ... |
... | @@ -17,6 +17,13 @@ | ... | @@ -17,6 +17,13 @@ |
17 | 17 | ||
18 | #include "mail.h" | 18 | #include "mail.h" |
19 | 19 | ||
20 | /* Global variables and constants*/ | ||
21 | mailbox_t mbox; | ||
22 | unsigned int cursor; | ||
23 | unsigned int realcursor; | ||
24 | unsigned int total; | ||
25 | FILE *ofile; | ||
26 | |||
20 | const char *argp_program_version = "mail (" PACKAGE ") " VERSION; | 27 | const char *argp_program_version = "mail (" PACKAGE ") " VERSION; |
21 | const char *argp_program_bug_address = "<bug-mailutils@gnu.org>"; | 28 | const char *argp_program_bug_address = "<bug-mailutils@gnu.org>"; |
22 | static char doc[] = "GNU mail -- the standard /bin/mail interface"; | 29 | static char doc[] = "GNU mail -- the standard /bin/mail interface"; | ... | ... |
... | @@ -83,11 +83,11 @@ struct mail_env_entry { | ... | @@ -83,11 +83,11 @@ struct mail_env_entry { |
83 | }; | 83 | }; |
84 | 84 | ||
85 | /* Global variables and constants*/ | 85 | /* Global variables and constants*/ |
86 | mailbox_t mbox; | 86 | extern mailbox_t mbox; |
87 | unsigned int cursor; | 87 | extern unsigned int cursor; |
88 | unsigned int realcursor; | 88 | extern unsigned int realcursor; |
89 | unsigned int total; | 89 | extern unsigned int total; |
90 | FILE *ofile; | 90 | extern FILE *ofile; |
91 | extern const struct mail_command_entry mail_command_table[]; | 91 | extern const struct mail_command_entry mail_command_table[]; |
92 | 92 | ||
93 | /* Functions */ | 93 | /* Functions */ | ... | ... |
... | @@ -30,7 +30,7 @@ mail_pipe (int argc, char **argv) | ... | @@ -30,7 +30,7 @@ mail_pipe (int argc, char **argv) |
30 | char *cmd; | 30 | char *cmd; |
31 | FILE *pipe; | 31 | FILE *pipe; |
32 | int *list, num = 0; | 32 | int *list, num = 0; |
33 | char buffer[BUFSIZ]; | 33 | char buffer[512]; |
34 | off_t off = 0; | 34 | off_t off = 0; |
35 | size_t n = 0; | 35 | size_t n = 0; |
36 | 36 | ... | ... |
... | @@ -36,7 +36,7 @@ mail_print (int argc, char **argv) | ... | @@ -36,7 +36,7 @@ mail_print (int argc, char **argv) |
36 | header_t hdr; | 36 | header_t hdr; |
37 | body_t body; | 37 | body_t body; |
38 | stream_t stream; | 38 | stream_t stream; |
39 | char buffer[BUFSIZ]; | 39 | char buffer[512]; |
40 | off_t off = 0; | 40 | off_t off = 0; |
41 | size_t n = 0, lines = 0; | 41 | size_t n = 0, lines = 0; |
42 | FILE *out = ofile; | 42 | FILE *out = ofile; | ... | ... |
... | @@ -30,7 +30,7 @@ mail_top (int argc, char **argv) | ... | @@ -30,7 +30,7 @@ mail_top (int argc, char **argv) |
30 | { | 30 | { |
31 | message_t msg; | 31 | message_t msg; |
32 | stream_t stream; | 32 | stream_t stream; |
33 | char buf[BUFSIZ]; | 33 | char buf[512]; |
34 | size_t n; | 34 | size_t n; |
35 | off_t off; | 35 | off_t off; |
36 | int lines = strtol ((util_find_env("toplines"))->value, NULL, 10); | 36 | int lines = strtol ((util_find_env("toplines"))->value, NULL, 10); | ... | ... |
... | @@ -35,7 +35,7 @@ mail_write (int argc, char **argv) | ... | @@ -35,7 +35,7 @@ mail_write (int argc, char **argv) |
35 | stream_t stream; | 35 | stream_t stream; |
36 | FILE *output; | 36 | FILE *output; |
37 | char *filename = NULL; | 37 | char *filename = NULL; |
38 | char buffer[BUFSIZ]; | 38 | char buffer[512]; |
39 | off_t off = 0; | 39 | off_t off = 0; |
40 | size_t n = 0; | 40 | size_t n = 0; |
41 | int *msglist = NULL; | 41 | int *msglist = NULL; | ... | ... |
... | @@ -58,6 +58,9 @@ static struct _record _imap_record = | ... | @@ -58,6 +58,9 @@ static struct _record _imap_record = |
58 | via the register entry/record. */ | 58 | via the register entry/record. */ |
59 | record_t imap_record = &_imap_record; | 59 | record_t imap_record = &_imap_record; |
60 | 60 | ||
61 | #ifndef HAVE_STRTOK_R | ||
62 | char *strtok_r __P ((char *, const char *, char **)); | ||
63 | #endif | ||
61 | /* Concrete IMAP implementation. */ | 64 | /* Concrete IMAP implementation. */ |
62 | static int folder_imap_open __P ((folder_t, int)); | 65 | static int folder_imap_open __P ((folder_t, int)); |
63 | static int folder_imap_create __P ((folder_t)); | 66 | static int folder_imap_create __P ((folder_t)); | ... | ... |
... | @@ -69,8 +69,8 @@ pop3d_apopuser (const char *user) | ... | @@ -69,8 +69,8 @@ pop3d_apopuser (const char *user) |
69 | return NULL; | 69 | return NULL; |
70 | } | 70 | } |
71 | 71 | ||
72 | memset (&key, 0, sizeof (DBT)); | 72 | memset (&key, 0, sizeof DBT); |
73 | memset (&data, 0, sizeof (DBT)); | 73 | memset (&data, 0, sizeof DBT); |
74 | 74 | ||
75 | strncpy (buf, user, sizeof buf); | 75 | strncpy (buf, user, sizeof buf); |
76 | /* strncpy () is lame and does not NULL terminate. */ | 76 | /* strncpy () is lame and does not NULL terminate. */ | ... | ... |
... | @@ -154,81 +154,35 @@ pop3d_usage (char *argv0) | ... | @@ -154,81 +154,35 @@ pop3d_usage (char *argv0) |
154 | RETSIGTYPE | 154 | RETSIGTYPE |
155 | pop3d_signal (int signo) | 155 | pop3d_signal (int signo) |
156 | { | 156 | { |
157 | (void)signo; | ||
158 | syslog (LOG_CRIT, "got signal %d", signo); | 157 | syslog (LOG_CRIT, "got signal %d", signo); |
158 | /* Master process. */ | ||
159 | if (!ofile) | ||
160 | { | ||
161 | syslog(LOG_CRIT, "MASTER: exiting on signal"); | ||
162 | exit (1); /* abort(); */ | ||
163 | } | ||
164 | |||
165 | if (signo == SIGALRM) | ||
166 | pop3d_abquit (ERR_TIMEOUT); | ||
159 | pop3d_abquit (ERR_SIGNAL); | 167 | pop3d_abquit (ERR_SIGNAL); |
160 | } | 168 | } |
161 | 169 | ||
162 | /* Gets a line of input from the client */ | 170 | /* Gets a line of input from the client, caller should free() */ |
163 | /* We can also implement PIPELINING by keeping a static buffer. | ||
164 | Implementing this cost an extra allocation with more uglier code. | ||
165 | Is it worth it? How many clients actually use PIPELINING? | ||
166 | */ | ||
167 | char * | 171 | char * |
168 | pop3d_readline (int fd) | 172 | pop3d_readline (FILE *fp) |
169 | { | 173 | { |
170 | static char *buffer = NULL; /* Note: This buffer is never free()d. */ | 174 | static char buffer[512]; |
171 | static size_t total = 0; | 175 | char *ptr; |
172 | char *nl; | ||
173 | char *line; | ||
174 | size_t len; | ||
175 | |||
176 | nl = memchr (buffer, '\n', total); | ||
177 | if (!nl) | ||
178 | { | ||
179 | /* Need to refill the buffer. */ | ||
180 | do | ||
181 | { | ||
182 | char buf[512]; | ||
183 | int nread; | ||
184 | |||
185 | if (timeout) | ||
186 | { | ||
187 | int available; | ||
188 | fd_set rfds; | ||
189 | struct timeval tv; | ||
190 | 176 | ||
191 | FD_ZERO (&rfds); | 177 | alarm (timeout); |
192 | FD_SET (fd, &rfds); | 178 | ptr = fgets (buffer, sizeof (buffer), fp); |
193 | tv.tv_sec = timeout; | 179 | alarm (0); |
194 | tv.tv_usec = 0; | ||
195 | |||
196 | available = select (fd + 1, &rfds, NULL, NULL, &tv); | ||
197 | if (!available) | ||
198 | pop3d_abquit (ERR_TIMEOUT); | ||
199 | else if (available == -1) | ||
200 | { | ||
201 | if (errno == EINTR) | ||
202 | continue; | ||
203 | pop3d_abquit (ERR_NO_OFILE); | ||
204 | } | ||
205 | } | ||
206 | 180 | ||
207 | errno = 0; | 181 | /* We should probably check ferror() too, but if ptr is null we |
208 | nread = read (fd, buf, sizeof (buf) - 1); | 182 | are done anyway; if (!ptr && ferror(fp)) */ |
209 | if (nread < 1) | 183 | if (!ptr) |
210 | { | ||
211 | if (errno == EINTR) | ||
212 | continue; | ||
213 | pop3d_abquit (ERR_NO_OFILE); | 184 | pop3d_abquit (ERR_NO_OFILE); |
214 | } | ||
215 | buf[nread] = '\0'; | ||
216 | |||
217 | buffer = realloc (buffer, (total + nread + 1) * sizeof (*buffer)); | ||
218 | if (buffer == NULL) | ||
219 | pop3d_abquit (ERR_NO_MEM); | ||
220 | memcpy (buffer + total, buf, nread + 1); /* copy the null too. */ | ||
221 | total += nread; | ||
222 | } | ||
223 | while ((nl = memchr (buffer, '\n', total)) == NULL); | ||
224 | } | ||
225 | 185 | ||
226 | nl++; | 186 | /* Caller should not free () this ... should we strdup() then? */ |
227 | len = nl - buffer; | 187 | return ptr; |
228 | line = calloc (len + 1, sizeof (*line)); | ||
229 | memcpy (line, buffer, len); /* copy the newline too. */ | ||
230 | line[len] = '\0'; | ||
231 | total -= len; | ||
232 | memmove (buffer, nl, total); | ||
233 | return line; | ||
234 | } | 188 | } | ... | ... |
... | @@ -21,7 +21,7 @@ mailbox_t mbox; | ... | @@ -21,7 +21,7 @@ mailbox_t mbox; |
21 | size_t timeout; | 21 | size_t timeout; |
22 | int state; | 22 | int state; |
23 | char *username; | 23 | char *username; |
24 | int ifile; | 24 | FILE *ifile; |
25 | FILE *ofile; | 25 | FILE *ofile; |
26 | char *md5shared; | 26 | char *md5shared; |
27 | /* Number of child processes. */ | 27 | /* Number of child processes. */ |
... | @@ -224,10 +224,12 @@ pop3d_mainloop (int infile, int outfile) | ... | @@ -224,10 +224,12 @@ pop3d_mainloop (int infile, int outfile) |
224 | 224 | ||
225 | /* Reset hup to exit. */ | 225 | /* Reset hup to exit. */ |
226 | signal (SIGHUP, pop3d_signal); | 226 | signal (SIGHUP, pop3d_signal); |
227 | /* Timeout alarm. */ | ||
228 | signal (SIGALRM, pop3d_signal); | ||
227 | 229 | ||
228 | ifile = infile; | 230 | ifile = fdopen (infile, "r"); |
229 | ofile = fdopen (outfile, "w"); | 231 | ofile = fdopen (outfile, "w"); |
230 | if (ofile == NULL) | 232 | if (!ofile || !ofile) |
231 | pop3d_abquit (ERR_NO_OFILE); | 233 | pop3d_abquit (ERR_NO_OFILE); |
232 | 234 | ||
233 | state = AUTHORIZATION; | 235 | state = AUTHORIZATION; |
... | @@ -303,6 +305,9 @@ pop3d_mainloop (int infile, int outfile) | ... | @@ -303,6 +305,9 @@ pop3d_mainloop (int infile, int outfile) |
303 | pop3d_abquit (ERR_MBOX_SYNC); /* Out of sync, Bail out. */ | 305 | pop3d_abquit (ERR_MBOX_SYNC); /* Out of sync, Bail out. */ |
304 | } | 306 | } |
305 | 307 | ||
308 | /* Refresh the Lock. */ | ||
309 | pop3d_touchlock (); | ||
310 | |||
306 | if (strlen (arg) > POP_MAXCMDLEN || strlen (cmd) > POP_MAXCMDLEN) | 311 | if (strlen (arg) > POP_MAXCMDLEN || strlen (cmd) > POP_MAXCMDLEN) |
307 | status = ERR_TOO_LONG; | 312 | status = ERR_TOO_LONG; |
308 | else if (strlen (cmd) > 4) | 313 | else if (strlen (cmd) > 4) |
... | @@ -361,7 +366,6 @@ pop3d_mainloop (int infile, int outfile) | ... | @@ -361,7 +366,6 @@ pop3d_mainloop (int infile, int outfile) |
361 | else | 366 | else |
362 | fprintf (ofile, "-ERR unknown error\r\n"); | 367 | fprintf (ofile, "-ERR unknown error\r\n"); |
363 | 368 | ||
364 | free (buf); | ||
365 | free (cmd); | 369 | free (cmd); |
366 | free (arg); | 370 | free (arg); |
367 | } | 371 | } | ... | ... |
... | @@ -167,11 +167,10 @@ | ... | @@ -167,11 +167,10 @@ |
167 | #endif /* __P */ | 167 | #endif /* __P */ |
168 | 168 | ||
169 | extern mailbox_t mbox; | 169 | extern mailbox_t mbox; |
170 | |||
171 | extern unsigned int timeout; | 170 | extern unsigned int timeout; |
172 | extern int state; | 171 | extern int state; |
173 | extern char *username; | 172 | extern char *username; |
174 | extern int ifile; | 173 | extern FILE *ifile; |
175 | extern FILE *ofile; | 174 | extern FILE *ofile; |
176 | extern char *md5shared; | 175 | extern char *md5shared; |
177 | extern volatile size_t children; | 176 | extern volatile size_t children; |
... | @@ -202,5 +201,5 @@ extern RETSIGTYPE pop3d_signal __P ((int)); | ... | @@ -202,5 +201,5 @@ extern RETSIGTYPE pop3d_signal __P ((int)); |
202 | extern RETSIGTYPE pop3d_sigchld __P ((int)); | 201 | extern RETSIGTYPE pop3d_sigchld __P ((int)); |
203 | extern void pop3d_daemon_init __P ((void)); | 202 | extern void pop3d_daemon_init __P ((void)); |
204 | extern char *pop3d_apopuser __P ((const char *)); | 203 | extern char *pop3d_apopuser __P ((const char *)); |
205 | extern char *pop3d_readline __P ((int)); | 204 | extern char *pop3d_readline __P ((FILE *)); |
206 | #endif /* _POP3D_H */ | 205 | #endif /* _POP3D_H */ | ... | ... |
... | @@ -96,7 +96,6 @@ pop3d_user (const char *arg) | ... | @@ -96,7 +96,6 @@ pop3d_user (const char *arg) |
96 | buf = pop3d_readline (ifile); | 96 | buf = pop3d_readline (ifile); |
97 | cmd = pop3d_cmd (buf); | 97 | cmd = pop3d_cmd (buf); |
98 | tmp = pop3d_args (buf); | 98 | tmp = pop3d_args (buf); |
99 | free (buf); | ||
100 | 99 | ||
101 | if (strlen (tmp) > POP_MAXCMDLEN) | 100 | if (strlen (tmp) > POP_MAXCMDLEN) |
102 | { | 101 | { |
... | @@ -137,12 +136,13 @@ pop3d_user (const char *arg) | ... | @@ -137,12 +136,13 @@ pop3d_user (const char *arg) |
137 | #ifndef USE_LIBPAM | 136 | #ifndef USE_LIBPAM |
138 | if (pw == NULL || pw->pw_uid < 1) | 137 | if (pw == NULL || pw->pw_uid < 1) |
139 | return ERR_BAD_LOGIN; | 138 | return ERR_BAD_LOGIN; |
140 | if (strcmp (pw->pw_passwd, crypt (pass, pw->pw_passwd))) | 139 | if (strcmp (pw->pw_passwd, (char *)crypt (pass, pw->pw_passwd))) |
141 | { | 140 | { |
142 | #ifdef HAVE_SHADOW_H | 141 | #ifdef HAVE_SHADOW_H |
143 | struct spwd *spw; | 142 | struct spwd *spw; |
144 | spw = getspnam ((char *)arg); | 143 | spw = getspnam ((char *)arg); |
145 | if (spw == NULL || strcmp (spw->sp_pwdp, crypt (pass, spw->sp_pwdp))) | 144 | if (spw == NULL || strcmp (spw->sp_pwdp, |
145 | (char *)crypt (pass, spw->sp_pwdp))) | ||
146 | #endif /* HAVE_SHADOW_H */ | 146 | #endif /* HAVE_SHADOW_H */ |
147 | { | 147 | { |
148 | syslog (LOG_INFO, "User '%s': authentication failed", arg); | 148 | syslog (LOG_INFO, "User '%s': authentication failed", arg); |
... | @@ -155,6 +155,8 @@ pop3d_user (const char *arg) | ... | @@ -155,6 +155,8 @@ pop3d_user (const char *arg) |
155 | int pamerror; | 155 | int pamerror; |
156 | _user = (char *) arg; | 156 | _user = (char *) arg; |
157 | _pwd = pass; | 157 | _pwd = pass; |
158 | /* libpam doesn't log to LOG_MAIL */ | ||
159 | closelog (); | ||
158 | pamerror = pam_start ("gnu-pop3d", arg, &PAM_conversation, &pamh); | 160 | pamerror = pam_start ("gnu-pop3d", arg, &PAM_conversation, &pamh); |
159 | PAM_ERROR; | 161 | PAM_ERROR; |
160 | pamerror = pam_authenticate (pamh, 0); | 162 | pamerror = pam_authenticate (pamh, 0); |
... | @@ -165,6 +167,7 @@ pop3d_user (const char *arg) | ... | @@ -165,6 +167,7 @@ pop3d_user (const char *arg) |
165 | PAM_ERROR; | 167 | PAM_ERROR; |
166 | pam_errlab: | 168 | pam_errlab: |
167 | pam_end (pamh, PAM_SUCCESS); | 169 | pam_end (pamh, PAM_SUCCESS); |
170 | openlog ("gnu-pop3d", LOG_PID, LOG_FACILITY); | ||
168 | if (pamerror != PAM_SUCCESS) | 171 | if (pamerror != PAM_SUCCESS) |
169 | { | 172 | { |
170 | syslog (LOG_INFO, "User '%s': authentication failed", _user); | 173 | syslog (LOG_INFO, "User '%s': authentication failed", _user); |
... | @@ -176,8 +179,8 @@ pop3d_user (const char *arg) | ... | @@ -176,8 +179,8 @@ pop3d_user (const char *arg) |
176 | if (pw != NULL && pw->pw_uid > 1) | 179 | if (pw != NULL && pw->pw_uid > 1) |
177 | setuid (pw->pw_uid); | 180 | setuid (pw->pw_uid); |
178 | 181 | ||
179 | if ((status = mailbox_create_default (&mbox, arg) != 0) | 182 | if ((status = mailbox_create_default (&mbox, arg)) != 0 |
180 | || (status = mailbox_open (mbox, MU_STREAM_RDWR) != 0)) | 183 | || (status = mailbox_open (mbox, MU_STREAM_RDWR)) != 0) |
181 | { | 184 | { |
182 | mailbox_destroy (&mbox); | 185 | mailbox_destroy (&mbox); |
183 | /* For non existent mailbox, we fake. */ | 186 | /* For non existent mailbox, we fake. */ | ... | ... |
-
Please register or sign in to post a comment