2 * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
13 * $Id: sendmail.h,v 8.34.4.4 2000/07/15 17:35:17 gshapiro Exp $
17 ** SENDMAIL.H -- Global definitions for sendmail.
21 # include <sfio/stdio.h>
27 #include "sendmail/errstring.h"
28 #include "sendmail/useful.h"
31 /**********************************************************************
32 ** Table sizes, etc....
33 ** There shouldn't be much need to change these....
34 **********************************************************************/
36 # define MAXMAILERS 25 /* maximum mailers known to system */
37 #endif /* ! MAXMAILERS */
40 ** Data structure for bit maps.
42 ** Each bit in this map can be referenced by an ascii character.
43 ** This is 256 possible bits, or 32 8-bit bytes.
46 #define BITMAPBITS 256 /* number of bits in a bit map */
47 #define BYTEBITS 8 /* number of bits in a byte */
48 #define BITMAPBYTES (BITMAPBITS / BYTEBITS) /* number of bytes in bit map */
51 #define _BITWORD(bit) ((bit) / (BYTEBITS * sizeof (int)))
52 #define _BITBIT(bit) ((unsigned int)1 << ((bit) % (BYTEBITS * sizeof (int))))
54 typedef unsigned int BITMAP256[BITMAPBYTES / sizeof (int)];
56 /* test bit number N */
57 #define bitnset(bit, map) ((map)[_BITWORD(bit)] & _BITBIT(bit))
59 /* set bit number N */
60 #define setbitn(bit, map) (map)[_BITWORD(bit)] |= _BITBIT(bit)
62 /* clear bit number N */
63 #define clrbitn(bit, map) (map)[_BITWORD(bit)] &= ~_BITBIT(bit)
65 /* clear an entire bit map */
66 #define clrbitmap(map) memset((char *) map, '\0', BITMAPBYTES)
73 /* return number of bytes left in a buffer */
74 #define SPACELEFT(buf, ptr) (sizeof buf - ((ptr) - buf))
76 ** Flags passed to safefile/safedirpath.
79 #define SFF_ANYFILE 0L /* no special restrictions */
80 #define SFF_MUSTOWN 0x00000001L /* user must own this file */
81 #define SFF_NOSLINK 0x00000002L /* file cannot be a symbolic link */
82 #define SFF_ROOTOK 0x00000004L /* ok for root to own this file */
83 #define SFF_RUNASREALUID 0x00000008L /* if no ctladdr, run as real uid */
84 #define SFF_NOPATHCHECK 0x00000010L /* don't bother checking dir path */
85 #define SFF_SETUIDOK 0x00000020L /* setuid files are ok */
86 #define SFF_CREAT 0x00000040L /* ok to create file if necessary */
87 #define SFF_REGONLY 0x00000080L /* regular files only */
88 #define SFF_SAFEDIRPATH 0x00000100L /* no writable directories allowed */
89 #define SFF_NOHLINK 0x00000200L /* file cannot have hard links */
90 #define SFF_NOWLINK 0x00000400L /* links only in non-writable dirs */
91 #define SFF_NOGWFILES 0x00000800L /* disallow world writable files */
92 #define SFF_NOWWFILES 0x00001000L /* disallow group writable files */
93 #define SFF_OPENASROOT 0x00002000L /* open as root instead of real user */
94 #define SFF_NOLOCK 0x00004000L /* don't lock the file */
95 #define SFF_NOGRFILES 0x00008000L /* disallow g readable files */
96 #define SFF_NOWRFILES 0x00010000L /* disallow o readable files */
97 #define SFF_NOTEXCL 0x00020000L /* creates don't need to be exclusive */
98 #define SFF_EXECOK 0x00040000L /* executable files are ok (E_SM_ISEXEC) */
99 #define SFF_NORFILES (SFF_NOGRFILES|SFF_NOWRFILES)
102 #define SFF_NOLINK (SFF_NOHLINK|SFF_NOSLINK)
105 extern int safefile __P((char *, UID_T, GID_T, char *, long, int, struct stat *));
106 extern int safedirpath __P((char *, UID_T, GID_T, char *, long, int, int));
107 extern int safeopen __P((char *, int, int, long));
108 extern FILE *safefopen __P((char *, int, int, long));
109 extern int dfopen __P((char *, int, int, long));
110 extern bool filechanged __P((char *, int, struct stat *));
113 ** DontBlameSendmail options
115 ** Hopefully nobody uses these.
118 #define DBS_ASSUMESAFECHOWN 1
119 #define DBS_GROUPWRITABLEDIRPATHSAFE 2
120 #define DBS_GROUPWRITABLEFORWARDFILESAFE 3
121 #define DBS_GROUPWRITABLEINCLUDEFILESAFE 4
122 #define DBS_GROUPWRITABLEALIASFILE 5
123 #define DBS_WORLDWRITABLEALIASFILE 6
124 #define DBS_FORWARDFILEINUNSAFEDIRPATH 7
125 #define DBS_MAPINUNSAFEDIRPATH 8
126 #define DBS_LINKEDALIASFILEINWRITABLEDIR 9
127 #define DBS_LINKEDCLASSFILEINWRITABLEDIR 10
128 #define DBS_LINKEDFORWARDFILEINWRITABLEDIR 11
129 #define DBS_LINKEDINCLUDEFILEINWRITABLEDIR 12
130 #define DBS_LINKEDMAPINWRITABLEDIR 13
131 #define DBS_LINKEDSERVICESWITCHFILEINWRITABLEDIR 14
132 #define DBS_FILEDELIVERYTOHARDLINK 15
133 #define DBS_FILEDELIVERYTOSYMLINK 16
134 #define DBS_WRITEMAPTOHARDLINK 17
135 #define DBS_WRITEMAPTOSYMLINK 18
136 #define DBS_WRITESTATSTOHARDLINK 19
137 #define DBS_WRITESTATSTOSYMLINK 20
138 #define DBS_FORWARDFILEINGROUPWRITABLEDIRPATH 21
139 #define DBS_INCLUDEFILEINGROUPWRITABLEDIRPATH 22
140 #define DBS_CLASSFILEINUNSAFEDIRPATH 23
141 #define DBS_ERRORHEADERINUNSAFEDIRPATH 24
142 #define DBS_HELPFILEINUNSAFEDIRPATH 25
143 #define DBS_FORWARDFILEINUNSAFEDIRPATHSAFE 26
144 #define DBS_INCLUDEFILEINUNSAFEDIRPATHSAFE 27
145 #define DBS_RUNPROGRAMINUNSAFEDIRPATH 28 /* Not used yet */
146 #define DBS_RUNWRITABLEPROGRAM 29
147 #define DBS_INCLUDEFILEINUNSAFEDIRPATH 30
148 #define DBS_NONROOTSAFEADDR 31
149 #define DBS_TRUSTSTICKYBIT 32
150 #define DBS_DONTWARNFORWARDFILEINUNSAFEDIRPATH 33
151 #define DBS_INSUFFICIENTENTROPY 34
153 #define DBS_GROUPREADABLESASLFILE 35
154 #endif /* _FFR_UNSAFE_SASL */
156 /* struct defining such things */
159 char *dbs_name; /* name of DontBlameSendmail flag */
160 u_char dbs_flag; /* numeric level */
164 extern void dprintf __P((const char *, ...));
165 extern int dflush __P((void));
166 #else /* _FFR_DPRINTF */
167 #define dprintf printf
168 #define dflush() fflush(stdout)
169 #endif /* _FFR_DPRINTF */
171 extern int sm_snprintf __P((char *, size_t, const char *, ...));
172 extern int sm_vsnprintf __P((char *, size_t, const char *, va_list));
173 extern char *quad_to_string __P((QUAD_T));
175 extern size_t strlcpy __P((char *, const char *, size_t));
176 extern size_t strlcat __P((char *, const char *, size_t));