summaryrefslogtreecommitdiff
path: root/bus/activation.c
AgeCommit message (Collapse)AuthorFilesLines
2013-06-05When "activating" systemd, handle its special case betterChengwei Yang1-5/+14
When dbus-daemon receives a request to activate a systemd service before systemd has connected to it, it enqueues a fake request to "activate" systemd itself (as a way to get a BusPendingActivationEntry to track the process of waiting for systemd). When systemd later joins the bus, dbus-daemon sends the actual activation message; any future activation messages are sent directly to systemd. In the "pending" code path, the activation messages are currently dispatched as though they had been sent by the same process that sent the original activation request, which is wrong: the bus security policy probably doesn't allow that process to talk to systemd directly. They should be dispatched as though they had been sent by the dbus-daemon itself (connection == NULL), the same as in the non-pending code path. In the worst case, if the attempt to activate systemd timed out, the dbus-daemon would crash with a (fatal) warning, because in this special case, activation_message is a signal with no serial number, whereas the code to send an error reply is expecting a method call with a serial number. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50199 Signed-off-by: Chengwei Yang <chengwei.yang@intel.com> Tested-by: Ma Yu <yu.ma@intel.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2012-02-07Merge branch 'socket-set-33337'Simon McVittie1-1/+11
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33337
2011-09-21Merge branch 'more-unused-39231'Simon McVittie1-2/+6
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39231 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-09-21Merge branch 'dbus-1.4'Simon McVittie1-4/+7
Conflicts: NEWS
2011-09-21update_desktop_file_entry: initialize return value properly, and actually ↵Simon McVittie1-1/+2
return it Since 1.4.4 (commit 75cfd97f) this function always returned FALSE. As far as I can see this was actually harmless, because both of its callers ignore any error that is not NoMemory (and treat it the same as success). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39230 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-09-21update_desktop_file_entry: if the service name already existed, set errorSimon McVittie1-1/+4
If we're going to return FALSE for this (which has apparently always been the case), then we should set an error properly. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39230 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-09-21update_desktop_file_entry: don't leak file_path on one particular OOMSimon McVittie1-2/+1
Revenge of #33126: most, but not all, temporary variables were freed on this code path. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39230 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-09-19Use {}, not semicolon, when the statement of an "if" does nothingSimon McVittie1-2/+6
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>)
2011-08-05Remove various never-used variablesSimon McVittie1-3/+0
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39231 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-06-13Add a stub _dbus_loop_toggle_watch and call it where neededSimon McVittie1-1/+11
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33337 Bug-NB: NB#197191
2011-06-13bus-activation: separate the "finished" callback from the watch callbackSimon McVittie1-23/+11
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>
2011-06-13DBusLoop: remove second layer of watch callbacks where possibleSimon McVittie1-4/+4
Similar to the previous commit, almost every use of DBusWatch can just have the main loop call dbus_watch_handle. The one exception is the bus activation code; it's had a comment explaining why it's wrong since 2003. We should fix that one day, but for now, just migrate it to a new _dbus_loop_add_watch_full which preserves the second-layer callback. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342 Reviewed-by: Thiago Macieira <thiago@kde.org>
2011-06-13DBusLoop: remove a layer of pointless abstraction around timeoutsSimon McVittie1-16/+2
Instead of supplying 8 tiny wrapper functions around dbus_timeout_handle, each with a user_data parameter that's a potentially unsafe borrowed pointer but isn't actually used, we can call dbus_timeout_handle directly and save a lot of trouble. One of the wrappers previously called dbus_timeout_handle repeatedly if it returned FALSE to indicate OOM, but that timeout's handler never actually returned FALSE, so there was no practical effect. The rest just ignore the return, which is documented as OK to do. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342 Reviewed-by: Thiago Macieira <thiago@kde.org>
2011-04-26activation: Use _dbus_system_log for activation informationColin Walters1-8/+60
Log when we are activating something (and whether it's via systemd) as well as when we fail to activate, and when one succeeds. https://bugs.freedesktop.org/show_bug.cgi?id=35705
2011-04-08activation: Strip out code to compare by Exec=Colin Walters1-18/+4
In commit: 075945f6 (John (J5) Palmieri 2005-07-14 20:44:15 +0000 some code was added to compare services by Exec key. The changelog is not pariticularly informative as to why this was added. But while debugging other code, we noticed this. Comparing by Exec key is not in the specification, and triggered a problem where while converting services to use systemd for activation, a change was made to use Exec=/bin/false and simply rely on systemd to activate. While I think it was broken for the service files to be changed to Exec=/bin/false, we shouldn't be doing something here that's not in the spec either. Reviewed-by: Will Thompson <will.thompson@collabora.co.uk> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=35750
2011-02-16update_desktop_file_entry: stylistic fixes based on Colin's reviewSimon McVittie1-20/+23
2011-02-16update_desktop_file_entry: unify cleanup code for success and failure casesSimon McVittie1-18/+17
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
2011-02-16update_desktop_file_entry: don't double-free strings if added to entry ↵Simon McVittie1-0/+11
before failure Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
2011-02-16update_desktop_file_entry: free @exec on errorSimon McVittie1-0/+1
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
2011-02-16update_desktop_file_entry: make scope of exec_tmp as short as possibleSimon McVittie1-3/+4
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
2011-02-16update_desktop_file_entry: use _dbus_strdup for something we'll dbus_freeSimon McVittie1-1/+1
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126
2010-07-09activation: optionally, use systemd for system bus activationLennart Poettering1-187/+362
2010-04-21Patch relocating "exec" variable and position of service filesFridrich Štrba1-3/+7
2010-03-19Consistently include <config.h> in all C source files and never in header files.Marcus Brinkmann1-0/+2
2010-03-19Dispatch post-activation messages to anyone interestedWill Thompson1-14/+6
Previously, if a method call activated a service, it would only be delivered to that service, and not to other services with match rules which should match. This patch replaces the improperly-duplicated dispatch code in activation.c with a call back into the normal dispatch code, fixing this bug (fd.o#26427). (Additionally, were one to service-activate a service that doesn't understand file descriptors with a message containing a file descriptor, the previous code would send it anyway, and the service's dbus library would blow up. This is also fixed here, since the normal dispatch code checks this correctly.)
2010-01-28Don't drop pending activations when reloading configurationColin Walters1-40/+64
The reload handling for activation simply dropped all knowledge of pending activations, which was clearly wrong. Refactor things so that reload only reloads directories, server address etc. Based on a patch originally from Matthias Clasen <mclasen@redhat.com>
2010-01-28Ignore exit code zero from activated servicesColin Walters1-28/+55
A variety of system components have migrated from legacy init into DBus service activation. Many of these system components "daemonize", which involves forking. The DBus activation system treated an exit as an activation failure, assuming that the child process which grabbed the DBus name didn't run first. While we're in here, also differentiate in this code path between the servicehelper (system) versus direct activation (session) paths. In the session activation path our error message mentioned a helper process which was confusing, since none was involved. Based on a patch and debugging research from Ray Strode <rstrode@redhat.com>
2009-07-14Bug 21161 - Update the FSF addressTobias Mueller1-1/+1
No comment. Signed-off-by: Colin Walters <walters@verbum.org> (cherry picked from commit 5baf2f856a9c6625993234855b07680da1c8916f)
2009-01-06Avoid possible use of uninitialized variablePeter Breitenlohner1-1/+1
Signed-off-by: Colin Walters <walters@verbum.org>
2008-07-15Fix leaks in bus_activation_get_environment error pathsRay Strode1-2/+5
Commit 91306ef938873fce8f2ae2d4a6b3282d0379c65a introduced two memory leaks on OOM error paths. In one case the environment string array wasn't getting freed, and in the other case it was getting freed with dbus_free instead of dbus_free_string_array.
2008-07-12Store what environment to activate with on activation objectRay Strode1-18/+212
We now keep the environment in a hash table member of the activation object and provide a method bus_activation_set_environment_variable to modify the hash table. This hash table is seeded initially with the environment of the bus daemon itself.
2007-07-262007-07-26 Havoc Pennington <hp@redhat.com>Havoc Pennington1-0/+4
* bus/config-parser-trivial.c (check_return_values): disable a test that hardcoded the bus user's name * bus/dispatch.c (bus_dispatch_test_conf): remove the "if (!use_launcher)" around the tests, they were only failing because we didn't pass through all the expected errors from the helper. * bus/activation-exit-codes.h (BUS_SPAWN_EXIT_CODE_CHILD_SIGNALED): add a code for child segfaulting (BUS_SPAWN_EXIT_CODE_GENERIC_FAILURE): make "1" be a generic failure code, so if a third party launch helper were written it could just always return 1 on failure.
2007-07-242007-07-24 Havoc Pennington <hp@redhat.com>Havoc Pennington1-3/+8
* 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-242007-07-24 Richard Hughes <richard@hughsie.com>Richard Hughes1-2/+56
* bus/activation.c: (bus_activation_activate_service): If the bus uses a service-laucher, then use the setuid laucher.
2007-07-242007-07-24 Richard Hughes <richard@hughsie.com>Richard Hughes1-0/+54
* bus/activation.c: (handle_activation_exit_error), (babysitter_watch_callback): Map the child exit status integer to a proper dbus error.
2007-07-242007-07-24 Richard Hughes <richard@hughsie.com>Richard Hughes1-1/+34
* bus/activation.c: (bus_activation_entry_unref), (update_desktop_file_entry): Add the concept of, and read the value of user from the desktop file. The user string is not required unless we are using system activation.
2007-07-242007-07-24 Richard Hughes <richard@hughsie.com>Richard Hughes1-4/+1
* bus/activation.c: * bus/desktop-file.h: Move the defines into the header file, as we use these in the lauch helper as well as the desktop file parsing.
2007-07-142007-07-13 Havoc Pennington <hp@redhat.com>Havoc Pennington1-1/+1
* Add indent-tabs-mode: nil to all file headers.
2007-06-152007-06-15 Havoc Pennington <hp@redhat.com>Havoc Pennington1-0/+2
* 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-03-07* bus/activation.c: win32 compile fix.Ralf Habacker1-1/+0
* test/test-segfault.c: win32 compile fix, rlimit isn't available on win32. * dbus-win.patch: removed some more patches, they are applied or obsolate
2007-03-04* bus/activation.c: (bus_activation_activate_service):Ralf Habacker1-0/+2
fixed call to _dbus_spawn_async_with_babysitter().
2006-11-03* bus/activation.c (bus_activation_new): don't fail if we can not readJohn (J5) Palmieri1-2/+8
the directory as it may not exist
2006-09-11* remove a bunch of todo items from the 1.0 listJohn (J5) Palmieri1-1/+1
2006-09-11* bus/activation.c, bus/desktop-file.c: Distinguish between OOM andJohn (J5) Palmieri1-13/+13
key not found
2006-09-06* doc/TODO, various source files: Audited todo's and FIXME's andJohn (J5) Palmieri1-1/+1
prepended the ones we should be looking at with 1.0. Those prepended with 1.0? need clerification or might not be needed for 1.0
2006-08-10* dbus/dbus-sysdeps.c:John (J5) Palmieri1-2/+6
* dbus/dbus-address.c: * bus/activation.c: * test/shell-test.c: don't hardcode tmp directory (patch from Dave Meikle <dmk at davemeikle dot co dot uk>)
2006-08-08These are all patches from Kjartan Maraas <kmaraas at gnome dot org>John (J5) Palmieri1-2/+0
with cleanups of bugs found from Coverity reports: * dbus/dbus-sysdeps-util.c (_dbus_write_pid_file): close the file on error to avoid a leak * bus/expirelist.c (bus_expire_list_test): Check for NULL on dbus_new0 * bus/activation.c (update_directory): remove dead code * bus/config-parser.c (merge_service_context_hash, start_selinux_child): Fix some leaks * bus/bus.c (process_config_every_time): Fixed a leak * bus/desktop-file.c (parse_key_value): Fixed leak * bus/selinux.c (bus_selinux_id_table_insert): Fixed leak
2006-07-14* bus/activation.[ch] (bus_activation_list_services): new function toJohn (J5) Palmieri1-0/+45
get the list of services that can be activated * bus/dispatch.c: test coverage for the new bus method ListActivatableNames * bus/driver.c: new bus method ListActivatableNames to get the list of services that can be activated * doc/dbus-specification.xml: ListActivatableNames method documentation
2005-11-22 * configure.in: Add test/name-test/Makefile to the generatedJohn (J5) Palmieri1-1/+1
Makefile list * dbus/dbus-shared.h (#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT): New flag which replaces DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT (#define DBUS_NAME_FLAG_DO_NOT_QUEUE): New flag for specifying not to queue an ower if it can't be the primary owner * bus/bus.h: Add new internal BusOwner struct * bus/driver.c (bus_driver_handle_hello): Send flags (0 for default) to bus_registry_ensure and don't set the prohibit_replacement flag since they are now set per BusOwner and not per name. (bus_driver_handle_list_queued_owners): bus method (ListQueuedOwners) that returns the list of connections in a name's connection queue * bus/services.c (struct BusService): remove prohibit_replacement field (struct BusOwner): new struct for keeping track of queued connections and their associated flags for the queue (struct BusRegistry): add a BusOwner memory pool (bus_registry_new): initialize the BusOwner memory pool (bus_registry_unref): free the BusOwner memory pool (_bus_service_find_owner_link): new internal method for searching the queue for a specific connection (bus_owner_set_flags): new method for adding setting the flags on a bus owner (bus_owner_new): new method that creates a BusOwner object from the pool and sets its flags (bus_owner_ref, bus_owner_unref): ref counting for BusOwner objects (bus_registry_ensure): Add the flags parameter (bus_registry_acquire_service): Switch from using raw connections to using the BusOwner struct Add new state machine for dealing with the new set of flags (bus_registry_set_service_context_table, struct OwnershipCancelData, cancel_ownership, free_ownership_cancel_data, add_cancel_ownership_to_transaction, struct OwnershipRestoreData, restore_ownership, free_ownership_restore_data, add_restore_ownership_to_transaction): Switch to using BusOwner instead of raw connections (bus_service_add_owner): Add flags parameter Switch to using BusOwner instead of raw connections Add state machine for dealing with the new set of flags (bus_service_swap_owner): Swaps the first and second owners in the queue. Used to make sure proper signals are sent when a service looses or gains primary ownership. We never insert an owner at the top of the queue. Instead we insert it in the second position and then swap. (bus_service_remove_owner): Remove the owner from the queue sending out the NameLost and NameOwnerChanged signals if the we were the primary owner (bus_service_get_primary_owners_connection): New method that extracts the connection from the primary owner (bus_service_get_primary_owner): Returns the BusOwner instead of the connection (bus_service_get_allow_replacement): Changed from the old bus_service_get_prohibit_replacement method. Checks the flags of the primary owner and returns if it can be replaced or not (bus_service_set_prohibit_replacement): removed (bus_service_has_owner): returns TRUE if and owner with the specified connection exists in the queue * dbus/dbus-bus.c (dbus_bus_connection_get_unique_name): New helper method that only compiles if tests are enabled. Allows us to get the unique name of a connection so we can check it against the queue when doing regression tests * bus/activation.c (bus_activation_send_pending_auto_activate), bus/dispatch.c (bus_dispatch), bus/driver.c (bus_driver_handle_get_service_owner, bus_driver_handle_get_connection_unix_user, bus_driver_handle_get_connection_unix_process_id, bus_driver_handle_get_connection_selinux_security_context), bus/signals.c (connection_is_primary_owner): use bus_service_get_primary_owners_connection instead of bus_service_get_primary_owner * dbus/dbus-sysdeps.c (_dbus_connect_unix_socket, _dbus_listen_unix_socket): Calculate the length of the socket path and use that instead of using a fixed length which was causing socket names to contain many trailing Nul bytes. * dbus/dbus-glib-lowlevel.h, glib/dbus-gobject.c (dbus_g_method_get_sender): New method for extracting the sender from a DBusGMethodInvocation (dbus_g_method_return_get_reply): changed name to dbus_g_method_get_reply (dbus_g_method_return_send_reply): changed name to dbus_g_method_send reply * doc/dbus-specification.xml: New docs that describe how the new queueing system works and talks about the changes to the how we specify socket names * glib/examples/example-service.c, glib/examples/example-signal-emitter.c, glib/examples/statemachine/statemachine-server.c: Changed the RequestName flags to the new system * test/name-test/ (test-names.c, run-test.sh, Makefile.am): New regression test suite for testing various states of the new queueing system
2005-09-06* Released 0.50John (J5) Palmieri1-2/+4
* Patch from Steve Grubb: - bus/activation.c (bus_activation_service_reload_test): clean up some indentation - dbus/dbus-keyring.c (_dbus_keyring_reload): fix conditional - dbus/dbus-message-factory.c (generate_special): fix a couple of buffer overflows in the test suite. This is non critical because it can not be exploited and this code is only run when doing a make check. * Patch from Yaakov Selkowitz: Build fixes for Cygwin - configure.in: Don't check and link against kdecore, only qt headers - dbus/Makefile.am: Add -no-undefined to libdbus_1_la_LDFLAGS - gcj/org/freedesktop/dbus/Makefile.am: add libdbus_gcj_1_la_LDFLAGS = -no-undefined - glib/Makefile.am: Add -no-undefined to libdbus_glib_1_la_LDFLAGS and $(DBUS_GLIB_LIBS) to dbus_binding_tool_LDADD - qt/Makefile.am: Add -no-undefined to libdbus_qt_1_la_LDFLAGS - tools/Makefile.am: Add platform extentions to binaries (i.e. .exe on windows) * configure.in: - Make it so if no suitable version of python is found we only disable building python instead of exiting the configure script - Require version 2.4 of glib for glib bindings - Up version to 0.50 * python/__init__.py: Sync version with libdbus to (0,50,0)