1 /* 2 * Copyright (c) 2000-2002 Proofpoint, 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.20 2013/11/22 20:51:50 ca 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 #if NETINFO 41 char *cflocation; 42 #endif /* NETINFO */ 43 44 if (conffile != NULL) 45 return conffile; 46 47 if (cftype == SM_GET_SUBMIT_CF || 48 ((submitmode != SUBMIT_UNKNOWN || 49 opmode == MD_DELIVER || 50 opmode == MD_ARPAFTP || 51 opmode == MD_SMTP) && 52 cftype != SM_GET_SENDMAIL_CF)) 53 { 54 struct stat sbuf; 55 static char cf[MAXPATHLEN]; 56 57 #if NETINFO 58 cflocation = ni_propval("/locations", NULL, "sendmail", 59 "submit.cf", '\0'); 60 if (cflocation != NULL) 61 (void) sm_strlcpy(cf, cflocation, sizeof cf); 62 else 63 #endif /* NETINFO */ 64 (void) sm_strlcpyn(cf, sizeof cf, 2, _DIR_SENDMAILCF, 65 "submit.cf"); 66 if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0) 67 return cf; 68 } 69 #if NETINFO 70 cflocation = ni_propval("/locations", NULL, "sendmail", 71 "sendmail.cf", '\0'); 72 if (cflocation != NULL) 73 return cflocation; 74 #endif /* NETINFO */ 75 return _PATH_SENDMAILCF; 76 } 77