2 * Copyright (c) 1989 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
6 * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
7 * static char SccsId[] = "@(#)@(#)popper.h 2.2 2.2 4/2/91";
14 * Header file for the POP programs
23 #define RETURN_PATH_HANDLING
26 /* Common include files */
42 #ifdef HAVE_SYS_TYPES_H
43 #include <sys/types.h>
51 #ifdef HAVE_SYS_STAT_H
54 #ifdef HAVE_SYS_FILE_H
57 #ifdef TIME_WITH_SYS_TIME
60 #elif defined(HAVE_SYS_TIME_H)
65 #ifdef HAVE_SYS_RESOURCE_H
66 #include <sys/resource.h>
68 #ifdef HAVE_SYS_WAIT_H
71 #ifdef HAVE_SYS_SOCKET_H
72 #include <sys/socket.h>
74 #ifdef HAVE_NETINET_IN_H
75 #include <netinet/in.h>
77 #ifdef HAVE_NETINET_IN6_H
78 #include <netinet/in6.h>
80 #ifdef HAVE_NETINET6_IN6_H
81 #include <netinet6/in6.h>
87 #ifdef HAVE_ARPA_INET_H
89 struct sockaddr_dl
; /* AIX fun */
92 #include <arpa/inet.h>
97 #ifdef HAVE_SYS_SELECT_H
98 #include <sys/select.h>
100 #ifdef HAVE_SYS_PARAM_H
101 #include <sys/param.h>
117 #define MAXUSERNAMELEN 65
118 #define MAXLINELEN 1024
119 #define MAXMSGLINELEN 1024
121 #define MAXPARMCOUNT 10
122 #define MAXPARMLEN 10
123 #define ALLOC_MSGS 20
124 #define MAIL_COMMAND "/usr/lib/sendmail"
126 #define POP_FACILITY LOG_LOCAL0
127 #define POP_PRIORITY LOG_NOTICE
128 #define POP_DEBUG LOG_DEBUG
129 #define POP_INFO LOG_INFO
130 #define POP_LOGOPTS 0
135 #ifdef HAVE_MAILLOCK_H
136 #include <maillock.h>
143 #if defined(_PATH_MAILDIR)
144 #define POP_MAILDIR _PATH_MAILDIR
145 #elif defined(MAILDIR)
146 #define POP_MAILDIR MAILDIR
148 #define POP_MAILDIR "/usr/spool/mail"
151 #define POP_DROP POP_MAILDIR "/.%s.pop"
152 /* POP_TMPSIZE needs to be big enough to hold the string
153 * defined by POP_TMPDROP. POP_DROP and POP_TMPDROP
154 * must be in the same filesystem.
156 #define POP_TMPDROP POP_MAILDIR "/tmpXXXXXX"
157 #define POP_TMPSIZE 256
158 #define POP_TMPXMIT "/tmp/xmitXXXXXX"
160 #define POP_ERR "-ERR"
161 #define POP_SUCCESS 1
162 #define POP_FAILURE 0
163 #define POP_TERMINATE '.'
164 #define POP_TIMEOUT 120 /* timeout connection after this many secs */
166 extern int pop_timeout
;
174 #define pop_command pop_parm[0] /* POP command is first token */
175 #define pop_subcommand pop_parm[1] /* POP XTND subcommand is the
178 typedef enum { /* POP processing states */
179 auth1
, /* Authorization: waiting for
181 auth2
, /* Authorization: waiting for
183 trans
, /* Transaction */
184 update
, /* Update: session ended,
185 process maildrop changes */
186 halt
, /* (Halt): stop processing
188 error
/* (Error): something really
197 typedef struct { /* Message information */
198 int number
; /* Message number relative to
199 the beginning of list */
200 long length
; /* Length of message in
202 int lines
; /* Number of (null-terminated) lines in the message */
203 long offset
; /* Offset from beginning of
207 #if defined(UIDL) || defined(XOVER)
208 char *msg_id
; /* The POP UIDL uniqueifier */
218 #define IS_MAILDIR(P) ((P)->temp_drop[0] == '\0')
220 typedef struct { /* POP parameter block */
221 int debug
; /* Debugging requested */
222 char * myname
; /* The name of this POP
224 char myhost
[MaxHostNameLen
]; /* The name of our host
226 char client
[MaxHostNameLen
]; /* Canonical name of client
228 char ipaddr
[MaxHostNameLen
]; /* Dotted-notation format of
230 unsigned short ipport
; /* Client port for privileged
232 char user
[MAXUSERNAMELEN
]; /* Name of the POP user */
233 state CurrentState
; /* The current POP operational state */
234 MsgInfoList
* mlp
; /* Message information list */
235 int msg_count
; /* Number of messages in
237 int msgs_deleted
; /* Number of messages flagged
239 int last_msg
; /* Last message touched by
241 long bytes_deleted
; /* Number of maildrop bytes
242 flagged for deletion */
243 char drop_name
[MAXPATHLEN
]; /* The name of the user's
245 char temp_drop
[MAXPATHLEN
]; /* The name of the user's
246 temporary maildrop */
247 long drop_size
; /* Size of the maildrop in
249 FILE * drop
; /* (Temporary) mail drop */
250 FILE * input
; /* Input TCP/IP communication
252 FILE * output
; /* Output TCP/IP communication stream */
253 FILE * trace
; /* Debugging trace file */
254 char * pop_parm
[MAXPARMCOUNT
]; /* Parse POP parameter list */
255 int parm_count
; /* Number of parameters in
257 int kerberosp
; /* Using KPOP? */
259 krb5_context context
;
260 krb5_principal principal
; /* principal auth as */
261 krb5_log_facility
* logf
;
263 int version
; /* 4 or 5? */
264 int auth_level
; /* Dont allow cleartext */
266 OtpContext otp_ctx
; /* OTP context */
269 #define POP_FLAG_CAPA 1
272 typedef struct { /* State information for
274 state ValidCurrentState
; /* The operating state of
276 char * command
; /* The POP command */
277 int min_parms
; /* Minimum number of parms
279 int max_parms
; /* Maximum number of parms
281 int (*function
) (); /* The function that process
283 state result
[2]; /* The resulting state after
284 command processing */
285 #define success_state result[0] /* State when a command
289 typedef struct { /* Table of extensions */
290 char * subcommand
; /* The POP XTND subcommand */
291 int min_parms
; /* Minimum number of parms for
293 int max_parms
; /* Maximum number of parms for
295 int (*function
) (); /* The function that processes
299 int pop_dele(POP
*p
);
300 int pop_dropcopy(POP
*p
, struct passwd
*pwp
);
301 int pop_dropinfo(POP
*p
);
302 int pop_init(POP
*p
,int argcount
,char **argmessage
);
303 int pop_last(POP
*p
);
304 int pop_list(POP
*p
);
305 int pop_parse(POP
*p
, char *buf
);
306 int pop_pass(POP
*p
);
307 int pop_quit(POP
*p
);
308 int pop_rset(POP
*p
);
309 int pop_send(POP
*p
);
310 int pop_stat(POP
*p
);
311 int pop_updt(POP
*p
);
312 int pop_user(POP
*p
);
314 int pop_uidl(POP
*p
);
317 int pop_xover(POP
*p
);
320 int pop_xdele(POP
*p
);
322 int pop_help(POP
*p
);
323 state_table
*pop_get_command(POP
*p
, char *mp
);
324 void pop_lower(char *buf
);
326 int pop_auth (POP
*p
);
327 void pop_capa_sasl(POP
*p
);
330 int pop_log(POP
*p
, int stat
, char *format
, ...)
332 __attribute__ ((format (printf
, 3, 4)))
336 int pop_msg(POP
*p
, int stat
, const char *format
, ...)
338 __attribute__ ((format (printf
, 3, 4)))
342 int pop_maildir_info (POP
*);
343 int pop_maildir_open (POP
*, MsgInfoList
*);
344 int pop_maildir_update (POP
*);
346 int changeuser(POP
*, struct passwd
*);
347 void parse_header(MsgInfoList
*, char*);
348 int add_missing_headers(POP
*, MsgInfoList
*);
349 int login_user(POP
*p
);