From 3a75526503c2fda6353c5ab4e8f6acc067caf1fa Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 18 Jan 2014 12:17:43 +0800 Subject: [PATCH] Set argv[0] to dbus-launch to avoid misleading info from /proc At previous, argv[0] is the full-qualified path of program, however, if start dbus-launch failed, it will fall back to find one from $PATH, while keep the argv[0] as the full-qualified path. So we'll get misleading info from /proc or ps(1) about dbus-launch process. One simple solution is just hard-code argv[0] to dbus-launch, something like (From Simon). archetype% cat /proc/$$/cmdline; printf "\n" zsh Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69716 --- dbus/dbus-sysdeps-unix.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index ae42f56..4b35ee4 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3476,6 +3476,7 @@ _dbus_get_autolaunch_address (const char *scope, * but that's done elsewhere, and if it worked, this function wouldn't * be called.) */ const char *display; + char *progpath; char *argv[6]; int i; DBusString uuid; @@ -3515,13 +3516,19 @@ _dbus_get_autolaunch_address (const char *scope, goto out; } - i = 0; #ifdef DBUS_ENABLE_EMBEDDED_TESTS if (_dbus_getenv ("DBUS_USE_TEST_BINARY") != NULL) - argv[i] = TEST_BUS_LAUNCH_BINARY; + progpath = TEST_BUS_LAUNCH_BINARY; else #endif - argv[i] = DBUS_BINDIR "/dbus-launch"; + progpath = DBUS_BINDIR "/dbus-launch"; + /* + * argv[0] is always dbus-launch, that's the name what we'll + * get from /proc, or ps(1), regardless what the progpath is, + * see fd.o#69716 + */ + i = 0; + argv[i] = "dbus-launch"; ++i; argv[i] = "--autolaunch"; ++i; @@ -3536,7 +3543,7 @@ _dbus_get_autolaunch_address (const char *scope, _dbus_assert (i == _DBUS_N_ELEMENTS (argv)); - retval = _read_subprocess_line_argv (argv[0], + retval = _read_subprocess_line_argv (progpath, TRUE, argv, address, error); -- 1.7.9.5