dovecot-2.0: master: Don't fail startup if the full path to dove...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Apr 29 22:24:31 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/9ef2d07f786d
changeset: 9175:9ef2d07f786d
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 29 15:24:25 2009 -0400
description:
master: Don't fail startup if the full path to dovecot wasn't in argv[0].
diffstat:
1 file changed, 18 insertions(+), 3 deletions(-)
src/lib-master/master-service-settings.c | 21 ++++++++++++++++++---
diffs (38 lines):
diff -r 1ad6926f46a2 -r 9ef2d07f786d src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c Wed Apr 29 15:08:34 2009 -0400
+++ b/src/lib-master/master-service-settings.c Wed Apr 29 15:24:25 2009 -0400
@@ -55,7 +55,21 @@ static void ATTR_NORETURN
static void ATTR_NORETURN
master_service_exec_config(struct master_service *service, bool preserve_home)
{
- const char **conf_argv;
+ const char **conf_argv, *path, *const *paths, *binary_path;
+
+ binary_path = service->argv[0];
+ path = getenv("PATH");
+ if (*service->argv[0] != '/') {
+ /* we have to find our executable from path */
+ paths = t_strsplit(path, ":");
+ for (; *paths != NULL; paths++) {
+ path = t_strconcat(*paths, "/", binary_path, NULL);
+ if (access(path, X_OK) == 0) {
+ binary_path = path;
+ break;
+ }
+ }
+ }
if (!service->keep_environment)
master_service_env_clean(preserve_home);
@@ -68,8 +82,9 @@ master_service_exec_config(struct master
conf_argv[3] = "-c";
conf_argv[4] = service->config_path;
conf_argv[5] = "-e";
- memcpy(conf_argv+6, service->argv,
- (service->argc+1) * sizeof(conf_argv[0]));
+ conf_argv[6] = binary_path;
+ memcpy(conf_argv+7, service->argv + 1,
+ (service->argc) * sizeof(conf_argv[0]));
execv(conf_argv[0], (char **)conf_argv);
i_fatal("execv(%s) failed: %m", conf_argv[0]);
}
More information about the dovecot-cvs
mailing list