Commit | Line | Data |
---|---|---|
b3cbe40f | 1 | # include <pwd.h> |
96faada8 | 2 | # include "sendmail.h" |
916b3375 | 3 | |
b3cbe40f | 4 | /* |
96faada8 | 5 | ** CONF.C -- Sendmail Configuration Tables. |
b3cbe40f EA |
6 | ** |
7 | ** Defines the configuration of this installation. | |
8 | ** | |
cb590f52 | 9 | ** Compilation Flags: |
cb590f52 EA |
10 | ** V6 -- running on a version 6 system. This determines |
11 | ** whether to define certain routines between | |
12 | ** the two systems. If you are running a funny | |
13 | ** system, e.g., V6 with long tty names, this | |
14 | ** should be checked carefully. | |
b3cbe40f | 15 | ** |
cb590f52 | 16 | ** Configuration Variables: |
1a12c7d6 EA |
17 | ** HdrInfo -- a table describing well-known header fields. |
18 | ** Each entry has the field name and some flags, | |
df960d9b | 19 | ** which are described in sendmail.h. |
74c5fe7c EA |
20 | ** StdTimezone -- name of local timezone in standard time |
21 | ** (V6 only). | |
22 | ** DstTimezone -- name of local timezone in daylight savings | |
23 | ** time (V6 only). | |
9c6d4c70 EA |
24 | ** |
25 | ** Notes: | |
26 | ** I have tried to put almost all the reasonable | |
27 | ** configuration information into the configuration | |
28 | ** file read at runtime. My intent is that anything | |
29 | ** here is a function of the version of UNIX you | |
30 | ** are running, or is really static -- for example | |
31 | ** the headers are a superset of widely used | |
32 | ** protocols. If you find yourself playing with | |
33 | ** this file too much, you may be making a mistake! | |
b3cbe40f EA |
34 | */ |
35 | ||
36 | ||
37 | ||
38 | ||
884a20cb | 39 | static char SccsId[] = "@(#)conf.c 3.40 %G%"; |
b5fd168f | 40 | \f/* |
1a12c7d6 | 41 | ** Header info table |
355a2a04 | 42 | ** Final (null) entry contains the flags used for any other field. |
df960d9b EA |
43 | ** |
44 | ** Not all of these are actually handled specially by sendmail | |
45 | ** at this time. They are included as placeholders, to let | |
46 | ** you know that "someday" I intend to have sendmail do | |
47 | ** something with them. | |
1a12c7d6 EA |
48 | */ |
49 | ||
50 | struct hdrinfo HdrInfo[] = | |
51 | { | |
df960d9b EA |
52 | "date", H_CHECK, M_NEEDDATE, |
53 | "from", H_CHECK, M_NEEDFROM, | |
327272f5 | 54 | "original-from", 0, 0, |
df960d9b EA |
55 | "sender", 0, 0, |
56 | "full-name", H_ACHECK, M_FULLNAME, | |
a502a3e7 EA |
57 | "to", H_ADDR, 0, |
58 | "cc", H_ADDR, 0, | |
59 | "bcc", H_ADDR|H_ACHECK, 0, | |
df960d9b EA |
60 | "message-id", H_CHECK, M_MSGID, |
61 | "message", H_EOH, 0, | |
62 | "text", H_EOH, 0, | |
63 | "posted-date", 0, 0, | |
64 | "return-receipt-to", 0, 0, | |
7add9668 EA |
65 | "received-date", H_CHECK, M_LOCAL, |
66 | "received-from", H_CHECK, M_LOCAL, | |
df960d9b EA |
67 | "precedence", 0, 0, |
68 | "via", H_FORCE, 0, | |
69 | NULL, 0, 0, | |
1a12c7d6 | 70 | }; |
15b28570 EA |
71 | |
72 | ||
73 | /* | |
74 | ** ARPANET error message numbers. | |
75 | */ | |
76 | ||
15b28570 | 77 | char Arpa_Info[] = "050"; /* arbitrary info */ |
49086753 EA |
78 | char Arpa_Syserr[] = "451"; /* some (transient) system error */ |
79 | char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ | |
4e1f4d4b EA |
80 | |
81 | ||
82 | ||
83 | ||
84 | ||
85 | /* | |
86 | ** Location of system files/databases/etc. | |
87 | */ | |
88 | ||
89 | char *AliasFile = "/usr/lib/aliases"; /* alias file */ | |
90 | char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ | |
71df6b97 | 91 | char *StatFile = "/usr/lib/sendmail.st"; /* statistics summary */ |
a1a88160 | 92 | char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ |
884a20cb | 93 | # ifdef QUEUE |
ed45aae1 | 94 | char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ |
884a20cb EA |
95 | # else QUEUE |
96 | char *QueueDir = "/tmp"; /* location of temp files */ | |
97 | # endif QUEUE | |
ed45aae1 | 98 | char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ |
74c5fe7c EA |
99 | |
100 | ||
a13c4f97 EA |
101 | /* |
102 | ** Other configuration. | |
103 | */ | |
104 | ||
105 | int DefUid = 1; /* the uid to execute mailers as */ | |
106 | int DefGid = 1; /* ditto for gid */ | |
ed45aae1 | 107 | time_t TimeOut = 3*24*60*60; /* default timeout for queue files */ |
a13c4f97 EA |
108 | |
109 | ||
74c5fe7c EA |
110 | |
111 | /* | |
112 | ** V6 system configuration. | |
113 | */ | |
114 | ||
115 | # ifdef V6 | |
116 | char *StdTimezone = "PST"; /* std time timezone */ | |
117 | char *DstTimezone = "PDT"; /* daylight time timezone */ | |
118 | # endif V6 | |
b3cbe40f EA |
119 | \f |
120 | # ifdef V6 | |
121 | /* | |
14e42c2b | 122 | ** TTYNAME -- return name of terminal. |
b3cbe40f EA |
123 | ** |
124 | ** Parameters: | |
14e42c2b | 125 | ** fd -- file descriptor to check. |
b3cbe40f EA |
126 | ** |
127 | ** Returns: | |
14e42c2b EA |
128 | ** pointer to full path of tty. |
129 | ** NULL if no tty. | |
b3cbe40f EA |
130 | ** |
131 | ** Side Effects: | |
132 | ** none. | |
b3cbe40f EA |
133 | */ |
134 | ||
b3cbe40f | 135 | char * |
14e42c2b EA |
136 | ttyname(fd) |
137 | int fd; | |
b3cbe40f | 138 | { |
14e42c2b | 139 | register char tn; |
b3cbe40f | 140 | static char pathn[] = "/dev/ttyx"; |
b3cbe40f EA |
141 | |
142 | /* compute the pathname of the controlling tty */ | |
14e42c2b | 143 | if ((tn = ttyn(fd)) == NULL) |
b3cbe40f EA |
144 | { |
145 | errno = 0; | |
146 | return (NULL); | |
147 | } | |
14e42c2b | 148 | pathn[8] = tn; |
b3cbe40f EA |
149 | return (pathn); |
150 | } | |
151 | \f/* | |
152 | ** FDOPEN -- Open a stdio file given an open file descriptor. | |
153 | ** | |
154 | ** This is included here because it is standard in v7, but we | |
155 | ** need it in v6. | |
156 | ** | |
157 | ** Algorithm: | |
158 | ** Open /dev/null to create a descriptor. | |
159 | ** Close that descriptor. | |
160 | ** Copy the existing fd into the descriptor. | |
161 | ** | |
162 | ** Parameters: | |
163 | ** fd -- the open file descriptor. | |
164 | ** type -- "r", "w", or whatever. | |
165 | ** | |
166 | ** Returns: | |
167 | ** The file descriptor it creates. | |
168 | ** | |
169 | ** Side Effects: | |
170 | ** none | |
171 | ** | |
b3cbe40f EA |
172 | ** Called By: |
173 | ** deliver | |
174 | ** | |
175 | ** Notes: | |
176 | ** The mode of fd must match "type". | |
177 | */ | |
178 | ||
179 | FILE * | |
180 | fdopen(fd, type) | |
181 | int fd; | |
182 | char *type; | |
183 | { | |
184 | register FILE *f; | |
185 | ||
186 | f = fopen("/dev/null", type); | |
29871fef | 187 | (void) close(fileno(f)); |
b3cbe40f EA |
188 | fileno(f) = fd; |
189 | return (f); | |
190 | } | |
191 | \f/* | |
192 | ** INDEX -- Return pointer to character in string | |
193 | ** | |
194 | ** For V7 compatibility. | |
195 | ** | |
196 | ** Parameters: | |
197 | ** s -- a string to scan. | |
198 | ** c -- a character to look for. | |
199 | ** | |
200 | ** Returns: | |
201 | ** If c is in s, returns the address of the first | |
202 | ** instance of c in s. | |
203 | ** NULL if c is not in s. | |
204 | ** | |
205 | ** Side Effects: | |
206 | ** none. | |
b3cbe40f EA |
207 | */ |
208 | ||
b14547d5 | 209 | char * |
b3cbe40f EA |
210 | index(s, c) |
211 | register char *s; | |
212 | register char c; | |
213 | { | |
214 | while (*s != '\0') | |
215 | { | |
216 | if (*s++ == c) | |
217 | return (--s); | |
218 | } | |
219 | return (NULL); | |
220 | } | |
a0554f81 EA |
221 | \f/* |
222 | ** UMASK -- fake the umask system call. | |
223 | ** | |
224 | ** Since V6 always acts like the umask is zero, we will just | |
225 | ** assume the same thing. | |
226 | */ | |
227 | ||
228 | /*ARGSUSED*/ | |
229 | umask(nmask) | |
230 | { | |
231 | return (0); | |
232 | } | |
233 | ||
234 | ||
235 | /* | |
236 | ** GETRUID -- get real user id. | |
237 | */ | |
238 | ||
239 | getruid() | |
240 | { | |
241 | return (getuid() & 0377); | |
242 | } | |
243 | ||
244 | ||
245 | /* | |
246 | ** GETRGID -- get real group id. | |
247 | */ | |
248 | ||
249 | getrgid() | |
250 | { | |
251 | return (getgid() & 0377); | |
252 | } | |
253 | ||
254 | ||
255 | /* | |
256 | ** GETEUID -- get effective user id. | |
257 | */ | |
258 | ||
259 | geteuid() | |
260 | { | |
261 | return ((getuid() >> 8) & 0377); | |
262 | } | |
263 | ||
264 | ||
265 | /* | |
266 | ** GETEGID -- get effective group id. | |
267 | */ | |
268 | ||
269 | getegid() | |
270 | { | |
271 | return ((getgid() >> 8) & 0377); | |
272 | } | |
273 | ||
274 | # endif V6 | |
275 | \f | |
276 | # ifndef V6 | |
277 | ||
278 | /* | |
279 | ** GETRUID -- get real user id (V7) | |
280 | */ | |
281 | ||
282 | getruid() | |
283 | { | |
f6a0cc15 EA |
284 | if (Daemon) |
285 | return (RealUid); | |
286 | else | |
287 | return (getuid()); | |
a0554f81 EA |
288 | } |
289 | ||
290 | ||
291 | /* | |
292 | ** GETRGID -- get real group id (V7). | |
293 | */ | |
294 | ||
295 | getrgid() | |
296 | { | |
f6a0cc15 EA |
297 | if (Daemon) |
298 | return (RealGid); | |
299 | else | |
300 | return (getgid()); | |
a0554f81 EA |
301 | } |
302 | ||
b3cbe40f | 303 | # endif V6 |
14e42c2b EA |
304 | \f/* |
305 | ** TTYPATH -- Get the path of the user's tty | |
b3cbe40f EA |
306 | ** |
307 | ** Returns the pathname of the user's tty. Returns NULL if | |
308 | ** the user is not logged in or if s/he has write permission | |
309 | ** denied. | |
310 | ** | |
311 | ** Parameters: | |
312 | ** none | |
313 | ** | |
314 | ** Returns: | |
315 | ** pathname of the user's tty. | |
316 | ** NULL if not logged in or write permission denied. | |
317 | ** | |
318 | ** Side Effects: | |
319 | ** none. | |
320 | ** | |
321 | ** WARNING: | |
322 | ** Return value is in a local buffer. | |
323 | ** | |
b3cbe40f EA |
324 | ** Called By: |
325 | ** savemail | |
b3cbe40f EA |
326 | */ |
327 | ||
b3cbe40f EA |
328 | # include <sys/stat.h> |
329 | ||
330 | char * | |
331 | ttypath() | |
332 | { | |
333 | struct stat stbuf; | |
334 | register char *pathn; | |
b3cbe40f | 335 | extern char *ttyname(); |
29871fef | 336 | extern char *getlogin(); |
b3cbe40f EA |
337 | |
338 | /* compute the pathname of the controlling tty */ | |
339 | if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) | |
340 | { | |
341 | errno = 0; | |
342 | return (NULL); | |
343 | } | |
344 | ||
345 | /* see if we have write permission */ | |
a530c75f | 346 | if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) |
b3cbe40f EA |
347 | { |
348 | errno = 0; | |
349 | return (NULL); | |
350 | } | |
351 | ||
352 | /* see if the user is logged in */ | |
353 | if (getlogin() == NULL) | |
354 | return (NULL); | |
355 | ||
356 | /* looks good */ | |
357 | return (pathn); | |
358 | } | |
a530c75f EA |
359 | \f/* |
360 | ** CHECKCOMPAT -- check for From and To person compatible. | |
361 | ** | |
362 | ** This routine can be supplied on a per-installation basis | |
363 | ** to determine whether a person is allowed to send a message. | |
364 | ** This allows restriction of certain types of internet | |
365 | ** forwarding or registration of users. | |
366 | ** | |
367 | ** If the hosts are found to be incompatible, an error | |
368 | ** message should be given using "usrerr" and FALSE should | |
369 | ** be returned. | |
370 | ** | |
46b14b48 EA |
371 | ** 'NoReturn' can be set to suppress the return-to-sender |
372 | ** function; this should be done on huge messages. | |
373 | ** | |
a530c75f EA |
374 | ** Parameters: |
375 | ** to -- the person being sent to. | |
376 | ** | |
377 | ** Returns: | |
378 | ** TRUE -- ok to send. | |
379 | ** FALSE -- not ok. | |
380 | ** | |
381 | ** Side Effects: | |
382 | ** none (unless you include the usrerr stuff) | |
383 | */ | |
384 | ||
385 | bool | |
386 | checkcompat(to) | |
387 | register ADDRESS *to; | |
388 | { | |
ed45aae1 | 389 | # ifdef ING70 |
b14547d5 | 390 | register STAB *s; |
ed45aae1 | 391 | # endif ING70 |
b14547d5 | 392 | |
179c1218 | 393 | if (to->q_mailer != LocalMailer && MsgSize > 100000) |
46b14b48 EA |
394 | { |
395 | usrerr("Message exceeds 100000 bytes"); | |
396 | NoReturn++; | |
397 | return (FALSE); | |
398 | } | |
b14547d5 EA |
399 | # ifdef ING70 |
400 | s = stab("arpa", ST_MAILER, ST_FIND); | |
179c1218 | 401 | if (s != NULL && From.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) |
b14547d5 EA |
402 | { |
403 | usrerr("No ARPA mail through this machine: see your system administration"); | |
404 | return (FALSE); | |
405 | } | |
406 | # endif ING70 | |
a530c75f EA |
407 | return (TRUE); |
408 | } |