cf.c revision 363466
134925Sdufault/* 234925Sdufault * Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers. 334030Sdufault * All rights reserved. 434030Sdufault * 534030Sdufault * By using this file, you agree to the terms and conditions set 634030Sdufault * forth in the LICENSE file which can be found at the top level of 734030Sdufault * the sendmail distribution. 834030Sdufault * 934030Sdufault */ 1034030Sdufault 1134030Sdufault#include <sendmail.h> 1234030SdufaultSM_RCSID("@(#)$Id: cf.c,v 8.20 2013-11-22 20:51:50 ca Exp $") 1334030Sdufault#include <sendmail/pathnames.h> 1434030Sdufault 1534030Sdufault/* 1634030Sdufault** GETCFNAME -- return the name of the .cf file to use. 1734030Sdufault** 1834030Sdufault** Some systems (e.g., NeXT) determine this dynamically. 1934030Sdufault** 2034030Sdufault** For others: returns submit.cf or sendmail.cf depending 2134030Sdufault** on the modes. 2234030Sdufault** 2334030Sdufault** Parameters: 2434030Sdufault** opmode -- operation mode. 2534030Sdufault** submitmode -- submit mode. 2634030Sdufault** cftype -- may request a certain cf file. 2734030Sdufault** conffile -- if set, return it. 2834030Sdufault** 2934030Sdufault** Returns: 3034030Sdufault** name of .cf file. 3134030Sdufault*/ 3234030Sdufault 3334030Sdufaultchar * 3455140Sbdegetcfname(opmode, submitmode, cftype, conffile) 3534030Sdufault int opmode; 3634030Sdufault int submitmode; 3734030Sdufault int cftype; 3834030Sdufault char *conffile; 3934925Sdufault{ 4034925Sdufault#if NETINFO 4134030Sdufault char *cflocation; 4234925Sdufault#endif 4345739Speter 4434925Sdufault if (conffile != NULL) 4534030Sdufault return conffile; 4634925Sdufault 4734925Sdufault if (cftype == SM_GET_SUBMIT_CF || 4883366Sjulian ((submitmode != SUBMIT_UNKNOWN || 4934030Sdufault opmode == MD_DELIVER || 5034925Sdufault opmode == MD_ARPAFTP || 5183366Sjulian opmode == MD_SMTP) && 5234925Sdufault cftype != SM_GET_SENDMAIL_CF)) 5383366Sjulian { 5434925Sdufault struct stat sbuf; 5534030Sdufault static char cf[MAXPATHLEN]; 5634030Sdufault 5734925Sdufault#if NETINFO 5834030Sdufault cflocation = ni_propval("/locations", NULL, "sendmail", 5934925Sdufault "submit.cf", '\0'); 6034925Sdufault if (cflocation != NULL) 6134925Sdufault (void) sm_strlcpy(cf, cflocation, sizeof cf); 6292727Salfred else 6334925Sdufault#endif /* NETINFO */ 6492727Salfred (void) sm_strlcpyn(cf, sizeof cf, 2, _DIR_SENDMAILCF, 65103574Salfred "submit.cf"); 66106998Salfred if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0) 6734925Sdufault return cf; 6834925Sdufault } 6934925Sdufault#if NETINFO 7034030Sdufault cflocation = ni_propval("/locations", NULL, "sendmail", 7134030Sdufault "sendmail.cf", '\0'); 7234030Sdufault if (cflocation != NULL) 7334030Sdufault return cflocation; 7434030Sdufault#endif 7534030Sdufault return _PATH_SENDMAILCF; 7634030Sdufault} 7734030Sdufault