Variuos code cleanups
fixed a couple of functions to use libmailbox fixed copyright notices
Showing
17 changed files
with
112 additions
and
165 deletions
... | @@ -6,4 +6,10 @@ pop3d_DEPENDENDENCIES = ../libmailbox/libmailbox.la ../libsrc/libgetopt.la\ | ... | @@ -6,4 +6,10 @@ pop3d_DEPENDENDENCIES = ../libmailbox/libmailbox.la ../libsrc/libgetopt.la\ |
6 | ../libsrc/libmd5.la | 6 | ../libsrc/libmd5.la |
7 | pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h\ | 7 | pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h\ |
8 | list.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c | 8 | list.c noop.c quit.c retr.c rset.c stat.c top.c uidl.c user.c |
9 | pop3d_LDADD = ../libmailbox/libmailbox.la | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
9 | |||
10 | #if USE_LIBPAM | ||
11 | #pop3d_LDADD = ../libmailbox/libmailbox.la -lpam -ldl | ||
12 | #else | ||
13 | #pop3d_LDADD = ../libmailbox/libmailbox.la | ||
14 | #endif | ||
15 | pop3d_LADADD = ../libmailbox/libmailbox.la $(AUTHLIBS) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -17,8 +17,6 @@ | ... | @@ -17,8 +17,6 @@ |
17 | 17 | ||
18 | #include "pop3d.h" | 18 | #include "pop3d.h" |
19 | 19 | ||
20 | #ifdef _USE_APOP | ||
21 | |||
22 | /* Check if a username exists in APOP password file | 20 | /* Check if a username exists in APOP password file |
23 | returns pinter to password if found, otherwise NULL */ | 21 | returns pinter to password if found, otherwise NULL */ |
24 | char * | 22 | char * |
... | @@ -127,30 +125,26 @@ pop3_apop (const char *arg) | ... | @@ -127,30 +125,26 @@ pop3_apop (const char *arg) |
127 | 125 | ||
128 | if (state != AUTHORIZATION) | 126 | if (state != AUTHORIZATION) |
129 | return ERR_WRONG_STATE; | 127 | return ERR_WRONG_STATE; |
130 | if (strlen (arg) == 0) | ||
131 | return ERR_BAD_ARGS; | ||
132 | 128 | ||
133 | tmp = pop3_cmd (arg); | 129 | if (strlen (arg) == 0) |
134 | if (strlen (tmp) > (POP_MAXCMDLEN - APOP_DIGEST)) | ||
135 | return ERR_BAD_ARGS; | 130 | return ERR_BAD_ARGS; |
136 | if ((username = strdup (tmp)) == NULL) | ||
137 | pop3_abquit (ERR_NO_MEM); | ||
138 | free (tmp); | ||
139 | 131 | ||
140 | tmp = pop3_args (arg); | 132 | username = pop3_cmd (arg); |
141 | if (strlen (tmp) > APOP_DIGEST) | 133 | user_digest = pop3_args (arg); |
134 | if (strlen (username) > (POP_MAXCMDLEN - APOP_DIGEST)) | ||
142 | return ERR_BAD_ARGS; | 135 | return ERR_BAD_ARGS; |
143 | if ((user_digest = strdup (tmp)) == NULL) | ||
144 | pop3_abquit (ERR_NO_MEM); | ||
145 | free (tmp); | ||
146 | 136 | ||
147 | if ((password = pop3_apopuser (username)) == NULL) | 137 | password = pop3_apopuser (username); |
138 | if (password == NULL) | ||
139 | { | ||
140 | free (username); | ||
141 | free (user_digest); | ||
148 | return ERR_BAD_LOGIN; | 142 | return ERR_BAD_LOGIN; |
143 | } | ||
149 | 144 | ||
150 | md5_init_ctx (&md5context); | 145 | md5_init_ctx (&md5context); |
151 | md5_process_bytes (md5shared, strlen (md5shared), &md5context); | 146 | md5_process_bytes (md5shared, strlen (md5shared), &md5context); |
152 | md5_process_bytes (password, strlen (password), &md5context); | 147 | md5_process_bytes (password, strlen (password), &md5context); |
153 | /* pop3_wipestr (password); */ | ||
154 | free (password); | 148 | free (password); |
155 | md5_finish_ctx (&md5context, md5digest); | 149 | md5_finish_ctx (&md5context, md5digest); |
156 | 150 | ||
... | @@ -161,49 +155,44 @@ pop3_apop (const char *arg) | ... | @@ -161,49 +155,44 @@ pop3_apop (const char *arg) |
161 | *tmp++ = '\0'; | 155 | *tmp++ = '\0'; |
162 | 156 | ||
163 | if (strcmp (user_digest, buf)) | 157 | if (strcmp (user_digest, buf)) |
158 | { | ||
159 | free (username); | ||
160 | free (user_digest); | ||
164 | return ERR_BAD_LOGIN; | 161 | return ERR_BAD_LOGIN; |
162 | } | ||
165 | 163 | ||
166 | if ((pw = getpwnam (username)) == NULL) | 164 | free (user_digest); |
165 | pw = getpwnam (username); | ||
166 | if (pw == NULL) | ||
167 | { | ||
168 | free (username); | ||
167 | return ERR_BAD_LOGIN; | 169 | return ERR_BAD_LOGIN; |
170 | } | ||
168 | 171 | ||
169 | #ifdef MAILSPOOLHOME | 172 | #ifdef MAILSPOOLHOME |
170 | mailbox = malloc ((strlen (pw->pw_dir) + strlen (MAILSPOOLHOME) + 1) * sizeof (char)); | 173 | if (pw != NULL) |
171 | if (mailbox == NULL) | 174 | { |
172 | pop3_abquit (ERR_NO_MEM); | 175 | chdir (pw->pw_dir); |
173 | strcpy (mailbox, pw->pw_dir); | 176 | mbox = mbox_open (MAILSPOOLHOME); |
174 | strcat (mailbox, MAILSPOOLHOME); | 177 | } |
175 | mbox = fopen (mailbox, "r"); | 178 | else |
179 | mbox = NULL; | ||
180 | |||
176 | if (mbox == NULL) | 181 | if (mbox == NULL) |
177 | { | 182 | { |
178 | free (mailbox); | ||
179 | chdir (_PATH_MAILDIR); | 183 | chdir (_PATH_MAILDIR); |
180 | #endif | 184 | #endif /* MAILSPOOLHOME */ |
181 | mailbox = malloc (sizeof (char) * (strlen (_PATH_MAILDIR) + strlen (username) + 2)); | 185 | mbox = mbox_open (username); |
182 | strcpy (mailbox, _PATH_MAILDIR "/"); | ||
183 | strcat (mailbox, username); | ||
184 | if (mailbox == NULL) | ||
185 | pop3_abquit (ERR_NO_MEM); | ||
186 | |||
187 | mbox = fopen (mailbox, "r"); | ||
188 | if (mbox == NULL) | 186 | if (mbox == NULL) |
189 | { | 187 | { |
190 | mailbox = strdup ("/dev/null"); | 188 | state = AUTHORIZATION; |
191 | if (mailbox == NULL) | 189 | return ERR_MBOX_LOCK; |
192 | pop3_abquit (ERR_NO_MEM); | ||
193 | mbox = fopen (mailbox, "r"); | ||
194 | } | 190 | } |
195 | #ifdef MAILSPOOLHOME | 191 | #ifdef MAILSPOOLHOME |
196 | } | 192 | } |
197 | else | ||
198 | #endif | 193 | #endif |
199 | if (pop3_lock () != OK) | ||
200 | { | ||
201 | pop3_unlock (); | ||
202 | free (mailbox); | ||
203 | state = AUTHORIZATION; | ||
204 | return ERR_MBOX_LOCK; | ||
205 | } | ||
206 | 194 | ||
195 | #if 0 | ||
207 | if ((pw->pw_uid < 1) | 196 | if ((pw->pw_uid < 1) |
208 | #ifdef MAILSPOOLHOME | 197 | #ifdef MAILSPOOLHOME |
209 | /* Drop mail group for home dirs */ | 198 | /* Drop mail group for home dirs */ |
... | @@ -215,22 +204,11 @@ pop3_apop (const char *arg) | ... | @@ -215,22 +204,11 @@ pop3_apop (const char *arg) |
215 | free (mailbox); | 204 | free (mailbox); |
216 | return ERR_BAD_LOGIN; | 205 | return ERR_BAD_LOGIN; |
217 | } | 206 | } |
207 | #endif /* 0 */ | ||
218 | 208 | ||
219 | state = TRANSACTION; | 209 | state = TRANSACTION; |
220 | messages = NULL; | ||
221 | pop3_getsizes (); | ||
222 | fprintf (ofile, "+OK opened mailbox for %s\r\n", username); | 210 | fprintf (ofile, "+OK opened mailbox for %s\r\n", username); |
223 | syslog (LOG_INFO, "User %s logged in with mailbox %s", username, mailbox); | 211 | syslog (LOG_INFO, "User %s logged in with mailbox %s", username, mbox->name); |
224 | cursor = 0; | ||
225 | return OK; | 212 | return OK; |
226 | } | 213 | } |
227 | 214 | ||
228 | #else | ||
229 | |||
230 | int | ||
231 | pop3_apop (const char *foo) | ||
232 | { | ||
233 | return ERR_NOT_IMPL; | ||
234 | } | ||
235 | |||
236 | #endif | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
2 | 17 | ||
3 | * Code for capa support by Sean 'Shaleh' Perry <shaleh@debian.org> | ||
4 | * added 4/2/1999 | ||
5 | * | ||
6 | */ | ||
7 | #include "pop3d.h" | 18 | #include "pop3d.h" |
8 | 19 | ||
9 | int | 20 | int | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -33,16 +33,15 @@ pop3_retr (const char *arg) | ... | @@ -33,16 +33,15 @@ pop3_retr (const char *arg) |
33 | 33 | ||
34 | mesg = atoi (arg) - 1; | 34 | mesg = atoi (arg) - 1; |
35 | 35 | ||
36 | if (mesg > mbox->messages || mbox_is_deleted(mbox, mesg)) | 36 | if (mesg >= mbox->messages || mbox_is_deleted(mbox, mesg)) |
37 | return ERR_NO_MESG; | 37 | return ERR_NO_MESG; |
38 | 38 | ||
39 | fprintf (ofile, "+OK\r\n"); | ||
40 | buf = mbox_get_header (mbox, mesg); | 39 | buf = mbox_get_header (mbox, mesg); |
41 | fprintf (ofile, "%s", buf); | 40 | fprintf (ofile, "+OK\r\n%s\r\n", buf); |
42 | free (buf); | 41 | free (buf); |
43 | buf = mbox_get_body (mbox, mesg); | 42 | buf = mbox_get_body (mbox, mesg); |
44 | fprintf (ofile, "%s", buf); | 43 | fprintf (ofile, "%s.\r\n", buf); |
45 | free (buf); | 44 | free (buf); |
46 | fprintf (ofile, ".\r\n"); | ||
47 | return OK; | 45 | return OK; |
48 | } | 46 | } |
47 | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -22,11 +22,9 @@ | ... | @@ -22,11 +22,9 @@ |
22 | int | 22 | int |
23 | pop3_top (const char *arg) | 23 | pop3_top (const char *arg) |
24 | { | 24 | { |
25 | #ifdef _HAVE_BLACK_MAGIC | ||
26 | int i = 0, header = 1, done = 0; | ||
27 | int mesg, lines; | 25 | int mesg, lines; |
28 | char *mesgc, *linesc; | 26 | char *mesgc, *linesc; |
29 | char *buf, buf2[80]; | 27 | char *buf; |
30 | 28 | ||
31 | if (strlen (arg) == 0) | 29 | if (strlen (arg) == 0) |
32 | return ERR_BAD_ARGS; | 30 | return ERR_BAD_ARGS; |
... | @@ -44,66 +42,15 @@ pop3_top (const char *arg) | ... | @@ -44,66 +42,15 @@ pop3_top (const char *arg) |
44 | if (lines < 0) | 42 | if (lines < 0) |
45 | return ERR_BAD_ARGS; | 43 | return ERR_BAD_ARGS; |
46 | 44 | ||
47 | if (pop3_mesg_exist (mesg) != OK) | 45 | if (mesg > mbox->messages || mbox_is_deleted(mbox, mesg)) |
48 | return ERR_NO_MESG; | 46 | return ERR_NO_MESG; |
49 | 47 | ||
50 | mbox = freopen (mailbox, "r", mbox); | 48 | buf = mbox_get_header (mbox, mesg); |
51 | if (mbox == NULL) | 49 | fprintf (ofile, "+OK\r\n%s\r\n", buf); |
52 | return ERR_FILE; | 50 | free (buf); |
53 | fsetpos (mbox, &(messages[mesg].header)); | 51 | buf = mbox_body_lines (mbox, mesg, lines); |
54 | 52 | fprintf (ofile, "%s.\r\n", buf); | |
55 | fprintf (ofile, "+OK\r\n"); | ||
56 | buf = malloc (sizeof (char) * 80); | ||
57 | if (buf == NULL) | ||
58 | pop3_abquit (ERR_NO_MEM); | ||
59 | |||
60 | while (fgets (buf, 80, mbox) && !done) | ||
61 | { | ||
62 | while (strchr (buf, '\n') == NULL) | ||
63 | { | ||
64 | buf = realloc (buf, sizeof (char) * (strlen (buf) + 81)); | ||
65 | if (buf == NULL) | ||
66 | pop3_abquit (ERR_NO_MEM); | ||
67 | fgets (buf2, 80, mbox); | ||
68 | strncat (buf, buf2, 80); | ||
69 | } | ||
70 | if (!strncmp (buf, "From ", 5)) | ||
71 | done = 1; | ||
72 | else | ||
73 | { | ||
74 | buf[strlen (buf) - 1] = '\0'; | ||
75 | if (header == 1) | ||
76 | { | ||
77 | if (buf[0] == '.') | ||
78 | fprintf (ofile, ".%s\r\n", buf); | ||
79 | else | ||
80 | fprintf (ofile, "%s\r\n", buf); | ||
81 | if ((buf[0] == '\r') || (buf[0] == '\n') || (buf[0]) == '\0') | ||
82 | header = 0; | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | if (++i <= lines) | ||
87 | { | ||
88 | if (buf[0] == '.') | ||
89 | fprintf (ofile, ".%s\r\n", buf); | ||
90 | else | ||
91 | fprintf (ofile, "%s\r\n", buf); | ||
92 | } | ||
93 | else | ||
94 | done = 1; | ||
95 | } | ||
96 | } | ||
97 | buf = realloc (buf, sizeof (char) * 80); | ||
98 | if (buf == NULL) | ||
99 | pop3_abquit (ERR_NO_MEM); | ||
100 | } | ||
101 | |||
102 | free (buf); | 53 | free (buf); |
103 | fprintf (ofile, ".\r\n"); | ||
104 | return OK; | 54 | return OK; |
105 | #else | ||
106 | return ERR_NOT_IMPL; | ||
107 | #endif | ||
108 | } | 55 | } |
109 | 56 | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* GNU POP3 - a small, fast, and efficient POP3 daemon | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999 Jakob 'sparky' Kaivo <jkaivo@nodomainname.net> | 2 | Copyright (C) 1999 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -79,11 +79,11 @@ int | ... | @@ -79,11 +79,11 @@ int |
79 | pop3_user (const char *arg) | 79 | pop3_user (const char *arg) |
80 | { | 80 | { |
81 | char *buf, pass[POP_MAXCMDLEN], *tmp, *cmd; | 81 | char *buf, pass[POP_MAXCMDLEN], *tmp, *cmd; |
82 | struct passwd *pw; | ||
82 | #ifdef USE_LIBPAM | 83 | #ifdef USE_LIBPAM |
83 | pam_handle_t *pamh; | 84 | pam_handle_t *pamh; |
84 | int pamerror; | 85 | int pamerror; |
85 | #endif /* !USE_LIBPAM */ | 86 | #endif /* !USE_LIBPAM */ |
86 | struct passwd *pw; | ||
87 | 87 | ||
88 | if (state != AUTHORIZATION) | 88 | if (state != AUTHORIZATION) |
89 | return ERR_WRONG_STATE; | 89 | return ERR_WRONG_STATE; |
... | @@ -101,6 +101,7 @@ pop3_user (const char *arg) | ... | @@ -101,6 +101,7 @@ pop3_user (const char *arg) |
101 | 101 | ||
102 | if (strlen (tmp) > POP_MAXCMDLEN) | 102 | if (strlen (tmp) > POP_MAXCMDLEN) |
103 | { | 103 | { |
104 | free (cmd); | ||
104 | free (tmp); | 105 | free (tmp); |
105 | return ERR_TOO_LONG; | 106 | return ERR_TOO_LONG; |
106 | } | 107 | } |
... | @@ -148,7 +149,7 @@ pop3_user (const char *arg) | ... | @@ -148,7 +149,7 @@ pop3_user (const char *arg) |
148 | #endif /* HAVE_SHADOW_H */ | 149 | #endif /* HAVE_SHADOW_H */ |
149 | return ERR_BAD_LOGIN; | 150 | return ERR_BAD_LOGIN; |
150 | } | 151 | } |
151 | #else /* USE_LIBPAM */ | 152 | #else /* !USE_LIBPAM */ |
152 | _user = (char *) arg; | 153 | _user = (char *) arg; |
153 | _pwd = pass; | 154 | _pwd = pass; |
154 | /* libpam doesn't log to LOG_MAIL */ | 155 | /* libpam doesn't log to LOG_MAIL */ |
... | @@ -166,18 +167,21 @@ pop3_user (const char *arg) | ... | @@ -166,18 +167,21 @@ pop3_user (const char *arg) |
166 | #endif /* USE_LIBPAM */ | 167 | #endif /* USE_LIBPAM */ |
167 | 168 | ||
168 | #ifdef MAILSPOOLHOME | 169 | #ifdef MAILSPOOLHOME |
170 | if (pw != NULL) | ||
171 | { | ||
169 | chdir (pw->pw_dir); | 172 | chdir (pw->pw_dir); |
170 | mbox = mbox_open (MAILSPOOLHOME); | 173 | mbox = mbox_open (MAILSPOOLHOME); |
171 | if (mbox == NULL) | 174 | } |
175 | else | ||
176 | mbox = NULL; | ||
177 | |||
178 | if (mbox == NULL) /* We should check errno here... */ | ||
172 | { | 179 | { |
173 | /* See comments below... */ | ||
174 | chdir (_PATH_MAILDIR); | 180 | chdir (_PATH_MAILDIR); |
175 | #endif /* MAILSPOOLHOME */ | 181 | #endif /* MAILSPOOLHOME */ |
176 | mbox = mbox_open (arg); | 182 | mbox = mbox_open (arg); |
177 | if (mbox == NULL) | 183 | if (mbox == NULL) /* And here */ |
178 | { | 184 | { |
179 | /* Check the error type... */ | ||
180 | /* Until then, though */ | ||
181 | state = AUTHORIZATION; | 185 | state = AUTHORIZATION; |
182 | return ERR_MBOX_LOCK; | 186 | return ERR_MBOX_LOCK; |
183 | } | 187 | } |
... | @@ -192,6 +196,8 @@ pop3_user (const char *arg) | ... | @@ -192,6 +196,8 @@ pop3_user (const char *arg) |
192 | if (pw != NULL && pw->pw_uid > 1) | 196 | if (pw != NULL && pw->pw_uid > 1) |
193 | setuid (pw->pw_uid); | 197 | setuid (pw->pw_uid); |
194 | 198 | ||
199 | mbox_lock (mbox, MO_RLOCK | MO_WLOCK); | ||
200 | |||
195 | fprintf (ofile, "+OK opened mailbox for %s\r\n", username); | 201 | fprintf (ofile, "+OK opened mailbox for %s\r\n", username); |
196 | syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username, | 202 | syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username, |
197 | mbox->name); | 203 | mbox->name); | ... | ... |
-
Please register or sign in to post a comment