diff options
-rw-r--r-- | README.rst | 4 | ||||
-rw-r--r-- | src/syncevo/ForkExec.cpp | 30 | ||||
-rw-r--r-- | src/syncevo/syncevo.am | 2 |
3 files changed, 32 insertions, 4 deletions
@@ -1048,6 +1048,10 @@ SYNCEVOLUTION_DATA_DIR SYNCEVOLUTION_BACKEND_DIR Overrides the default path to plugins, normally `/usr/lib/syncevolution/backends`. +SYNCEVOLUTION_LIBEXEC_DIR + Overrides the path where additional helper executables are found, normally + `/usr/libexec`. + SYNCEVOLUTION_TEMPLATE_DIR Overrides the default path to template files, normally `/usr/share/syncevolution/templates`. diff --git a/src/syncevo/ForkExec.cpp b/src/syncevo/ForkExec.cpp index a0030d63..09c5490f 100644 --- a/src/syncevo/ForkExec.cpp +++ b/src/syncevo/ForkExec.cpp @@ -80,7 +80,32 @@ void ForkExecParent::start() } m_server->setNewConnectionCallback(boost::bind(&ForkExecParent::newClientConnection, this, _2)); - m_argvStrings.push_back(m_helper); + // look for helper binary + std::string helper; + GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD; + if (m_helper.find('/') == m_helper.npos) { + helper = getEnv("SYNCEVOLUTION_LIBEXEC_DIR", ""); + if (helper.empty()) { + // env variable not set, look in libexec dir + helper = SYNCEVO_LIBEXEC; + helper += "/"; + helper += m_helper; + if (access(helper.c_str(), R_OK)) { + // some error, try PATH + flags = (GSpawnFlags)(flags | G_SPAWN_SEARCH_PATH); + helper = m_helper; + } + } else { + // use env variable without further checks, must work + helper += "/"; + helper += m_helper; + } + } else { + // absolute path, use it + m_helper = helper; + } + + m_argvStrings.push_back(helper); m_argv.reset(AllocStringArray(m_argvStrings)); for (char **env = environ; *env; @@ -98,8 +123,7 @@ void ForkExecParent::start() if (!g_spawn_async_with_pipes(NULL, // working directory static_cast<gchar **>(m_argv.get()), static_cast<gchar **>(m_env.get()), - (GSpawnFlags)((m_helper.find('/') == m_helper.npos ? G_SPAWN_SEARCH_PATH : 0) | - G_SPAWN_DO_NOT_REAP_CHILD), + flags, setStdoutToStderr, // child setup function: redirect stdout to stderr where it will be caught by our own output redirection code // TODO: avoid logging child errors as "[ERROR] stderr: [ERROR] onConnect not implemented" // TODO: log child INFO messages? diff --git a/src/syncevo/syncevo.am b/src/syncevo/syncevo.am index f5eceeea..2d55432a 100644 --- a/src/syncevo/syncevo.am +++ b/src/syncevo/syncevo.am @@ -3,7 +3,7 @@ include $(top_srcdir)/src/syncevo/configs/configs.am # applies to sources in SyncEvolution repository, but not # the Funambol C++ client library src_syncevo_cxxflags = @SYNCEVOLUTION_CXXFLAGS@ -src_syncevo_cppflags = @BACKEND_CPPFLAGS@ @GLIB_CFLAGS@ -I$(top_srcdir)/test -I$(gdbus_dir) $(DBUS_CFLAGS) -I$(top_builddir)/src/syncevo -I$(top_srcdir)/src -DSYNCEVO_BACKEND=\"$(BACKENDS_SEARCH_DIRECTORY)\" +src_syncevo_cppflags = @BACKEND_CPPFLAGS@ @GLIB_CFLAGS@ -I$(top_srcdir)/test -I$(gdbus_dir) $(DBUS_CFLAGS) -I$(top_builddir)/src/syncevo -I$(top_srcdir)/src -DSYNCEVO_LIBEXEC=\"$(libexecdir)\" -DSYNCEVO_BACKEND=\"$(BACKENDS_SEARCH_DIRECTORY)\" src_syncevo_ldadd = @SYNCEVOLUTION_LDADD@ if COND_DBUS |