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