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