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 static char SccsId[] = "@(#)conf.c 3.20 08/21/81"; 36 37 38 # include <whoami.h> /* definitions of machine id's at berkeley */ 39 40 41 /* 42 ** Header info table 43 ** Final (null) entry contains the flags used for any other field. 44 ** 45 ** Not all of these are actually handled specially by sendmail 46 ** at this time. They are included as placeholders, to let 47 ** you know that "someday" I intend to have sendmail do 48 ** something with them. 49 */ 50 51 struct hdrinfo HdrInfo[] = 52 { 53 "date", H_CHECK, M_NEEDDATE, 54 "from", H_CHECK, M_NEEDFROM, 55 "sender", 0, 0, 56 "full-name", H_ACHECK, M_FULLNAME, 57 "to", 0, 0, 58 "cc", 0, 0, 59 "bcc", 0, 0, 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, 65 "received-date", H_CHECK, M_FINAL, 66 "received-from", H_CHECK, M_FINAL, 67 "precedence", 0, 0, 68 "via", H_FORCE, 0, 69 NULL, 0, 0, 70 }; 71 72 73 /* 74 ** ARPANET error message numbers. 75 */ 76 77 # ifdef NEWFTP 78 /* these are almost all unchecked */ 79 char Arpa_Info[] = "010"; /* arbitrary info: this is WRONG! */ 80 char Arpa_Enter[] = "354"; /* start mail input */ 81 char Arpa_Mmsg[] = "250"; /* mail successful (MAIL cmd) */ 82 char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 83 char Arpa_Syserr[] = "450"; /* some (transient) system error */ 84 char Arpa_Usrerr[] = "550"; /* some (fatal) user error */ 85 # else NEWFTP 86 char Arpa_Info[] = "050"; /* arbitrary info */ 87 char Arpa_Enter[] = "350"; /* start mail input */ 88 char Arpa_Mmsg[] = "256"; /* mail successful (MAIL cmd) */ 89 char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 90 char Arpa_Syserr[] = "455"; /* some (transient) system error */ 91 char Arpa_Usrerr[] = "450"; /* some (fatal) user error */ 92 # endif NEWFTP 93 94 # ifdef V6 95 /* 96 ** TTYNAME -- return name of terminal. 97 ** 98 ** Parameters: 99 ** fd -- file descriptor to check. 100 ** 101 ** Returns: 102 ** pointer to full path of tty. 103 ** NULL if no tty. 104 ** 105 ** Side Effects: 106 ** none. 107 */ 108 109 char * 110 ttyname(fd) 111 int fd; 112 { 113 register char tn; 114 static char pathn[] = "/dev/ttyx"; 115 116 /* compute the pathname of the controlling tty */ 117 if ((tn = ttyn(fd)) == NULL) 118 { 119 errno = 0; 120 return (NULL); 121 } 122 pathn[8] = tn; 123 return (pathn); 124 } 125 /* 126 ** FDOPEN -- Open a stdio file given an open file descriptor. 127 ** 128 ** This is included here because it is standard in v7, but we 129 ** need it in v6. 130 ** 131 ** Algorithm: 132 ** Open /dev/null to create a descriptor. 133 ** Close that descriptor. 134 ** Copy the existing fd into the descriptor. 135 ** 136 ** Parameters: 137 ** fd -- the open file descriptor. 138 ** type -- "r", "w", or whatever. 139 ** 140 ** Returns: 141 ** The file descriptor it creates. 142 ** 143 ** Side Effects: 144 ** none 145 ** 146 ** Called By: 147 ** deliver 148 ** 149 ** Notes: 150 ** The mode of fd must match "type". 151 */ 152 153 FILE * 154 fdopen(fd, type) 155 int fd; 156 char *type; 157 { 158 register FILE *f; 159 160 f = fopen("/dev/null", type); 161 (void) close(fileno(f)); 162 fileno(f) = fd; 163 return (f); 164 } 165 /* 166 ** INDEX -- Return pointer to character in string 167 ** 168 ** For V7 compatibility. 169 ** 170 ** Parameters: 171 ** s -- a string to scan. 172 ** c -- a character to look for. 173 ** 174 ** Returns: 175 ** If c is in s, returns the address of the first 176 ** instance of c in s. 177 ** NULL if c is not in s. 178 ** 179 ** Side Effects: 180 ** none. 181 */ 182 183 index(s, c) 184 register char *s; 185 register char c; 186 { 187 while (*s != '\0') 188 { 189 if (*s++ == c) 190 return (--s); 191 } 192 return (NULL); 193 } 194 # endif V6 195 /* 196 ** TTYPATH -- Get the path of the user's tty 197 ** 198 ** Returns the pathname of the user's tty. Returns NULL if 199 ** the user is not logged in or if s/he has write permission 200 ** denied. 201 ** 202 ** Parameters: 203 ** none 204 ** 205 ** Returns: 206 ** pathname of the user's tty. 207 ** NULL if not logged in or write permission denied. 208 ** 209 ** Side Effects: 210 ** none. 211 ** 212 ** WARNING: 213 ** Return value is in a local buffer. 214 ** 215 ** Called By: 216 ** savemail 217 */ 218 219 # include <sys/stat.h> 220 221 char * 222 ttypath() 223 { 224 struct stat stbuf; 225 register char *pathn; 226 extern char *ttyname(); 227 extern char *getlogin(); 228 229 /* compute the pathname of the controlling tty */ 230 if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 231 { 232 errno = 0; 233 return (NULL); 234 } 235 236 /* see if we have write permission */ 237 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 238 { 239 errno = 0; 240 return (NULL); 241 } 242 243 /* see if the user is logged in */ 244 if (getlogin() == NULL) 245 return (NULL); 246 247 /* looks good */ 248 return (pathn); 249 } 250 /* 251 ** CHECKCOMPAT -- check for From and To person compatible. 252 ** 253 ** This routine can be supplied on a per-installation basis 254 ** to determine whether a person is allowed to send a message. 255 ** This allows restriction of certain types of internet 256 ** forwarding or registration of users. 257 ** 258 ** If the hosts are found to be incompatible, an error 259 ** message should be given using "usrerr" and FALSE should 260 ** be returned. 261 ** 262 ** Parameters: 263 ** to -- the person being sent to. 264 ** 265 ** Returns: 266 ** TRUE -- ok to send. 267 ** FALSE -- not ok. 268 ** 269 ** Side Effects: 270 ** none (unless you include the usrerr stuff) 271 */ 272 273 bool 274 checkcompat(to) 275 register ADDRESS *to; 276 { 277 # ifdef lint 278 ADDRESS *x = to; 279 280 to = x; 281 # endif lint 282 283 return (TRUE); 284 } 285