Mercurial > dovecot > core-2.2
changeset 9242:031bfa5a8995 HEAD
Fixed running <path>/<binary> when building absolute path for doveconf -e.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 06 May 2009 15:22:35 -0400 |
parents | 0b74ad9372d9 |
children | 64a7a1a3fe33 |
files | src/lib-master/master-service-settings.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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_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++) {