Patches from Sergey, se Changelog for details:
2001-04-23 Sergey Poznyakoff
Showing
20 changed files
with
218 additions
and
144 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 | { | ... | ... |
... | @@ -2,21 +2,21 @@ | ... | @@ -2,21 +2,21 @@ |
2 | /* | 2 | /* |
3 | Unix snprintf implementation. | 3 | Unix snprintf implementation. |
4 | Version 1.3 | 4 | Version 1.3 |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU Library General Public License as published by | 7 | it under the terms of the GNU Library General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU Library General Public License for more details. | 14 | GNU Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | 19 | ||
20 | Revision History: | 20 | Revision History: |
21 | 21 | ||
22 | 1.3: | 22 | 1.3: |
... | @@ -55,7 +55,7 @@ pow_10(int n) | ... | @@ -55,7 +55,7 @@ pow_10(int n) |
55 | pow_10(n) | 55 | pow_10(n) |
56 | int n; | 56 | int n; |
57 | #endif | 57 | #endif |
58 | { | 58 | { |
59 | int i; | 59 | int i; |
60 | double P; | 60 | double P; |
61 | 61 | ||
... | @@ -67,7 +67,7 @@ int n; | ... | @@ -67,7 +67,7 @@ int n; |
67 | } | 67 | } |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Find the integral part of the log in base 10 | 70 | * Find the integral part of the log in base 10 |
71 | * Note: this not a real log10() | 71 | * Note: this not a real log10() |
72 | I just need and approximation(integerpart) of x in: | 72 | I just need and approximation(integerpart) of x in: |
73 | 10^x ~= r | 73 | 10^x ~= r |
... | @@ -81,7 +81,7 @@ log_10(double r) | ... | @@ -81,7 +81,7 @@ log_10(double r) |
81 | log_10(r) | 81 | log_10(r) |
82 | double r; | 82 | double r; |
83 | #endif | 83 | #endif |
84 | { | 84 | { |
85 | int i = 0; | 85 | int i = 0; |
86 | double result = 1.; | 86 | double result = 1.; |
87 | 87 | ||
... | @@ -110,7 +110,7 @@ integral(real, ip) | ... | @@ -110,7 +110,7 @@ integral(real, ip) |
110 | double real; | 110 | double real; |
111 | double * ip; | 111 | double * ip; |
112 | #endif | 112 | #endif |
113 | { | 113 | { |
114 | int j; | 114 | int j; |
115 | double i, s, p; | 115 | double i, s, p; |
116 | double real_integral = 0.; | 116 | double real_integral = 0.; |
... | @@ -144,11 +144,11 @@ double * ip; | ... | @@ -144,11 +144,11 @@ double * ip; |
144 | } | 144 | } |
145 | 145 | ||
146 | #define PRECISION 1.e-6 | 146 | #define PRECISION 1.e-6 |
147 | /* | 147 | /* |
148 | * return an ascii representation of the integral part of the number | 148 | * return an ascii representation of the integral part of the number |
149 | * and set fract to be an ascii representation of the fraction part | 149 | * and set fract to be an ascii representation of the fraction part |
150 | * the container for the fraction and the integral part or staticly | 150 | * the container for the fraction and the integral part or staticly |
151 | * declare with fix size | 151 | * declare with fix size |
152 | */ | 152 | */ |
153 | PRIVATE char * | 153 | PRIVATE char * |
154 | #ifdef __STDC__ | 154 | #ifdef __STDC__ |
... | @@ -171,7 +171,7 @@ char ** fract; | ... | @@ -171,7 +171,7 @@ char ** fract; |
171 | int ch; | 171 | int ch; |
172 | 172 | ||
173 | /* taking care of the obvious case: 0.0 */ | 173 | /* taking care of the obvious case: 0.0 */ |
174 | if (number == 0.) { | 174 | if (number == 0.) { |
175 | integral_part[0] = '0'; | 175 | integral_part[0] = '0'; |
176 | integral_part[1] = '\0'; | 176 | integral_part[1] = '\0'; |
177 | fraction_part[0] = '0'; | 177 | fraction_part[0] = '0'; |
... | @@ -183,7 +183,7 @@ char ** fract; | ... | @@ -183,7 +183,7 @@ char ** fract; |
183 | if ((sign = number) < 0.) { | 183 | if ((sign = number) < 0.) { |
184 | number = -number; | 184 | number = -number; |
185 | digits--; /* sign consume one digit */ | 185 | digits--; /* sign consume one digit */ |
186 | } | 186 | } |
187 | 187 | ||
188 | fraction = integral(number, &ip); | 188 | fraction = integral(number, &ip); |
189 | number = ip; | 189 | number = ip; |
... | @@ -198,11 +198,11 @@ char ** fract; | ... | @@ -198,11 +198,11 @@ char ** fract; |
198 | ch = (int)((fp + PRECISION)*base); /* force to round */ | 198 | ch = (int)((fp + PRECISION)*base); /* force to round */ |
199 | integral_part[i] = (ch <= 9) ? ch + '0' : ch + 'a' - 10; | 199 | integral_part[i] = (ch <= 9) ? ch + '0' : ch + 'a' - 10; |
200 | if (! isxdigit(integral_part[i])) /* bail out overflow !! */ | 200 | if (! isxdigit(integral_part[i])) /* bail out overflow !! */ |
201 | break; | 201 | break; |
202 | number = ip; | 202 | number = ip; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | /* Oh No !! out of bound, ho well fill it up ! */ | 206 | /* Oh No !! out of bound, ho well fill it up ! */ |
207 | if (number != 0.) | 207 | if (number != 0.) |
208 | for (i = 0; i < digits; ++i) | 208 | for (i = 0; i < digits; ++i) |
... | @@ -216,7 +216,7 @@ char ** fract; | ... | @@ -216,7 +216,7 @@ char ** fract; |
216 | 216 | ||
217 | /* reverse every thing */ | 217 | /* reverse every thing */ |
218 | for ( i--, j = 0; j < i; j++, i--) | 218 | for ( i--, j = 0; j < i; j++, i--) |
219 | SWAP_INT(integral_part[i], integral_part[j]); | 219 | SWAP_INT(integral_part[i], integral_part[j]); |
220 | 220 | ||
221 | /* the fractionnal part */ | 221 | /* the fractionnal part */ |
222 | for (i=0, fp=fraction; precision > 0 && i < MAX_FRACT ; i++, precision-- ) { | 222 | for (i=0, fp=fraction; precision > 0 && i < MAX_FRACT ; i++, precision-- ) { |
... | @@ -354,7 +354,7 @@ double d; | ... | @@ -354,7 +354,7 @@ double d; |
354 | ((d > 0. && p->justify == RIGHT) ? 1:0) - | 354 | ((d > 0. && p->justify == RIGHT) ? 1:0) - |
355 | ((p->space == FOUND) ? 1:0) - | 355 | ((p->space == FOUND) ? 1:0) - |
356 | strlen(tmp) - p->precision - 1; | 356 | strlen(tmp) - p->precision - 1; |
357 | PAD_RIGHT(p); | 357 | PAD_RIGHT(p); |
358 | PUT_PLUS(d, p); | 358 | PUT_PLUS(d, p); |
359 | PUT_SPACE(d, p); | 359 | PUT_SPACE(d, p); |
360 | while (*tmp) { /* the integral */ | 360 | while (*tmp) { /* the integral */ |
... | @@ -365,12 +365,12 @@ double d; | ... | @@ -365,12 +365,12 @@ double d; |
365 | PUT_CHAR('.', p); /* put the '.' */ | 365 | PUT_CHAR('.', p); /* put the '.' */ |
366 | if (*p->pf == 'g' || *p->pf == 'G') /* smash the trailing zeros */ | 366 | if (*p->pf == 'g' || *p->pf == 'G') /* smash the trailing zeros */ |
367 | for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) | 367 | for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) |
368 | tmp2[i] = '\0'; | 368 | tmp2[i] = '\0'; |
369 | for (; *tmp2; tmp2++) | 369 | for (; *tmp2; tmp2++) |
370 | PUT_CHAR(*tmp2, p); /* the fraction */ | 370 | PUT_CHAR(*tmp2, p); /* the fraction */ |
371 | 371 | ||
372 | PAD_LEFT(p); | 372 | PAD_LEFT(p); |
373 | } | 373 | } |
374 | 374 | ||
375 | /* %e %E %g exponent representation */ | 375 | /* %e %E %g exponent representation */ |
376 | PRIVATE void | 376 | PRIVATE void |
... | @@ -388,12 +388,12 @@ double d; | ... | @@ -388,12 +388,12 @@ double d; |
388 | DEF_PREC(p); | 388 | DEF_PREC(p); |
389 | j = log_10(d); | 389 | j = log_10(d); |
390 | d = d / pow_10(j); /* get the Mantissa */ | 390 | d = d / pow_10(j); /* get the Mantissa */ |
391 | d = ROUND(d, p); | 391 | d = ROUND(d, p); |
392 | tmp = dtoa(d, p->precision, &tmp2); | 392 | tmp = dtoa(d, p->precision, &tmp2); |
393 | /* 1 for unit, 1 for the '.', 1 for 'e|E', | 393 | /* 1 for unit, 1 for the '.', 1 for 'e|E', |
394 | * 1 for '+|-', 3 for 'exp' */ | 394 | * 1 for '+|-', 3 for 'exp' */ |
395 | /* calculate how much padding need */ | 395 | /* calculate how much padding need */ |
396 | p->width = p->width - | 396 | p->width = p->width - |
397 | ((d > 0. && p->justify == RIGHT) ? 1:0) - | 397 | ((d > 0. && p->justify == RIGHT) ? 1:0) - |
398 | ((p->space == FOUND) ? 1:0) - p->precision - 7; | 398 | ((p->space == FOUND) ? 1:0) - p->precision - 7; |
399 | PAD_RIGHT(p); | 399 | PAD_RIGHT(p); |
... | @@ -407,7 +407,7 @@ double d; | ... | @@ -407,7 +407,7 @@ double d; |
407 | PUT_CHAR('.', p); /* the '.' */ | 407 | PUT_CHAR('.', p); /* the '.' */ |
408 | if (*p->pf == 'g' || *p->pf == 'G') /* smash the trailing zeros */ | 408 | if (*p->pf == 'g' || *p->pf == 'G') /* smash the trailing zeros */ |
409 | for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) | 409 | for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) |
410 | tmp2[i] = '\0'; | 410 | tmp2[i] = '\0'; |
411 | for (; *tmp2; tmp2++) | 411 | for (; *tmp2; tmp2++) |
412 | PUT_CHAR(*tmp2, p); /* the fraction */ | 412 | PUT_CHAR(*tmp2, p); /* the fraction */ |
413 | 413 | ||
... | @@ -470,7 +470,7 @@ struct DATA * p; | ... | @@ -470,7 +470,7 @@ struct DATA * p; |
470 | case '1': case '2': case '3': | 470 | case '1': case '2': case '3': |
471 | case '4': case '5': case '6': | 471 | case '4': case '5': case '6': |
472 | case '7': case '8': case '9': /* gob all the digits */ | 472 | case '7': case '8': case '9': /* gob all the digits */ |
473 | for (i = 0; isdigit(*s); i++, s++) | 473 | for (i = 0; isdigit(*s); i++, s++) |
474 | if (i < MAX_FIELD/2 - 1) | 474 | if (i < MAX_FIELD/2 - 1) |
475 | number[i] = *s; | 475 | number[i] = *s; |
476 | number[i] = '\0'; | 476 | number[i] = '\0'; |
... | @@ -524,10 +524,10 @@ va_list args; | ... | @@ -524,10 +524,10 @@ va_list args; |
524 | case 'f': /* float, double */ | 524 | case 'f': /* float, double */ |
525 | STAR_ARGS(&data); | 525 | STAR_ARGS(&data); |
526 | d = va_arg(args, double); | 526 | d = va_arg(args, double); |
527 | floating(&data, d); | 527 | floating(&data, d); |
528 | state = 0; | 528 | state = 0; |
529 | break; | 529 | break; |
530 | case 'g': | 530 | case 'g': |
531 | case 'G': | 531 | case 'G': |
532 | STAR_ARGS(&data); | 532 | STAR_ARGS(&data); |
533 | DEF_PREC(&data); | 533 | DEF_PREC(&data); |
... | @@ -559,7 +559,7 @@ va_list args; | ... | @@ -559,7 +559,7 @@ va_list args; |
559 | d = va_arg(args, unsigned int); | 559 | d = va_arg(args, unsigned int); |
560 | decimal(&data, d); | 560 | decimal(&data, d); |
561 | state = 0; | 561 | state = 0; |
562 | break; | 562 | break; |
563 | case 'd': /* decimal */ | 563 | case 'd': /* decimal */ |
564 | STAR_ARGS(&data); | 564 | STAR_ARGS(&data); |
565 | if (data.a_long == FOUND) | 565 | if (data.a_long == FOUND) |
... | @@ -578,7 +578,7 @@ va_list args; | ... | @@ -578,7 +578,7 @@ va_list args; |
578 | octal(&data, d); | 578 | octal(&data, d); |
579 | state = 0; | 579 | state = 0; |
580 | break; | 580 | break; |
581 | case 'x': | 581 | case 'x': |
582 | case 'X': /* hexadecimal */ | 582 | case 'X': /* hexadecimal */ |
583 | STAR_ARGS(&data); | 583 | STAR_ARGS(&data); |
584 | if (data.a_long == FOUND) | 584 | if (data.a_long == FOUND) |
... | @@ -612,11 +612,11 @@ va_list args; | ... | @@ -612,11 +612,11 @@ va_list args; |
612 | state = 0; | 612 | state = 0; |
613 | break; | 613 | break; |
614 | case '#': case ' ': case '+': case '*': | 614 | case '#': case ' ': case '+': case '*': |
615 | case '-': case '.': case '0': case '1': | 615 | case '-': case '.': case '0': case '1': |
616 | case '2': case '3': case '4': case '5': | 616 | case '2': case '3': case '4': case '5': |
617 | case '6': case '7': case '8': case '9': | 617 | case '6': case '7': case '8': case '9': |
618 | /* initialize width and precision */ | 618 | /* initialize width and precision */ |
619 | for (i = 0; isflag(*data.pf); i++, data.pf++) | 619 | for (i = 0; isflag(*data.pf); i++, data.pf++) |
620 | if (i < MAX_FIELD - 1) | 620 | if (i < MAX_FIELD - 1) |
621 | conv_field[i] = *data.pf; | 621 | conv_field[i] = *data.pf; |
622 | conv_field[i] = '\0'; | 622 | conv_field[i] = '\0'; |
... | @@ -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); |
... | @@ -808,7 +808,7 @@ void main() | ... | @@ -808,7 +808,7 @@ void main() |
808 | printf("abc%n", &i); printf("%d\n", i); | 808 | printf("abc%n", &i); printf("%d\n", i); |
809 | snprintf(holder, sizeof holder, "abc%n", &i); | 809 | snprintf(holder, sizeof holder, "abc%n", &i); |
810 | printf("%s", holder); printf("%d\n\n", i); | 810 | printf("%s", holder); printf("%d\n\n", i); |
811 | 811 | ||
812 | printf("%%*.*s --> 10.10\n"); | 812 | printf("%%*.*s --> 10.10\n"); |
813 | snprintf(holder, sizeof holder, "%*.*s\n", 10, 10, BLURB); | 813 | snprintf(holder, sizeof holder, "%*.*s\n", 10, 10, BLURB); |
814 | printf("%*.*s\n", 10, 10, BLURB); | 814 | printf("%*.*s\n", 10, 10, BLURB); |
... | @@ -821,7 +821,7 @@ void main() | ... | @@ -821,7 +821,7 @@ void main() |
821 | 821 | ||
822 | #define BIG "Hello this is a too big string for the buffer" | 822 | #define BIG "Hello this is a too big string for the buffer" |
823 | /* printf("A buffer to small of 10, trying to put this:\n");*/ | 823 | /* printf("A buffer to small of 10, trying to put this:\n");*/ |
824 | printf("<%%>, %s\n", BIG); | 824 | printf("<%%>, %s\n", BIG); |
825 | i = snprintf(holder, 10, "%s\n", BIG); | 825 | i = snprintf(holder, 10, "%s\n", BIG); |
826 | printf("<%s>\n", BIG); | 826 | printf("<%s>\n", BIG); |
827 | printf("<%s>\n", holder); | 827 | printf("<%s>\n", holder); | ... | ... |
1 | /* | 1 | /* |
2 | Unix snprintf implementation. | 2 | Unix snprintf implementation. |
3 | Version 1.3 | 3 | Version 1.3 |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU Library General Public License as published by | 6 | it under the terms of the GNU Library General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU Library General Public License for more details. | 13 | GNU Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | 18 | ||
19 | Revision History: | 19 | Revision History: |
20 | see header of snprintf.c. | 20 | see header of snprintf.c. |
21 | 21 | ||
... | @@ -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> |
... | @@ -49,7 +49,7 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca | ... | @@ -49,7 +49,7 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca |
49 | #include <ctype.h> | 49 | #include <ctype.h> |
50 | 50 | ||
51 | 51 | ||
52 | /* | 52 | /* |
53 | * For the FLOATING POINT FORMAT : | 53 | * For the FLOATING POINT FORMAT : |
54 | * the challenge was finding a way to | 54 | * the challenge was finding a way to |
55 | * manipulate the Real numbers without having | 55 | * manipulate the Real numbers without having |
... | @@ -65,24 +65,24 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca | ... | @@ -65,24 +65,24 @@ Alain Magloire: alainm@rcsm.ee.mcgill.ca |
65 | fraction = b(1)*10^-1 + b(2)*10^-2 + ... | 65 | fraction = b(1)*10^-1 + b(2)*10^-2 + ... |
66 | 66 | ||
67 | where: | 67 | where: |
68 | 0 <= a(i) => 9 | 68 | 0 <= a(i) => 9 |
69 | 0 <= b(i) => 9 | 69 | 0 <= b(i) => 9 |
70 | 70 | ||
71 | from then it was simple math | 71 | from then it was simple math |
72 | */ | 72 | */ |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * size of the buffer for the integral part | 75 | * size of the buffer for the integral part |
76 | * and the fraction part | 76 | * and the fraction part |
77 | */ | 77 | */ |
78 | #define MAX_INT 99 + 1 /* 1 for the null */ | 78 | #define MAX_INT 99 + 1 /* 1 for the null */ |
79 | #define MAX_FRACT 29 + 1 | 79 | #define MAX_FRACT 29 + 1 |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * numtoa() uses PRIVATE buffers to store the results, | 82 | * numtoa() uses PRIVATE buffers to store the results, |
83 | * So this function is not reentrant | 83 | * So this function is not reentrant |
84 | */ | 84 | */ |
85 | #define itoa(n) numtoa(n, 10, 0, (char **)0) | 85 | #define itoa(n) numtoa(n, 10, 0, (char **)0) |
86 | #define otoa(n) numtoa(n, 8, 0, (char **)0) | 86 | #define otoa(n) numtoa(n, 8, 0, (char **)0) |
87 | #define htoa(n) numtoa(n, 16, 0, (char **)0) | 87 | #define htoa(n) numtoa(n, 16, 0, (char **)0) |
88 | #define dtoa(n, p, f) numtoa(n, 10, p, f) | 88 | #define dtoa(n, p, f) numtoa(n, 10, p, f) |
... | @@ -182,7 +182,7 @@ struct DATA { | ... | @@ -182,7 +182,7 @@ struct DATA { |
182 | if ((p)->space == FOUND && (d) > 0.) \ | 182 | if ((p)->space == FOUND && (d) > 0.) \ |
183 | PUT_CHAR(' ', p) | 183 | PUT_CHAR(' ', p) |
184 | 184 | ||
185 | /* pad right */ | 185 | /* pad right */ |
186 | #define PAD_RIGHT(p) \ | 186 | #define PAD_RIGHT(p) \ |
187 | if ((p)->width > 0 && (p)->justify != LEFT) \ | 187 | if ((p)->width > 0 && (p)->justify != LEFT) \ |
188 | for (; (p)->width > 0; (p)->width--) \ | 188 | for (; (p)->width > 0; (p)->width--) \ | ... | ... |
... | @@ -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; | 176 | |
173 | char *line; | 177 | alarm (timeout); |
174 | size_t len; | 178 | ptr = fgets (buffer, sizeof (buffer), fp); |
175 | 179 | alarm (0); | |
176 | nl = memchr (buffer, '\n', total); | 180 | |
177 | if (!nl) | 181 | /* We should probably check ferror() too, but if ptr is null we |
178 | { | 182 | are done anyway; if (!ptr && ferror(fp)) */ |
179 | /* Need to refill the buffer. */ | 183 | if (!ptr) |
180 | do | 184 | pop3d_abquit (ERR_NO_OFILE); |
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 | |||
191 | FD_ZERO (&rfds); | ||
192 | FD_SET (fd, &rfds); | ||
193 | tv.tv_sec = timeout; | ||
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 | |||
207 | errno = 0; | ||
208 | nread = read (fd, buf, sizeof (buf) - 1); | ||
209 | if (nread < 1) | ||
210 | { | ||
211 | if (errno == EINTR) | ||
212 | continue; | ||
213 | 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