dovecot-2.0: Fixed running <path>/<binary> when building absolut...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 6 22:23:03 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/031bfa5a8995
changeset: 9242:031bfa5a8995
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 06 15:22:35 2009 -0400
description:
Fixed running <path>/<binary> when building absolute path for doveconf -e.

diffstat:

1 file changed, 9 insertions(+), 2 deletions(-)
src/lib-master/master-service-settings.c |   11 +++++++++--

diffs (23 lines):

diff -r 0b74ad9372d9 -r 031bfa5a8995 src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c	Wed May 06 15:09:38 2009 -0400
+++ b/src/lib-master/master-service-settings.c	Wed May 06 15:22:35 2009 -0400
@@ -56,10 +56,17 @@ master_service_exec_config(struct master
 master_service_exec_config(struct master_service *service, bool preserve_home)
 {
 	const char **conf_argv, *path, *const *paths, *binary_path;
+	char full_path[PATH_MAX];
 
 	binary_path = service->argv[0];
-	path = getenv("PATH");
-	if (*service->argv[0] != '/' && path != NULL) {
+	if (*service->argv[0] == '/') {
+		/* already have the path */
+	} else if (strchr(service->argv[0], '/') != NULL) {
+		/* relative to current directory */
+		if (realpath(service->argv[0], full_path) == NULL)
+			i_fatal("realpath(%s) failed: %m", service->argv[0]);
+		binary_path = full_path;
+	} else if ((path = getenv("PATH")) != NULL) {
 		/* we have to find our executable from path */
 		paths = t_strsplit(path, ":");
 		for (; *paths != NULL; paths++) {


More information about the dovecot-cvs mailing list