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)
state = TRANSACTION;
fprintf (ofile, "+OK opened mailbox for %s\r\n", username);
/* FIXME: how to get mailbox name? */
syslog (LOG_INFO, "User %s logged in with mailbox %s", username, NULL);
/* mailbox name */
{
url_t url = NULL;
mailbox_get_url (mbox, &url);
syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'",
username, url_to_string (url));
}
return OK;
}
......
......@@ -17,10 +17,23 @@
#include "pop3d.h"
/* save some line space */
/* Save some line space. */
typedef struct sockaddr_in SA;
/* number of child processes */
/* Declared in <pop3d.h>. */
mailbox_t mbox;
unsigned int port;
unsigned int timeout;
int state;
char *username;
int ifile;
FILE *ofile;
time_t curr_time;
char *md5shared;
unsigned int children;
/* Number of child processes. */
unsigned int children = 0;
static struct option long_options[] =
......
......@@ -63,9 +63,6 @@
/* Size of the MD5 digest for APOP */
#define APOP_DIGEST 70
/* Maximum length of a hostname (is this defined somewhere else?) */
#define MAXHOSTNAMELEN 64
/* Longest legal POP command */
#define POP_MAXCMDLEN 255
......@@ -123,6 +120,13 @@
#include <shadow.h>
#endif
#ifndef MAXHOSTNAMELEN
/* Maximum length of a hostname (is this defined somewhere else?). */
/* MAXHOSTNAMELEN is already define on Solaris. */
#define MAXHOSTNAMELEN 64
#endif
#define AUTHORIZATION 0
#define TRANSACTION 1
#define UPDATE 2
......@@ -148,45 +152,52 @@
#define ERR_TIMEOUT 15
#define ERR_UNKNOWN 16
mailbox_t mbox;
unsigned int port;
unsigned int timeout;
int state;
char *username;
int ifile;
FILE *ofile;
time_t curr_time;
char *md5shared;
unsigned int children;
int pop3_dele (const char *arg);
int pop3_list (const char *arg);
int pop3_noop (const char *arg);
int pop3_quit (const char *arg);
int pop3_retr (const char *arg);
int pop3_rset (const char *arg);
int pop3_stat (const char *arg);
int pop3_top (const char *arg);
int pop3_uidl (const char *arg);
int pop3_user (const char *arg);
int pop3_apop (const char *arg);
int pop3_auth (const char *arg);
int pop3_capa (const char *arg);
char *pop3_args (const char *cmd);
char *pop3_cmd (const char *cmd);
int pop3_mesg_exist (int mesg);
int pop3_abquit (int reason);
int pop3_lock (void);
int pop3_unlock (void);
int pop3_getsizes (void);
int pop3_mainloop (int infile, int outfile);
void pop3_daemon (unsigned int maxchildren);
void pop3_usage (char *argv0);
void pop3_signal (int);
void pop3_sigchld (int);
void pop3_daemon_init (void);
char *pop3_apopuser (const char *user);
char *pop3_readline (int fd);
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
extern mailbox_t mbox;
extern unsigned int port;
extern unsigned int timeout;
extern int state;
extern char *username;
extern int ifile;
extern FILE *ofile;
extern time_t curr_time;
extern char *md5shared;
extern unsigned int children;
extern int pop3_dele __P ((const char *arg));
extern int pop3_list __P ((const char *arg));
extern int pop3_noop __P ((const char *arg));
extern int pop3_quit __P ((const char *arg));
extern int pop3_retr __P ((const char *arg));
extern int pop3_rset __P ((const char *arg));
extern int pop3_stat __P ((const char *arg));
extern int pop3_top __P ((const char *arg));
extern int pop3_uidl __P ((const char *arg));
extern int pop3_user __P ((const char *arg));
extern int pop3_apop __P ((const char *arg));
extern int pop3_auth __P ((const char *arg));
extern int pop3_capa __P ((const char *arg));
extern char *pop3_args __P ((const char *cmd));
extern char *pop3_cmd __P ((const char *cmd));
extern int pop3_mesg_exist __P ((int mesg));
extern int pop3_abquit __P ((int reason));
extern int pop3_lock __P ((void));
extern int pop3_unlock __P ((void));
extern int pop3_getsizes __P ((void));
extern int pop3_mainloop __P ((int infile, int outfile));
extern void pop3_daemon __P ((unsigned int maxchildren));
extern void pop3_usage __P ((char *argv0));
extern void pop3_signal __P ((int));
extern void pop3_sigchld __P ((int));
extern void pop3_daemon_init __P ((void));
extern char *pop3_apopuser __P ((const char *user));
extern char *pop3_readline __P ((int fd));
#endif /* _POP3D_H */
......
......@@ -186,9 +186,13 @@ pop3_user (const char *arg)
setuid (pw->pw_uid);
fprintf (ofile, "+OK opened mailbox for %s\r\n", username);
/* FIXME: mailbox name */
syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'", username,
NULL);
/* mailbox name */
{
url_t url = NULL;
mailbox_get_url (mbox, &url);
syslog (LOG_INFO, "User '%s' logged in with mailbox '%s'",
username, url_to_string (url));
}
return OK;
}
else if (strcasecmp (cmd, "QUIT") == 0)
......