xref: /netbsd-src/external/ibm-public/postfix/dist/src/postconf/postconf_misc.c (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1 /*	$NetBSD: postconf_misc.c,v 1.1.1.1 2013/01/02 18:59:03 tron 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	set_config_dir()
12 /* DESCRIPTION
13 /*	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 /* set_config_dir - forcibly override var_config_dir */
49 
50 void set_config_dir(void)
51 {
52     char   *config_dir;
53 
54     if (var_config_dir)
55         myfree(var_config_dir);
56     var_config_dir = mystrdup((config_dir = safe_getenv(CONF_ENV_PATH)) != 0 ?
57                               config_dir : DEF_CONFIG_DIR);     /* XXX */
58     set_mail_conf_str(VAR_CONFIG_DIR, var_config_dir);
59 }
60