summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-08-19 11:58:14 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-08-19 11:58:14 +0000
commit8babce2b7eba089b3102afd2fa75156ed8453f47 (patch)
treedcdb47e6b0c7c9c49530ff110bb410975ad1f469
parent4cc364ed1ad41c90cd5332f1c55bbb8b6b5557b8 (diff)
downloadpica-pica-8babce2b7eba089b3102afd2fa75156ed8453f47.tar.gz
pica-pica-8babce2b7eba089b3102afd2fa75156ed8453f47.zip
default config location - sysconfdir. Fail if unable to open config file
git-svn-id: svn://localhost/project_picapica/trunk@170 fb96df88-216d-11de-830c-f3023f12d8ac
-rw-r--r--Makefile.am2
-rwxr-xr-xPICA_node.c7
-rw-r--r--PICA_nodeconfig.h6
3 files changed, 11 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 841663f..abde805 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,7 @@ pica_node_SOURCES = PICA_node.c PICA_msgproc.c PICA_nodeaddrlist.c \
dist_man_MANS = pica-node.8 pica-node.conf.5
-pica_node_CPPFLAGS = -DPICA_INSTALLPREFIX=\"$(prefix)\"
+pica_node_CPPFLAGS = -DPICA_INSTALLPREFIX=\"$(prefix)\" -DPICA_SYSCONFDIR=\"$(sysconfdir)\"
pkglocalstatedir = $(localstatedir)/pica-node
diff --git a/PICA_node.c b/PICA_node.c
index 3310bb7..763b394 100755
--- a/PICA_node.c
+++ b/PICA_node.c
@@ -2412,9 +2412,12 @@ int main(int argc,char** argv)
process_cmdline(argc, argv);
-nodecfg.config_file = (nodecfg.config_file ? nodecfg.config_file : "/etc/pica-node.conf");
+nodecfg.config_file = (nodecfg.config_file ? nodecfg.config_file :PICA_NODECONFIG_DEF_CONFIG_FILE);
-PICA_nodeconfig_load(nodecfg.config_file);
+if (!PICA_nodeconfig_load(nodecfg.config_file))
+ {
+ PICA_fatal("Unable to load configuration. Please check if config file %s exists and has correct permissions", nodecfg.config_file);
+ }
PICA_debug1("nodecfg.config_file = %s", nodecfg.config_file);
PICA_debug1("nodecfg.announced_addr = %s",nodecfg.announced_addr);
diff --git a/PICA_nodeconfig.h b/PICA_nodeconfig.h
index b232d22..66e02ef 100644
--- a/PICA_nodeconfig.h
+++ b/PICA_nodeconfig.h
@@ -6,10 +6,14 @@
#define PICA_INSTALLPREFIX "/usr"
#endif
+#ifndef PICA_SYSCONFDIR
+#define PICA_SYSCONFDIR "/etc"
+#endif
+
#define PICA_NODECONFIG_DEF_ANNOUNCED_ADDR "0.0.0.0"
#define PICA_NODECONFIG_DEF_LISTEN_PORT "2299"
#define PICA_NODECONFIG_DEF_NODES_DB_FILE "/var/lib/pica-node/nodelist.db"
-#define PICA_NODECONFIG_DEF_CONFIG_FILE "/etc/pica-node.conf"
+#define PICA_NODECONFIG_DEF_CONFIG_FILE PICA_SYSCONFDIR"/pica-node.conf"
#define PICA_NODECONFIG_DEF_CA_CERT_FILE PICA_INSTALLPREFIX"/share/pica-node/CA.pem"
struct nodeconfig