From owner-svn-src-all@FreeBSD.ORG Mon Oct 17 09:54:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 319FB106566B; Mon, 17 Oct 2011 09:54:08 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 219D18FC15; Mon, 17 Oct 2011 09:54:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9H9s8GY005019; Mon, 17 Oct 2011 09:54:08 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9H9s8lV005017; Mon, 17 Oct 2011 09:54:08 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201110170954.p9H9s8lV005017@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Mon, 17 Oct 2011 09:54:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226461 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Oct 2011 09:54:08 -0000 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);