xref: /netbsd-src/external/ibm-public/postfix/dist/src/postconf/postconf_misc.c (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: postconf_misc.c,v 1.2 2017/02/14 01:16:46 christos Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	postconf_misc 3
6 /* SUMMARY
7 /*	miscellaneous low-level code
8 /* SYNOPSIS
9 /*	#include <postconf.h>
10 /*
11 /*	void	pcf_set_config_dir()
12 /* DESCRIPTION
13 /*	pcf_set_config_dir() forcibly overrides the var_config_dir
14 /*	parameter setting with the value from the environment or
15 /*	with the default pathname, and updates the mail parameter
16 /*	dictionary.
17 /* DIAGNOSTICS
18 /*	Problems are reported to the standard error stream.
19 /* LICENSE
20 /* .ad
21 /* .fi
22 /*	The Secure Mailer license must be distributed with this software.
23 /* AUTHOR(S)
24 /*	Wietse Venema
25 /*	IBM T.J. Watson Research
26 /*	P.O. Box 704
27 /*	Yorktown Heights, NY 10598, USA
28 /*--*/
29 
30 /* System library. */
31 
32 #include <sys_defs.h>
33 
34 /* Utility library. */
35 
36 #include <mymalloc.h>
37 #include <safe.h>
38 
39 /* Global library. */
40 
41 #include <mail_params.h>
42 #include <mail_conf.h>
43 
44 /* Application-specific. */
45 
46 #include <postconf.h>
47 
48 /* pcf_set_config_dir - forcibly override var_config_dir */
49 
50 void    pcf_set_config_dir(void)
51 {
52     char   *config_dir;
53 
54     if (var_config_dir)
55 	myfree(var_config_dir);
56     if ((config_dir = safe_getenv(CONF_ENV_PATH)) != 0) {
57 	var_config_dir = mystrdup(config_dir);
58 	set_mail_conf_str(VAR_CONFIG_DIR, var_config_dir);
59     } else {
60 	var_config_dir = mystrdup(DEF_CONFIG_DIR);
61     }
62 }
63