~ari-tczew/ubuntu/dapper/fetchmail/fix-CVE-2008-2711

« back to all changes in this revision

Viewing changes to fetchmail.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-02-07 12:12:13 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060207121213-onurwfrzdlzlzxnt
Tags: 6.3.2-2ubuntu1
* Resynchronise with Debian. This brings the new upstream version to dapper
  since upstream support for 6.2 was dropped.
* Drop debian/patches/CVE-2005-4348.dpatch, upstream now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** \file fetchmail.h  header file for fetchmail */
 
2
#ifndef _FETCHMAIL_H
 
3
#define _FETCHMAIL_H
1
4
/*
2
5
 * For license terms, see the file COPYING in this directory.
3
6
 */
8
11
/* We need this for size_t */
9
12
#include <sys/types.h>
10
13
 
 
14
/* We need this for time_t */
 
15
#if TIME_WITH_SYS_TIME
 
16
# include <sys/time.h>
 
17
# include <time.h>
 
18
#else
 
19
# if HAVE_SYS_TIME_H
 
20
#  include <sys/time.h>
 
21
# else
 
22
#  include <time.h>
 
23
# endif
 
24
#endif
 
25
 
 
26
#include <stdio.h>
 
27
 
 
28
/* Import Trio if needed */
 
29
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
 
30
#  include "trio/trio.h"
 
31
#endif
 
32
 
 
33
/* We need this for strstr */
 
34
#if !defined(HAVE_STRSTR) && !defined(strstr)
 
35
char *strstr(const char *, const char *);
 
36
#endif
 
37
 
11
38
/* constants designating the various supported protocols */
12
39
#define         P_AUTO          1
13
40
#define         P_POP2          2
18
45
#define         P_ETRN          7
19
46
#define         P_ODMR          8
20
47
 
21
 
#if INET6_ENABLE
22
48
#define         SMTP_PORT       "smtp"
 
49
#define         SMTP_PORT_NUM   25
23
50
#define         KPOP_PORT       "kpop"
24
 
#else /* INET6_ENABLE */
25
 
#define         SMTP_PORT       25
26
 
#define         KPOP_PORT       1109
27
 
#endif /* INET6_ENABLE */
28
51
 
29
52
#ifdef SSL_ENABLE
30
53
#define         SIMAP_PORT      993
48
71
#define         A_KERBEROS_V5   6       /* authenticate w/ Kerberos V5 */
49
72
#define         A_GSSAPI        7       /* authenticate with GSSAPI */
50
73
#define         A_SSH           8       /* authentication at session level */
 
74
#define         A_MSN           9       /* same as NTLM with keyword MSN */
51
75
 
52
 
/* some protocols (KERBEROS, GSSAPI, SSH) don't require a password */
53
 
#define NO_PASSWORD(ctl)        ((ctl)->server.authenticate > A_OTP || (ctl)->server.protocol == P_ETRN)
 
76
/* some protocols or authentication types (KERBEROS, GSSAPI, SSH) don't
 
77
 * require a password */
 
78
#define NO_PASSWORD(ctl) \
 
79
    ((ctl)->server.authenticate == A_OTP \
 
80
     || (ctl)->server.authenticate == A_KERBEROS_V4 \
 
81
     || (ctl)->server.authenticate == A_KERBEROS_V5 \
 
82
     || (ctl)->server.authenticate == A_GSSAPI \
 
83
     || (ctl)->server.authenticate == A_SSH \
 
84
     || (ctl)->server.protocol == P_ETRN)
54
85
 
