summaryrefslogtreecommitdiffstats
path: root/sbin/hastd
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-10-17 09:54:07 +0000
committerpjd <pjd@FreeBSD.org>2011-10-17 09:54:07 +0000
commitcc73b6a0415423003fdfbf5fbd3b5ed9b5055dbe (patch)
tree81b6ea2bc25d4b90df63aa01e9f128eec7eb8688 /sbin/hastd
parent2a41d7e8051e247e771134602fcf07235a90a819 (diff)
downloadFreeBSD-src-cc73b6a0415423003fdfbf5fbd3b5ed9b5055dbe.zip
FreeBSD-src-cc73b6a0415423003fdfbf5fbd3b5ed9b5055dbe.tar.gz
When path to the configuration file is relative, obtain full path,
so we can always find the file, even after daemonizing and changing working directory to /. MFC after: 1 week
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/hastd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c
index d21f7f6..e4cd5202 100644
--- a/sbin/hastd/hastd.c
+++ b/sbin/hastd/hastd.c
@@ -1168,6 +1168,22 @@ main(int argc, char *argv[])
pjdlog_errno(LOG_WARNING, "Unable to open or create pidfile");
}
+ /*
+ * When path to the configuration file is relative, obtain full path,
+ * so we can always find the file, even after daemonizing and changing
+ * working directory to /.
+ */
+ if (cfgpath[0] != '/') {
+ const char *newcfgpath;
+
+ newcfgpath = realpath(cfgpath, NULL);
+ if (newcfgpath == NULL) {
+ pjdlog_exit(EX_CONFIG,
+ "Unable to obtain full path of %s", cfgpath);
+ }
+ cfgpath = newcfgpath;
+ }
+
cfg = yy_config_parse(cfgpath, true);
PJDLOG_ASSERT(cfg != NULL);
OpenPOWER on IntegriCloud