Blame view

pop3d/pop3d.h 7.54 KB
1
/* GNU Mailutils -- a suite of utilities for electronic mail
2
   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3

4
   GNU Mailutils is free software; you can redistribute it and/or modify
5 6 7 8
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

9
   GNU Mailutils is distributed in the hope that it will be useful,
10 11 12 13 14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
15
   along with GNU Mailutils; if not, write to the Free Software
16
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  */
17 18 19

#ifndef _POP3D_H
#define _POP3D_H	1
20

21
#ifdef HAVE_CONFIG_H
22
# include <config.h>
23
#endif
24
#include <mu_dbm.h>
25
#include <mu_asprintf.h>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

/* The implementation */
#define	IMPL		"GNU POP3 Daemon"

/* You can edit the messages the POP server prints out here */

/* A command that doesn't exist */
#define BAD_COMMAND	"Invalid command"

/* Incorrect number of arguments passed to a command */
#define BAD_ARGS	"Invalid arguments"

/* Command issued in wrong state */
#define BAD_STATE	"Incorrect state"

/* An action on a message that doesn't exist */
#define NO_MESG		"No such message"

44 45 46
/* An action on a message that doesn't exist */
#define MESG_DELE	"Message has been deleted"

47 48 49 50 51 52 53 54 55 56 57 58
/* A command that is known but not implemented */
#define NOT_IMPL	"Not implemented"

/* Invalid username or password */
#define BAD_LOGIN	"Bad login"

/* User authenticated, but mailbox is locked */
#define MBOX_LOCK	"Mailbox in use"

/* The command argument was > 40 characters */
#define TOO_LONG	"Argument too long"

59 60 61
/* An error occured when expunging.  */
#define FILE_EXP        "Some deleted messages not removed"

62 63 64
/* Command not permitted when TLS active. */
#define TLS_ACTIVE      "Command not permitted when TLS active"

65 66 67
/* Trying to log in within the minimum login delay interval */
#define LOGIN_DELAY     "Attempt to log in within the minimum login delay interval"

68
/* APOP password file, without .db or .passwd, which are added based on file
69
   type automatically */
70 71 72 73
#define APOP_PASSFILE_NAME "apop"

#ifdef USE_DBM
# define APOP_PASSFILE SYSCONFDIR "/" APOP_PASSFILE_NAME
74
# define ENABLE_LOGIN_DELAY
75 76
#else
# define APOP_PASSFILE SYSCONFDIR "/" APOP_PASSFILE_NAME ".passwd"
77 78 79 80 81 82 83 84 85
# undef ENABLE_LOGIN_DELAY
#endif

#ifdef ENABLE_LOGIN_DELAY
# define LOGIN_STAT_FILE "/var/run/pop3-login"
extern time_t login_delay;
extern char *login_stat_file;
extern int check_login_delay __P((char *username));
extern void update_login_delay __P((char *username));
86
extern void login_delay_capa __P((void));
87 88 89
#else
# define check_login_delay(u) 0
# define update_login_delay(u)
90
# define login_delay_capa()
91
#endif
92

93 94 95
/* Minimum advertise retention time for messages.  */
extern int expire;

96 97 98 99 100 101
/* Size of the MD5 digest for APOP */
#define APOP_DIGEST	70

/* Longest legal POP command */
#define POP_MAXCMDLEN	255

102 103 104
/* Buffer size to use for output */
#define BUFFERSIZE	1024

105 106 107
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
108
#define _QNX_SOURCE
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
125
#include <arpa/inet.h>
126 127 128 129 130 131
#include <netdb.h>
#include <pwd.h>
#include <grp.h>
#include <syslog.h>
#include <ctype.h>
#include "md5.h"
132 133 134
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
135

136
#include <mailutils/argp.h>
137 138
#include <mailutils/attribute.h>
#include <mailutils/body.h>
139
#include <mailutils/daemon.h>
140
#include <mailutils/errno.h>
141 142 143 144
#include <mailutils/error.h>
#include <mailutils/header.h>
#include <mailutils/list.h>
#include <mailutils/locker.h>
145 146
#include <mailutils/mailbox.h>
#include <mailutils/message.h>
147
#include <mailutils/mutil.h>
148
#include <mailutils/mu_auth.h>
149
#include <mailutils/nls.h>
150 151 152
#include <mailutils/registrar.h>
#include <mailutils/tls.h>
#include <mailutils/url.h>
153

154
/* For Berkley DB2 APOP password file */
155 156
#ifdef HAVE_DB_H
#include <db.h>
157 158 159 160 161 162 163 164 165 166
#endif

#ifdef HAVE_SECURITY_PAM_APPL_H
#include <security/pam_appl.h>
#endif

#ifdef HAVE_SHADOW_H
#include <shadow.h>
#endif

