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