55
86
/*
56
87
 * Definitions for buffer sizes.  We get little help on setting maxima
165
196
struct method           /* describe methods for protocol state machine */
166
197
{
167
198
    const char *name;           /* protocol name */
168
 
#if INET6_ENABLE
169
 
    const char *service;
170
 
    const char *sslservice;
171
 
#else /* INET6_ENABLE */
172
 
    int port;                   /* service port */
173
 
    int sslport;                /* service port for ssl */
174
 
#endif /* INET6_ENABLE */
 
199
    const char *service;        /* service port (unencrypted) */
 
200
    const char *sslservice;     /* service port (SSL) */
175
201
    flag tagged;                /* if true, generate & expect command tags */
176
202
    flag delimited;             /* if true, accept "." message delimiter */
177
203
    int (*parse_response)(int, char *);
190
216
                                /* fetch FROM headera given message */
191
217
    int (*fetch_body)(int, struct query *, int, int *);
192
218
                                /* fetch a given message */
193
 
    int (*trail)(int, struct query *, int);
 
219
    int (*trail)(int, struct query *, int, const char *);
194
220
                                /* eat trailer of a message */
195
221
    int (*delete)(int, struct query *, int);
196
222
                                /* delete method */
197
223
    int (*mark_seen)(int, struct query *, int);
198
224
                                /* mark as seen method */
 
225
    int (*end_mailbox_poll)(int, struct query *);
 
226
                                /* end-of-mailbox processing */
199
227
    int (*logout_cmd)(int, struct query *);
200
228
                                /* logout command */
201
229
    flag retry;                 /* can getrange poll for new messages? */
209
237
    struct idlist *akalist;             /* server name first, then akas */
210
238
    struct idlist *localdomains;        /* list of pass-through domains */
211
239
    int protocol;                       /* protocol type */
212
 
#if INET6_ENABLE
213
 
    char *service;                      /* IPv6 service name */
214
 
    void *netsec;                       /* IPv6 security request */
215
 
#else /* INET6_ENABLE */
216
 
    int port;                           /* TCP/IP service port number */
217
 
#endif /* INET6_ENABLE */
 
240
    char *service;                      /* service name */
218
241
    int interval;                       /* # cycles to skip between polls */
219
242
    int authenticate;                   /* authentication mode to try */
220
243
    int timeout;                        /* inactivity timout in seconds */
227
250
#ifdef SDPS_ENABLE
228
251
    flag sdps;                          /* use Demon Internet SDPS *ENV */
229
252
#endif /* SDPS_ENABLE */
230
 
    flag checkalias;                    /* resolve aliases by comparing IPs? */
 
253
    flag checkalias;                    /* resolve aliases by comparing IPs? */
 
254
    flag tracepolls;                    /* if TRUE, add poll trace info to Received */
231
255
    char *principal;                    /* Kerberos principal for mail service */
232
256
    char *esmtp_name, *esmtp_password;  /* ESMTP AUTH information */
233
257
 
234
258
#if defined(linux) || defined(__FreeBSD__)
 
259
#define CAN_MONITOR
 
260
#endif
 
261
 
 
262
#ifdef CAN_MONITOR
235
263
    char *interface;
236
264
    char *monitor;
237
265
    int  monitor_io;
238
266
    struct interface_pair_s *interface_pair;
239
 
#endif /* linux */
 
267
#endif
240
268
 
241
269
    char *plugin,*plugout;
242
270
 
245
273
    int poll_count;                     /* count of polls so far */
246
274
    char *queryname;                    /* name to attempt DNS lookup on */
247
275
    char *truename;                     /* "true name" of server host */
248
 
    char *trueaddr;                     /* IP address of truename, as char */
 
276
    struct sockaddr *trueaddr;          /* IP address of truename */
 
277
    size_t trueaddr_len;                /* size of trueaddr data */
249
278
    struct hostdata *lead_server;       /* ptr to lead query for this server */
250
279
    int esmtp_options;
 
280
    int workarounds;                    /* track which workarounds the user was warned about */
251
281
};
252
282
 
 
283
/*
 
284
 * bit flags to set in workarounds after the corresponding warning,
 
285
 * which we assume to be server-specific, has been printed,
 
286
 * so we don't spam our users in daemon mode.
 
287
 */
 
288
#define WKA_TOP (1L << 0)               /* Maillennium TOP -> RETR override warning */
 
289
 