167 168
#ifndef MAXHOSTNAMELEN
/* Maximum length of a hostname (is this defined somewhere else?).  */
169 170
/* MAXHOSTNAMELEN is already defined on Solaris.  */
# define MAXHOSTNAMELEN	64
171 172
#endif

173
#define POP3_ATTRIBUTE_DELE 0x0001
174
#define POP3_ATTRIBUTE_RETR 0x0010
175

176 177 178 179 180 181 182 183 184
#define AUTHORIZATION	0
#define TRANSACTION	1
#define UPDATE		2

#define OK		0
#define ERR_WRONG_STATE	1
#define ERR_BAD_ARGS	2
#define ERR_BAD_LOGIN	3
#define ERR_NO_MESG	4
185 186 187 188 189 190
#define ERR_MESG_DELE   5
#define ERR_NOT_IMPL	6
#define ERR_BAD_CMD	7
#define ERR_MBOX_LOCK	8
#define ERR_TOO_LONG	9
#define ERR_NO_MEM	10
Alain Magloire authored
191 192 193 194 195 196
#define ERR_SIGNAL	11
#define ERR_FILE        12
#define ERR_NO_OFILE    13
#define ERR_TIMEOUT	14
#define ERR_UNKNOWN	15
#define ERR_MBOX_SYNC   16
197 198
#define ERR_TLS_ACTIVE  17
#define ERR_TLS_IO      18
199
#define ERR_LOGIN_DELAY 19
200

201 202 203
extern mailbox_t mbox;
extern int state;
extern char *username;
204
extern char *maildir;
205
extern char *md5shared;
Alain Magloire authored
206
extern volatile size_t children;
207
extern struct daemon_param daemon_param;
208
extern int debug_mode;
Wojciech Polak authored
209
#ifdef WITH_TLS
210 211
extern int tls_available;
extern int tls_done;
Wojciech Polak authored
212
#endif /* WITH_TLS */
213
extern int undelete_on_startup;
Alain Magloire authored
214

215
extern void pop3d_bye           __P ((void));
216 217 218 219 220 221 222
extern int pop3d_abquit         __P ((int));
extern int pop3d_apop           __P ((const char *));
extern char *pop3d_apopuser     __P ((const char *));
extern char *pop3d_args         __P ((const char *));
extern int pop3d_auth           __P ((const char *));
extern int pop3d_capa           __P ((const char *));
extern char *pop3d_cmd          __P ((const char *));
Alain Magloire authored
223 224
extern int pop3d_dele           __P ((const char *));
extern int pop3d_list           __P ((const char *));
225
extern int pop3d_lock           __P ((void));
Alain Magloire authored
226 227 228 229
extern int pop3d_noop           __P ((const char *));
extern int pop3d_quit           __P ((const char *));
extern int pop3d_retr           __P ((const char *));
extern int pop3d_rset           __P ((const char *));
230 231
extern void process_cleanup     __P ((void));

232 233
extern RETSIGTYPE pop3d_sigchld __P ((int));
extern RETSIGTYPE pop3d_signal  __P ((int));
Alain Magloire authored
234
extern int pop3d_stat           __P ((const char *));
235 236 237
#ifdef WITH_TLS
extern int pop3d_stls           __P ((const char *));
#endif /* WITH_TLS */
Alain Magloire authored
238
extern int pop3d_top            __P ((const char *));
239
extern int pop3d_touchlock      __P ((void));
Alain Magloire authored
240 241 242
extern int pop3d_uidl           __P ((const char *));
extern int pop3d_user           __P ((const char *));
extern int pop3d_unlock         __P ((void));
243
extern void pop3d_outf          __P ((const char *fmt, ...));
244

245 246 247 248 249
extern void pop3d_setio         __P ((FILE *in, FILE *out));
extern char *pop3d_readline     __P ((char *, size_t));
extern void pop3d_flush_output  __P ((void));

extern int pop3d_is_master      __P ((void));
Wojciech Polak authored
250

251 252 253 254 255
extern void pop3d_mark_deleted __P((attribute_t attr));
extern int pop3d_is_deleted __P((attribute_t attr));
extern void pop3d_unset_deleted __P((attribute_t attr));
void pop3d_undelete_all __P((void));

Wojciech Polak authored
256 257 258 259 260
#ifdef WITH_TLS
extern int pop3d_init_tls_server    __P ((void));
extern void pop3d_deinit_tls_server __P ((void));
#endif /* WITH_TLS */

261 262 263 264
extern void pop3d_mark_retr __P((attribute_t attr));
extern int pop3d_is_retr __P((attribute_t attr));
extern void pop3d_unmark_retr __P((attribute_t attr));

265
#endif /* _POP3D_H */