Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Oct 2011 09:54:07 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226461 - head/sbin/hastd
Message-ID:  <201110170954.p9H9s8lV005017@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Mon Oct 17 09:54:07 2011
New Revision: 226461
URL: http://svn.freebsd.org/changeset/base/226461

Log:
  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

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==============================================================================
--- head/sbin/hastd/hastd.c	Mon Oct 17 06:10:32 2011	(r226460)
+++ head/sbin/hastd/hastd.c	Mon Oct 17 09:54:07 2011	(r226461)
@@ -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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110170954.p9H9s8lV005017>