253
290
struct query
254
291
{
255
292
    /* mailserver connection controls */
280
317
    flag keep;                  /* if TRUE, leave messages undeleted */
281
318
    flag fetchall;              /* if TRUE, fetch all (not just unseen) */
282
319
    flag flush;                 /* if TRUE, delete messages already seen */
 
320
    flag limitflush;            /* if TRUE, delete oversized mails */
283
321
    flag rewrite;               /* if TRUE, canonicalize recipient addresses */
284
322
    flag stripcr;               /* if TRUE, strip CRs in text */
285
323
    flag forcecr;               /* if TRUE, force CRs before LFs in text */
304
342
    flag sslcertck;             /* Strictly check the server cert. */
305
343
    char *sslfingerprint;       /* Fingerprint to check against */
306
344
    char *properties;           /* passthrough properties for extensions */
307
 
    flag tracepolls;            /* if TRUE, add poll trace info to Received */
308
345
 
309
346
    /* internal use -- per-poll state */
310
347
    flag active;                /* should we actually poll this server? */
311
 
    const char *destaddr;       /* destination host for this query */
 
348
    char *destaddr;             /* destination host for this query */
312
349
    int errcount;               /* count transient errors in last pass */
313
350
    int authfailcount;          /* count of authorization failures */
314
351
    int wehaveauthed;           /* We've managed to logon at least once! */
315
352
    int wehavesentauthnote;     /* We've sent an authorization failure note */
316
353
    int wedged;                 /* wedged by auth failures or timeouts? */
317
354
    char *smtphost;             /* actual SMTP host we connected to */
 
355
    char smtphostmode;          /* what's the actual SMTP host's wire protocol? */
318
356
    int smtp_socket;            /* socket descriptor for SMTP connection */
319
357
    unsigned int uid;           /* UID of user to deliver to */
320
358
    struct idlist *skipped;     /* messages skipped on the mail server */
384
422
extern struct runctl run;       /* global controls for this run */
385
423
extern flag nodetach;           /* if TRUE, don't detach daemon process */
386
424
extern flag quitmode;           /* if --quit was set */
 
425
extern int  quitind;            /* optind after position of last --quit option */
387
426
extern flag check_only;         /* if --check was set */
388
427
extern char *rcfile;            /* path name of rc file */
389
428
extern int linelimit;           /* limit # lines retrieved per site */
401
440
extern char *sdps_envto;
402
441
#endif /* SDPS_ENABLE */
403
442
 
 
443
extern const char *iana_charset;        /* IANA assigned charset name */
 
444
 
 
445
/* from ucs/norm_charmap.c */
 
446
const char *norm_charmap(const char *name);
 
447
 
404
448
/* prototypes for globally callable functions */
405
449
 
406
450
/* from /usr/include/sys/cdefs.h */
432
476
 
433
477
/* driver.c -- main driver loop */
434
478
void set_timeout(int);
435
 
int isidletimeout(void);
 
479
int is_idletimeout(void);
436
480
void resetidletimeout(void);
437
481
int do_protocol(struct query *, const struct method *);
438
482
 
461
505
extern struct msgblk msgblk;
462
506
 
463
507
/* lock.c: concurrency locking */
464
 
void lock_setup(void), lock_assert(void);
465
 
void lock_or_die(void), lock_release(void);
 
508
void lock_setup(void);
 
509
void lock_assert(void);
 
510
void lock_or_die(void);
 
511
void fm_lock_release(void);
466
512
int lock_state(void);
467
513
void lock_dispose(void);
468
514
 
492
538
 
493
539
/* idle.c */
494
540
int interruptible_idle(int interval);
 
541
extern volatile int lastsig;
495
542
 
496
543
/* sink.c: forwarding */
497
544
void smtp_close(struct query *, int);
503
550
int close_sink(struct query *, struct msgblk *, flag);
504
551
int open_warning_by_mail(struct query *, struct msgblk *);
505
552
#if defined(HAVE_STDARG_H)
506
 
void stuff_warning(struct query *, const char *, ... )
507
 
    __attribute__ ((format (printf, 2, 3)))
 
553
void stuff_warning(const char *, struct query *, const char *, ... )
 
554
    __attribute__ ((format (printf, 3, 4)))
508
555
    ;
509
556
#else
510
557
void stuff_warning();
512
559
void close_warning_by_mail(struct query *, struct msgblk *);
513
560
 
514
561
/* rfc822.c: RFC822 header parsing */
515
 
unsigned char *reply_hack(unsigned char *, const unsigned char *, int *);
 
562
unsigned char *reply_hack(unsigned char *, const unsigned char *, size_t *);
516
563
unsigned char *nxtaddr(const unsigned char *);
517
564
 
518
565
/* uid.c: UID support */
572
619
#endif
573
620
XMALLOCTYPE *xmalloc(size_t);
574
621
XMALLOCTYPE *xrealloc(/*@null@*/ XMALLOCTYPE *, size_t);
 
622
#define xfree(p) { if (p) { free(p); } (p) = 0; }
575
623
char *xstrdup(const char *);
576
 
#if defined(HAVE_ALLOCA_H)
577
 
#include <alloca.h>
578
 
#else
579
 
#ifdef _AIX
580
 
#pragma alloca
581
 
#endif
582
 
#endif
583
 
#define xalloca(ptr, t, n)      if (!(ptr = (t) alloca(n)))\
584
 
       {report(stderr, GT_("alloca failed")); exit(PS_UNDEFINED);}
585
 
#if 0
586
 
/*
587
 
 * This is a hack to help xgettext which cannot find strings in
588
 
 * macro definitions like the one for xalloca above.
589
 
 */
590
 
static char *dummy = gettext_noop("alloca failed");
591
 
#endif
592
624
 
593
625
/* protocol driver and methods */
594
626
int doPOP2 (struct query *); 
600
632
/* authentication functions */
601
633
int do_cram_md5(int sock, char *command, struct query *ctl, char *strip);
602
634
int do_rfc1731(int sock, char *command, char *truename);
603
 
int do_gssauth(int sock, char *command, char *hostname, char *username);
 
635
int do_gssauth(int sock, char *command, char *service, char *hostname, char *username);
604
636
int do_otp(int sock, char *command, struct query *ctl);
605
637
 
606
638
/* miscellanea */
611
643
struct query *hostalloc(struct query *); 
612
644
int parsecmdline (int, char **, struct runctl *, struct query *);
613
645
char *prependdir (const char *, const char *);
614
 
char *MD5Digest (unsigned char *);
 
646
char *MD5Digest (unsigned const char *);
615
647
void hmac_md5 (unsigned char *, size_t, unsigned char *, size_t, unsigned char *, size_t);
616
648
int POP3_auth_rpa(unsigned char *, unsigned char *, int socket);
617
649
typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
625
657
const char *showproto(int);
626
658
void dump_config(struct runctl *runp, struct query *querylist);
627
659
int is_host_alias(const char *, struct query *);
628
 
char *host_fqdn(void);
 
660
 
 
661
/** Try to obtain fully qualified hostname of current host. Exit with
 
662
 * PS_DNS if \a required is true and there is a DNS error. Exit with
 
663
 * PS_DNS if gethostname() fails, independent of the value of \a
 
664
 * required.
 
665
 * \return
 
666
 * - fully qualified hostname if \a required is non-zero.
 
667
 * - unqualified or fully qualified hostname if \a required is zero (0).
 
668
 */
 
669
char *host_fqdn(int required /** exit with PS_DNS if the name cannot be qualified */);
629
670
char *rfc822timestamp(void);
630
 
flag isafile(int);
 
671
flag is_a_file(int);
 
672
char *rfc2047e(const char*, const char *);
631
673
 
632
674
void yyerror(const char *);
633
675
int yylex(void);
647
689
 
648
690
# if HAVE_STRERROR
649
691
#  ifndef strerror              /* On some systems, strerror is a macro */
650
 
char *strerror ();
 
692
char *strerror (int);
651
693
#  endif
652
694
# endif /* HAVE_STRERROR */
653
695
 
660
702
#endif
661
703
#endif
662
704
 
 
705
#ifndef HAVE_STPCPY
 
706
char *stpcpy(char *, const char*);
 
707
#endif
 
708
 
663
709
#ifdef FETCHMAIL_DEBUG
664
710
#define exit(e) do { \
665
711
       FILE *out; \
678
724
#define ROOT_UID 0
679
725
#endif /* __CYGWIN__ */
680
726
 
 
727
extern int mailserver_socket_temp;
 
728
extern char *program_name;
 
729
 
 
730
/* POSIX space characters,
 
731
 * <tab>;<newline>;<vertical-tab>;<form-feed>;<carriage-return>;<space> */
 
732
#define POSIX_space "\t\n\v\f\r "
 
733
 
 
734
/* strlcpy/strlcat prototypes */
 
735
#ifndef HAVE_STRLCAT
 
736
size_t
 
737
strlcat(char *dst, const char *src, size_t siz);
 
738
#endif
 
739
#ifndef HAVE_STRLCPY
 
740
size_t
 
741
strlcpy(char *dst, const char *src, size_t siz);
 
742
#endif
 
743
 
 
744
/** Resolve the a TCP service name or a string containing only a decimal
 
745
 * positive integer to a port number. Returns -1 for error. */
 
746
int servport(const char *service);
 
747
 
 
748
#ifndef HAVE_GETNAMEINFO
 
749
# define NI_NUMERICHOST 1
 
750
# define NI_NUMERICSERV 2
 
751
# define NI_NOFQDN      4
 
752
# define NI_NAMEREQD    8
 
753
# define NI_DGRAM       16
 
754
#endif
 
755
 
 
756
#endif
681
757
/* fetchmail.h ends here */