summaryrefslogtreecommitdiff
path: root/dbus/dbus-spawn.c
Commit message (Collapse)AuthorAgeFilesLines
* activation: set children oom_score_adj to 0WaLyong Cho2016-06-301-0/+20
| | | | | | | | | | If dbus is running as systemd service, dbus daemon is running with oom_score_adj -900 by OOMScoreAdjust=-900. And children will also have same value with dbus daemon. To avoid this, set the child itself values after fork () to 0. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32851 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Turn DBusSocket into a type-safe struct, preventing inappropriate conversionSimon McVittie2015-05-121-24/+24
| | | | | | | Fix the remaining platform-specific code to look at the struct's appropriate platform-specific member. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
* Rename _dbus_full_duplex_pipe() to more descriptive name _dbus_socketpair().Ralf Habacker2015-03-241-1/+1
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Revert "Rename _dbus_full_duplex_pipe() to more descriptive name ↵Ralf Habacker2015-03-111-1/+1
| | | | | | _dbus_socketpair()." This reverts commit ee0e15366c8b1ea196ad63a8376c8b5299279386.
* Rename _dbus_full_duplex_pipe() to more descriptive name _dbus_socketpair().Ralf Habacker2015-03-111-1/+1
| | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
* whitespace/comment fixesPatrick Welche2014-11-061-1/+1
| | | | | | | | [originally part of the previous commit -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69702 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
* dbus-spawn: do not forget the exec() errno when the grandchild exitsSimon McVittie2014-10-291-1/+17
| | | | | | | | | | | | As is already noted in a comment in _dbus_babysitter_set_child_exit_error(), if the grandchild fails to exec() the desired process, we get both CHILD_EXEC_FAILED (with an errno) and CHILD_EXITED (with a status), and we want to report the former, since it is more informative. However, clearing sitter->errnum meant we lose the errno value. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24821 Reviewed-by: Ross Lagerwall
* Fix compile error on opensuse 12.2 with systemd 44 and glibc-2.15.Ralf Habacker2014-01-101-0/+3
| | | | | | | The specific systemd/glibc version do not include syslog.h by default. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73455 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Fix api doc for _dbus_spawn_async_with_babysitterChengwei Yang2013-11-271-1/+1
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71820 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Close unused inherited file descriptorChengwei Yang2013-11-011-0/+2
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Add comments describing how "compile with journald, run without" worksSimon McVittie2013-11-011-2/+5
|
* Handle activated child stdout/stderr correctly in systemd environmentChengwei Yang2013-11-011-1/+35
| | | | | | | | | | | | | | | | | | | | In systemd environment, dbus-daemon will run as no-fork mode since this is the recommended practice of systemd. In that scenario, child activated by dbus-daemon will inherit dbus-daemon standard streams, includes stdin/stdout/stderr. stdin will be redirected to /dev/null by systemd and stdout/stderr will be catched by systemd log subsystem. Since the child inherit stdout/stderr from dbus-daemon, so from systemd journal log, the child log output will be identified with dbus-daemon identifier. So it's a little confusing. This patch redirects the child stdout/stderr to systemd journal stream, and with its owned service name as identifier. However, thing not fixed perfectly due to the socket ucred of the child is owned by dbus-daemon, so the pid isn't the real pid of the chile. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* DBusBabysitter: change executable to log_nameChengwei Yang2013-11-011-16/+28
| | | | | | | | | | | | | | | DBusBabysitter->executable is defined as executable name to use in error messages. However, if servicehelper used, then the executable name is servicehelper. It's not much help because we couldn't figure out which service we're trying to activated if error happens. In the following patch, we'll use service name to be activated as the child log identifier and add a parameter to _dbus_spawn_async_with_babysitter() to pass the log identifier. Since this is not the case in test, so executable changed to log_name. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* dbus-spawn: draw a diagramSimon McVittie2013-11-011-0/+42
| | | | | | | There are enough pipes, fds and processes here that it's important to keep track of them. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859
* dbus-spawn: correct a comment that falsely claimed thread-safetySimon McVittie2013-10-231-3/+8
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
* _dbus_spawn_async_with_babysitter: correct documentationSimon McVittie2013-10-231-1/+1
| | | | | | | env is used as you'd expect now. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
* Merge branch 'dbus-1.6'Simon McVittie2013-09-131-5/+8
|\ | | | | | | | | | | Conflicts: NEWS configure.ac
| * _dbus_babysitter_unref: avoid infinite loop if waitpid() returns EINTRSimon McVittie2013-09-051-5/+8
| | | | | | | | | | | | | | | | | | | | | | If waitpid() failed with EINTR, we'd go back for another go, but because ret is nonzero, we'd skip the waitpid() and just keep looping. Also avoid an unnecessary "goto" in favour of a proper loop, to make it more clearly correct. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68945 Reviewed-by: Colin Walters <walters@verbum.org>
* | tests to embedded tests: replaced in libdbusChengwei Yang2013-06-281-3/+3
| | | | | | | | | | | | Signed-off-by: Chengwei Yang <chengwei.yang@intel.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291
* | dbus-spawn: fix spacing mistake in commentRay Strode2012-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | commit 90f939f155bd120f44ff3906296707a6c00cd462 had two problems. 1) a small whitespace error in the added comment 2) the wrong bug reference at the bottom I'm using 1) as an excuse to add additional commit for the sake of 2). https://bugs.freedesktop.org/show_bug.cgi?id=56043
* | dbus-spawn: set SIGPIPE to SIG_IGN before activating servicesRay Strode2012-10-161-1/+5
|/ | | | | | | | | | | | | | | | | | | | | dbus's service activation code sets SIGPIPE to SIG_DFL as a sort of poor man's prctl(... PR_SET_PDEATHSIG) to detect when the parent goes away. It neglects to reignore the infamous signal before performing activation, however. This means if, for instance, journald is restarted all services activated after it will die with SIGPIPE when logging messages unless they explicitly ignore SIGPIPE themselves. This commit changes dbus's service activation code to correctly ignore SIGPIPE to protect activated services from a gruesome, premature death. Reviewed-by: Lennart Poettering <lennart@poettering.net> https://bugzilla.redhat.com/show_bug.cgi?id=839258
* Simplify substitution of test executables to use fewer variablesSimon McVittie2011-09-281-5/+59
| | | | | | | | | Also use EXEEXT in all the service files, even in the automake build system. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41222
* Use {}, not semicolon, when the statement of an "if" does nothingSimon McVittie2011-09-191-1/+3
| | | | | | The uses in bus/activation.c are also probably wrong because they ignore the result of the test, but that's orthogonal. (<https://bugs.freedesktop.org/show_bug.cgi?id=39858>)
* bus-activation: separate the "finished" callback from the watch callbackSimon McVittie2011-06-131-0/+19
| | | | | | | This has been marked as broken since 2003... Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342 Reviewed-by: Thiago Macieira <thiago@kde.org>
* Always remove, invalidate and free watches before closing watched socketsSimon McVittie2011-06-131-61/+61
| | | | | | | | | | | | | | This should mean we don't get invalid fds in the main loop. The BSD (kqueue) and Windows code paths are untested, but follow the same patterns as the tested Linux/generic Unix versions. DBusTransportSocket was already OK (it called free_watches() before _dbus_close_socket, and that did the remove, invalidate, unref dance). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33336 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk> Reviewed-by: Thiago Macieira <thiago@kde.org>
* dbus-spawn: don't leave bad file descriptors being watchedSimon McVittie2011-01-211-1/+26
| | | | | | | | | | | | The code called from handle_watch() might close either or both of the sockets we're watching, without cleaning up the DBusWatch. This results in invalid file descriptors being passed to _dbus_poll(), which could end up busy-looping on a POLLNVAL condition until the babysitter loses its last ref (which automatically clears up both watches). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32992 Bug-NB: NB#200248 Reviewed-by: Colin Walters <walters@verbum.org>
* fix some "unused result" warnings in dbus-launch and dbus-spawndbus-1.4.0Havoc Pennington2010-09-061-1/+2
| | | | Needed to avoid -Werror
* Merge branch 'dbus-1.2'Colin Walters2010-03-161-5/+5
|\ | | | | | | | | | | Conflicts: bus/bus.c configure.in
| * [dbus-spawn] Use correct sign values for variablesKimmo Hämäläinen2010-03-161-5/+5
| | | | | | | | | | | | read() returns a signed value, whereas the byte count is unsigned. Signed-off-by: Colin Walters <walters@verbum.org>
| * Bug 21161 - Update the FSF addressTobias Mueller2009-07-141-1/+1
| | | | | | | | | | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org> (cherry picked from commit 5baf2f856a9c6625993234855b07680da1c8916f)
| * Various compiler warning fixesColin Walters2009-01-061-2/+2
| |
* | Merge branch 'fd-passing'Thiago Macieira2009-07-161-8/+29
|\ \ | | | | | | | | | | | | | | | | | | Conflicts: dbus/dbus-connection.c dbus/dbus-message-util.c dbus/dbus-sysdeps-unix.c
| * | cloexec: make use of pipe2(O_CLOEXEC) when availableLennart Poettering2009-05-201-5/+29
| | | | | | | | | | | | This should fix another CLOEXEC race.
| * | cloexec: set FD_CLOEXEC for all full duplex pipesLennart Poettering2009-05-201-3/+0
| | | | | | | | | | | | | | | | | | | | | All users of full duplex pipes enable FD_CLOEXEC later anyway so let's just do it as part of _dbus_full_duplex_pipe. By side effect this allows to make use of SOCK_CLOEXEC which fixes a race when forking/execing from a different thread at the same time as we ar in this function.
* | | Bug 21161 - Update the FSF addressTobias Mueller2009-07-101-1/+1
|/ / | | | | | | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org>
* | Various compiler warning fixesColin Walters2008-12-191-2/+2
|/
* When spawning processes, don't ignore the passed in environmentRay Strode2008-07-121-1/+14
| | | | | | | | Previously, we'd always call execv() and unconditionally use the environment of the parent. Now we call execve() with the passed in environment. For compatibility, we detect if the passed in environment is NULL and for that case, use the environment from the parent instead.
* check write return value so we don't hang (FDO Bug #11665)John (J5) Palmieri2008-01-151-3/+3
| | | | | | | | | 2008-01-15 John (J5) Palmieri <johnp@redhat.com> * patch by Peter O'Gorman <pogma at thewrittenword dot com> * dbus/dbus-spawn.c (babysit_signal_handler): check write return value so we don't hang (FDO Bug #11665)
* the API contract says sitter_p can be NULL, so let's check it (FDO Bug #12919)John (J5) Palmieri2008-01-151-1/+3
| | | | | | | | | 2008-01-15 John (J5) Palmieri <johnp@redhat.com> * patch by Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com> * dbus/dbus-spawn.c (_dbus_spawn_async_with_babysitter): the API contract says sitter_p can be NULL, so let's check it (FDO Bug #12919)
* use correct ssize_t type instead of size_t (FDO Bug #12862)John (J5) Palmieri2008-01-151-2/+2
| | | | | | | | | 2008-01-15 John (J5) Palmieri <johnp@redhat.com> * patch by Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com> * dbus/dbus-spawn.c (read_ints, read_pid): use correct ssize_t type instead of size_t (FDO Bug #12862)
* add error handling when polling (FDO Bug #12954)John (J5) Palmieri2008-01-151-4/+19
| | | | | | | | | 2008-01-15 John (J5) Palmieri <johnp@redhat.com> * patch by Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com> * dbus/dbus-spawn.c (babysit, babysitter_iteration): add error handling when polling (FDO Bug #12954)
* Use DBUS_ERROR_INIT instead of dbus_error_init wherever it's clearly equivalentSimon McVittie2007-10-111-28/+10
|
* 2007-07-24 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-07-241-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.in: add AM_PROG_CC_C_O to allow per-target CPPFLAGS * bus/dispatch.c (bus_dispatch_test_conf): Fix up setting TEST_LAUNCH_HELPER_CONFIG to include the full path, and enable test shell_fail_service_auto_start when use_launcher==TRUE * bus/activation-helper-bin.c (convert_error_to_exit_code): pass through the INVALID_ARGS error so the test suite works * bus/activation.c (handle_activation_exit_error): return DBUS_ERROR_NO_MEMORY if we get BUS_SPAWN_EXIT_CODE_NO_MEMORY * dbus/dbus-spawn.c (_dbus_babysitter_get_child_exit_status): return only the exit code of the child, not the entire thingy from waitpid(), and make the return value indicate whether the child exited normally (with a status code) * bus/bus.c (process_config_first_time_only): _dbus_strdup works on NULL so no need to check (process_config_every_time): move servicehelper init here, so we reload it on HUP or config file change * bus/Makefile.am (install-data-hook): remove comment because Emacs make mode seems to be grumpy about it
* 2007-07-24 Richard Hughes <richard@hughsie.com>Richard Hughes2007-07-241-0/+25
| | | | | | | | | | | * dbus/dbus-spawn.c: (read_data), (_dbus_babysitter_get_child_exit_status): * dbus/dbus-spawn.h: Add a function so we can get access to the exit status of the launch helper. By providing the return code and not the error we can leave the 'what does this mean?' to the bus launch code and not include it in the dbus directory.
* 2007-07-13 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-07-141-1/+1
| | | | * Add indent-tabs-mode: nil to all file headers.
* 2007-06-18 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-06-181-1/+1
| | | | | | | | | * dbus/dbus-watch.c (dbus_watch_get_socket) (dbus_watch_get_unix_fd): new API to match DBusConnection (dbus_watch_get_fd): deprecate this Throughout: just s/dbus_watch_get_fd/dbus_watch_get_socket/g for now since all the transports use sockets anyway
* 2007-06-15 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-06-151-1/+3
| | | | | | | | | | | | | | * dbus/dbus-sysdeps.c (_dbus_set_errno_to_zero) (_dbus_get_is_errno_nonzero, _dbus_get_is_errno_eintr) (_dbus_strerror_from_errno): family of functions to abstract errno, though these are somewhat bogus (really we should make our socket wrappers not use errno probably - the issue is that any usage of errno that isn't socket-related probably is not cross-platform, so should either be in a unix-only file that can use errno directly, or is a bug - these general errno wrappers hide issues of this nature in non-socket code, while socket-specific API changes would not since sockets are allowed cross-platform)
* 2007-06-09 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-06-091-2/+2
| | | | | | | | | | | | | | | | | | | * bus/dispatch.c (check_get_connection_unix_process_id): adapt since sysdeps-unix.h stuff isn't included anymore * bus/bus.c (bus_context_new): use more abstract functions to change user, so they can be no-ops on Windows * dbus/dbus-credentials.c, dbus/dbus-credentials.h, dbus/dbus-credentials-util.c: new files containing a fully opaque DBusCredentials data type to replace the old not opaque one. * configure.in (DBUS_UNIX): define DBUS_UNIX to match DBUS_WIN on windows * dbus/dbus-userdb.h: prohibit on Windows, next step is to clean up the uses of it in bus/*.c and factor out the parts of cookie auth that depend on it
* * dbus/dbus-spawn.c,dbus/dbus-spawn.h (_dbus_spawn_async_with_babysitter):Ralf Habacker2007-03-041-4/+6
| | | | | | added environment pointer as function parameter,used on win32. * test/spawn-test.c: fixed call to above mentioned function.
* 2006-09-16 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-09-161-5/+5
| | | | | | | | | | * dbus/dbus-sysdeps-unix.h: small change to Peter's patch to make dbus-sysdeps-unix-util.c build, add unix-specific sysdeps header. * dbus/dbus-sysdeps.h, dbus-sysdeps-unix.c: patch from Peter Kümmel bug #8249 to make the sysdeps.h read/write/open/close functions specifically for sockets only, and move generic read/write/open/close into unix-specific code.