1 /* 2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 */ 10 11 #include <sendmail.h> 12 SM_RCSID("@(#)$Id: cf.c,v 8.16 2001/09/11 04:04:55 gshapiro Exp $") 13 #include <sendmail/pathnames.h> 14 15 /* 16 ** GETCFNAME -- return the name of the .cf file to use. 17 ** 18 ** Some systems (e.g., NeXT) determine this dynamically. 19 ** 20 ** For others: returns submit.cf or sendmail.cf depending 21 ** on the modes. 22 ** 23 ** Parameters: 24 ** opmode -- operation mode. 25 ** submitmode -- submit mode. 26 ** cftype -- may request a certain cf file. 27 ** conffile -- if set, return it. 28 ** 29 ** Returns: 30 ** name of .cf file. 31 */ 32 33 char * 34 getcfname(opmode, submitmode, cftype, conffile) 35 int opmode; 36 int submitmode; 37 int cftype; 38 char *conffile; 39 { 40 41 if (conffile != NULL) 42 return conffile; 43 44 #if NETINFO 45 { 46 char *cflocation; 47 48 cflocation = ni_propval("/locations", NULL, "sendmail", 49 "sendmail.cf", '\0'); 50 if (cflocation != NULL) 51 return cflocation; 52 } 53 #endif /* NETINFO */ 54 55 if (cftype == SM_GET_SUBMIT_CF || 56 ((submitmode != SUBMIT_UNKNOWN || 57 opmode == MD_DELIVER || 58 opmode == MD_ARPAFTP || 59 opmode == MD_SMTP) && 60 cftype != SM_GET_SENDMAIL_CF)) 61 { 62 struct stat sbuf; 63 static char cf[PATH_MAX]; 64 65 (void) sm_strlcpyn(cf, sizeof cf, 2, _DIR_SENDMAILCF, 66 "submit.cf"); 67 if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0) 68 return cf; 69 } 70 return _PATH_SENDMAILCF; 71 } 72