Commit abde8313 abde8313b0154ccac796e7371f97c9293556938d by Alain Magloire

pop3d.h: The global variables were define here so they would end up

include multiple times.  Compiler like Watcomm C, will scream loudly
about definition of those variables multiple times.  Gcc is very silent
about this.  So in pop3d.h we declare those variables extern and move the
definition in pop3d.c.
MAXHOSTNAMELEN is define in netinet/in.h on Solaris so we guard with
#ifdef's.
We were calling syslog("%s ", NULL); On solaris passing a NULL to  a printf
function will crash and  burn, this was a FIXME I did not see it earlier
the NULL was the place holder for the mailbox name.
1 parent acaaf3cd
...@@ -203,7 +203,12 @@ pop3_apop (const char *arg) ...@@ -203,7 +203,12 @@ pop3_apop (const char *arg)
203 203
204 state = TRANSACTION; 204 state = TRANSACTION;
205 fprintf (ofile, "+OK opened mailbox for %s\r\n", username); 205 fprintf (ofile, "+OK opened mailbox for %s\r\n", username);
206 /* FIXME: how to get mailbox name? */ 206 /* mailbox name */
207 syslog (LOG_INFO, "User %s logged in with mailbox %s", username, NULL); 207 {
208 url_t url = NULL;
209 mailbox_get_url (mbox, &url);
210 syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'",
211 username, url_to_string (url));
212 }
208 return OK; 213 return OK;
209 } 214 }
......
...@@ -17,10 +17,23 @@ ...@@ -17,10 +17,23 @@
17 17
18 #include "pop3d.h" 18 #include "pop3d.h"
19 19
20 /* save some line space */ 20 /* Save some line space. */
21 typedef struct sockaddr_in SA; 21 typedef struct sockaddr_in SA;
22 22
23 /* number of child processes */ 23 /* Declared in <pop3d.h>. */
24 mailbox_t mbox;
25
26 unsigned int port;
27 unsigned int timeout;
28 int state;
29 char *username;
30 int ifile;
31 FILE *ofile;
32 time_t curr_time;
33 char *md5shared;
34 unsigned int children;
35
36 /* Number of child processes. */
24 unsigned int children = 0; 37 unsigned int children = 0;
25 38
26 static struct option long_options[] = 39 static struct option long_options[] =
......
...@@ -63,9 +63,6 @@ ...@@ -63,9 +63,6 @@
63 /* Size of the MD5 digest for APOP */ 63 /* Size of the MD5 digest for APOP */
64 #define APOP_DIGEST 70 64 #define APOP_DIGEST 70
65 65
66 /* Maximum length of a hostname (is this defined somewhere else?) */
67 #define MAXHOSTNAMELEN 64
68
69 /* Longest legal POP command */ 66 /* Longest legal POP command */
70 #define POP_MAXCMDLEN 255 67 #define POP_MAXCMDLEN 255
71 68
...@@ -123,6 +120,13 @@ ...@@ -123,6 +120,13 @@
123 #include <shadow.h> 120 #include <shadow.h>
124 #endif 121 #endif
125 122
123 #ifndef MAXHOSTNAMELEN
124 /* Maximum length of a hostname (is this defined somewhere else?). */
125 /* MAXHOSTNAMELEN is already define on Solaris. */
126 #define MAXHOSTNAMELEN 64
127 #endif
128
129
126 #define AUTHORIZATION 0 130 #define AUTHORIZATION 0
127 #define TRANSACTION 1 131 #define TRANSACTION 1
128 #define UPDATE 2 132 #define UPDATE 2
...@@ -148,45 +152,52 @@ ...@@ -148,45 +152,52 @@
148 #define ERR_TIMEOUT 15 152 #define ERR_TIMEOUT 15
149 #define ERR_UNKNOWN 16 153 #define ERR_UNKNOWN 16
150 154
151 mailbox_t mbox; 155 #ifndef __P
152 156 # ifdef __STDC__
153 unsigned int port; 157 # define __P(args) args
154 unsigned int timeout; 158 # else
155 int state; 159 # define __P(args) ()
156 char *username; 160 # endif
157 int ifile; 161 #endif /* __P */
158 FILE *ofile; 162
159 time_t curr_time; 163 extern mailbox_t mbox;
160 char *md5shared; 164
161 unsigned int children; 165 extern unsigned int port;
162 166 extern unsigned int timeout;
163 int pop3_dele (const char *arg); 167 extern int state;
164 int pop3_list (const char *arg); 168 extern char *username;
165 int pop3_noop (const char *arg); 169 extern int ifile;
166 int pop3_quit (const char *arg); 170 extern FILE *ofile;
167 int pop3_retr (const char *arg); 171 extern time_t curr_time;
168 int pop3_rset (const char *arg); 172 extern char *md5shared;
169 int pop3_stat (const char *arg); 173 extern unsigned int children;
170 int pop3_top (const char *arg); 174
171 int pop3_uidl (const char *arg); 175 extern int pop3_dele __P ((const char *arg));
172 int pop3_user (const char *arg); 176 extern int pop3_list __P ((const char *arg));
173 int pop3_apop (const char *arg); 177 extern int pop3_noop __P ((const char *arg));
174 int pop3_auth (const char *arg); 178 extern int pop3_quit __P ((const char *arg));
175 int pop3_capa (const char *arg); 179 extern int pop3_retr __P ((const char *arg));
176 char *pop3_args (const char *cmd); 180 extern int pop3_rset __P ((const char *arg));
177 char *pop3_cmd (const char *cmd); 181 extern int pop3_stat __P ((const char *arg));
178 int pop3_mesg_exist (int mesg); 182 extern int pop3_top __P ((const char *arg));
179 int pop3_abquit (int reason); 183 extern int pop3_uidl __P ((const char *arg));
180 int pop3_lock (void); 184 extern int pop3_user __P ((const char *arg));
181 int pop3_unlock (void); 185 extern int pop3_apop __P ((const char *arg));
182 int pop3_getsizes (void); 186 extern int pop3_auth __P ((const char *arg));
183 int pop3_mainloop (int infile, int outfile); 187 extern int pop3_capa __P ((const char *arg));
184 void pop3_daemon (unsigned int maxchildren); 188 extern char *pop3_args __P ((const char *cmd));
185 void pop3_usage (char *argv0); 189 extern char *pop3_cmd __P ((const char *cmd));
186 void pop3_signal (int); 190 extern int pop3_mesg_exist __P ((int mesg));
187 void pop3_sigchld (int); 191 extern int pop3_abquit __P ((int reason));
188 void pop3_daemon_init (void); 192 extern int pop3_lock __P ((void));
189 char *pop3_apopuser (const char *user); 193 extern int pop3_unlock __P ((void));
190 char *pop3_readline (int fd); 194 extern int pop3_getsizes __P ((void));
191 195 extern int pop3_mainloop __P ((int infile, int outfile));
196 extern void pop3_daemon __P ((unsigned int maxchildren));
197 extern void pop3_usage __P ((char *argv0));
198 extern void pop3_signal __P ((int));
199 extern void pop3_sigchld __P ((int));
200 extern void pop3_daemon_init __P ((void));
201 extern char *pop3_apopuser __P ((const char *user));
202 extern char *pop3_readline __P ((int fd));
192 #endif /* _POP3D_H */ 203 #endif /* _POP3D_H */
......
...@@ -186,9 +186,13 @@ pop3_user (const char *arg) ...@@ -186,9 +186,13 @@ pop3_user (const char *arg)
186 setuid (pw->pw_uid); 186 setuid (pw->pw_uid);
187 187
188 fprintf (ofile, "+OK opened mailbox for %s\r\n", username); 188 fprintf (ofile, "+OK opened mailbox for %s\r\n", username);
189 /* FIXME: mailbox name */ 189 /* mailbox name */
190 syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username, 190 {
191 NULL); 191 url_t url = NULL;
192 mailbox_get_url (mbox, &url);
193 syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'",
194 username, url_to_string (url));
195 }
192 return OK; 196 return OK;
193 } 197 }
194 else if (strcasecmp (cmd, "QUIT") == 0) 198 else if (strcasecmp (cmd, "QUIT") == 0)
......