summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-07-20 15:47:57 +0100
committerLennart Poettering <lennart@poettering.net>2009-07-20 15:48:36 +0100
commita2b207e38ac35ffc048351f76d83f7f9db37bb6c (patch)
tree67135f52a96bede66875423cddd37f6b6a19deee /src/daemon
parent6fdd5846b24dd9346bfa5abae1fd727189681477 (diff)
daemon: before exec'ing ourselves, make sure nobody plays games with /proc/self/exe
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c
index eb378d24..07439675 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -405,7 +405,8 @@ int main(int argc, char *argv[]) {
/*
Disable lazy relocations to make usage of external libraries
more deterministic for our RT threads. We abuse __OPTIMIZE__ as
- a check whether we are a debug build or not.
+ a check whether we are a debug build or not. This all is
+ admittedly a bit snake-oilish.
*/
if (!getenv("LD_BIND_NOW")) {
@@ -416,9 +417,16 @@ int main(int argc, char *argv[]) {
pa_set_env("LD_BIND_NOW", "1");
- if ((rp = pa_readlink("/proc/self/exe")))
- pa_assert_se(execv(rp, argv) == 0);
- else
+ if ((rp = pa_readlink("/proc/self/exe"))) {
+
+ if (pa_streq(rp, PA_BINARY))
+ pa_assert_se(execv(rp, argv) == 0);
+ else
+ pa_log_warn("/proc/self/exe does not point to " PA_BINARY ", cannot self execute. Are you playing games?");
+
+ pa_xfree(rp);
+
+ } else
pa_log_warn("Couldn't read /proc/self/exe, cannot self execute. Running in a chroot()?");
}
#endif