Lines Matching defs:activation
2 /* activation.c Activation of services
27 #include "activation.h"
28 #include "activation-exit-codes.h"
53 * i.e. number of pending activation requests, not pending
92 BusActivation *activation;
171 _dbus_loop_remove_timeout (bus_context_get_loop (pending_activation->activation->context),
206 pending_activation->activation->n_pending_activations -=
209 _dbus_assert (pending_activation->activation->n_pending_activations >= 0);
245 update_desktop_file_entry (BusActivation *activation,
308 /* user is not _required_ unless we are using system activation */
363 if (_dbus_hash_table_lookup_string (activation->entries, name))
366 "Service %s already exists in activation entry list\n", name);
397 if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref (entry)))
406 _dbus_hash_table_remove_string (activation->entries, entry->name);
416 _dbus_hash_table_remove_string (activation->entries, entry->name);
418 if (_dbus_hash_table_lookup_string (activation->entries, name))
445 if (!_dbus_hash_table_insert_string (activation->entries,
475 check_service_file (BusActivation *activation,
510 _dbus_hash_table_remove_string (activation->entries, entry->name);
546 if (!update_desktop_file_entry (activation, entry->s_dir, &filename, desktop_file, &tmp_error))
578 update_directory (BusActivation *activation,
641 if (!check_service_file (activation, entry, NULL, error))
675 if (!update_desktop_file_entry (activation, s_dir, &filename, desktop_file, &tmp_error))
680 _dbus_verbose ("Could not add %s to activation entry list: %s\n",
723 populate_environment (BusActivation *activation)
764 if (!_dbus_hash_table_insert_string (activation->environment,
786 bus_activation_reload (BusActivation *activation,
794 if (activation->server_address != NULL)
795 dbus_free (activation->server_address);
796 if (!_dbus_string_copy_data (address, &activation->server_address))
802 if (activation->entries != NULL)
803 _dbus_hash_table_unref (activation->entries);
804 activation->entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
806 if (activation->entries == NULL)
812 if (activation->directories != NULL)
813 _dbus_hash_table_unref (activation->directories);
814 activation->directories = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
817 if (activation->directories == NULL)
856 if (!_dbus_hash_table_insert_string (activation->directories, s_dir->dir_c, s_dir))
864 if (!update_directory (activation, s_dir, error))
886 BusActivation *activation;
890 activation = dbus_new0 (BusActivation, 1);
891 if (activation == NULL)
897 activation->refcount = 1;
898 activation->context = context;
899 activation->n_pending_activations = 0;
901 if (!bus_activation_reload (activation, address, directories, error))
906 activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
909 if (activation->pending_activations == NULL)
915 activation->environment = _dbus_hash_table_new (DBUS_HASH_STRING,
919 if (activation->environment == NULL)
925 if (!populate_environment (activation))
931 return activation;
934 bus_activation_unref (activation);
939 bus_activation_ref (BusActivation *activation)
941 _dbus_assert (activation->refcount > 0);
943 activation->refcount += 1;
945 return activation;
949 bus_activation_unref (BusActivation *activation)
951 _dbus_assert (activation->refcount > 0);
953 activation->refcount -= 1;
955 if (activation->refcount > 0)
958 dbus_free (activation->server_address);
959 if (activation->entries)
960 _dbus_hash_table_unref (activation->entries);
961 if (activation->pending_activations)
962 _dbus_hash_table_unref (activation->pending_activations);
963 if (activation->directories)
964 _dbus_hash_table_unref (activation->directories);
965 if (activation->environment)
966 _dbus_hash_table_unref (activation->environment);
968 dbus_free (activation);
972 add_bus_environment (BusActivation *activation,
977 if (!bus_activation_set_environment_variable (activation,
979 activation->server_address,
983 type = bus_context_get_type (activation->context);
986 if (!bus_activation_set_environment_variable (activation,
993 if (!bus_activation_set_environment_variable (activation,
995 activation->server_address,
1001 if (!bus_activation_set_environment_variable (activation,
1003 activation->server_address,
1026 _dbus_verbose ("Restoring pending activation for service %s, has timeout = %d\n",
1030 _dbus_hash_table_insert_string_preallocated (d->pending_activation->activation->pending_activations,
1045 _dbus_hash_table_free_preallocated_entry (d->pending_activation->activation->pending_activations,
1064 d->hash_entry = _dbus_hash_table_preallocate_entry (d->pending_activation->activation->pending_activations);
1076 _dbus_verbose ("Saved pending activation to be restored if the transaction fails\n");
1082 bus_activation_service_created (BusActivation *activation,
1093 /* Check if it's a pending activation */
1094 pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name);
1099 bus_context_log (activation->context,
1111 /* Only send activation replies to regular activation requests. */
1155 bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
1165 /* Check if it's a pending activation */
1166 pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
1197 _dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
1202 _dbus_hash_table_remove_string (activation->pending_activations, bus_service_get_name (service));
1220 BusActivation *activation;
1224 activation = pending_activation->activation;
1226 transaction = bus_transaction_new (activation->context);
1259 * Free the pending activation and send an error message to all the
1270 /* Destroy this pending activation */
1271 _dbus_hash_table_remove_string (pending_activation->activation->pending_activations,
1345 uses_servicehelper = bus_context_get_servicehelper (pending_activation->activation->context) != NULL;
1383 bus_context_log (pending_activation->activation->context,
1389 _dbus_hash_iter_init (pending_activation->activation->pending_activations,
1399 /* Destroys the pending activation */
1416 bus_context_get_loop (pending_activation->activation->context),
1426 _dbus_loop_remove_watch (bus_context_get_loop (pending_activation->activation->context),
1436 _dbus_loop_toggle_watch (bus_context_get_loop (pending_activation->activation->context),
1456 "Activation of %s timed out",
1458 bus_context_log (pending_activation->activation->context,
1475 _dbus_verbose ("Canceling pending activation of %s\n",
1481 _dbus_hash_table_remove_string (pending_activation->activation->pending_activations,
1504 _dbus_verbose ("Saved pending activation to be canceled if the transaction fails\n");
1510 update_service_cache (BusActivation *activation, DBusError *error)
1514 _dbus_hash_iter_init (activation->directories, &iter);
1523 if (!update_directory (activation, s_dir, &tmp_error))
1540 activation_find_entry (BusActivation *activation,
1546 entry = _dbus_hash_table_lookup_string (activation->entries, service_name);
1549 if (!update_service_cache (activation, error))
1552 entry = _dbus_hash_table_lookup_string (activation->entries,
1559 if (!check_service_file (activation, entry, &updated_entry, error))
1577 bus_activation_get_environment (BusActivation *activation)
1584 length = _dbus_hash_table_get_n_entries (activation->environment);
1592 _dbus_hash_iter_init (activation->environment, &iter);
1627 bus_activation_set_environment_variable (BusActivation *activation,
1649 if (!_dbus_hash_table_insert_string (activation->environment,
1666 bus_activation_activate_service (BusActivation *activation,
1690 if (activation->n_pending_activations >=
1691 bus_context_get_max_pending_activations (activation->context))
1694 "The maximum number of pending activations has been reached, activation of %s failed",
1699 entry = activation_find_entry (activation, service_name, error);
1710 if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL)
1752 _dbus_verbose ("Failed to create pending activation entry\n");
1765 pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name);
1771 _dbus_verbose ("Failed to append a new entry to pending activation\n");
1779 pending_activation->activation->n_pending_activations += 1;
1786 _dbus_verbose ("Failed to create pending activation\n");
1793 pending_activation->activation = activation;
1799 _dbus_verbose ("Failed to copy service name for pending activation\n");
1810 _dbus_verbose ("Failed to copy service exec for pending activation\n");
1822 _dbus_verbose ("Failed to copy systemd service for pending activation\n");
1831 _dbus_timeout_new (bus_context_get_activation_timeout (activation->context),
1837 _dbus_verbose ("Failed to create timeout for pending activation\n");
1845 if (!_dbus_loop_add_timeout (bus_context_get_loop (activation->context),
1848 _dbus_verbose ("Failed to add timeout for pending activation\n");
1860 _dbus_verbose ("Failed to add entry to just-created pending activation\n");
1869 pending_activation->activation->n_pending_activations += 1;
1871 if (!_dbus_hash_table_insert_string (activation->pending_activations,
1875 _dbus_verbose ("Failed to put pending activation in hash table\n");
1885 _dbus_verbose ("Failed to add pending activation cancel hook to transaction\n");
1887 _dbus_hash_table_remove_string (activation->pending_activations,
1896 if (bus_context_get_systemd_activation (activation->context))
1912 hence let's enqueue an activation request message. This
1926 _dbus_verbose ("No memory to create activation message\n");
1937 _dbus_verbose ("No memory to set args of activation message\n");
1944 activation_transaction = bus_transaction_new (activation->context);
1947 _dbus_verbose ("No memory to create activation transaction\n");
1960 bus_context_log (activation->context,
1970 bus_context_log (activation->context,
1975 retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE,
1983 bus_context_log (activation->context,
1988 _dbus_verbose ("failed to send activation message: %s\n", error->name);
1998 proceed with traditional activation. */
2009 servicehelper = bus_context_get_servicehelper (activation->context);
2016 "Cannot do system-bus activation with no user\n");
2057 _dbus_hash_table_remove_string (activation->pending_activations,
2065 if (!add_bus_environment (activation, error))
2072 envp = bus_activation_get_environment (activation);
2083 bus_context_log (activation->context,
2087 bus_context_log (activation->context,
2095 NULL, activation,
2099 bus_context_log (activation->context,
2136 bus_activation_list_services (BusActivation *activation,
2144 len = _dbus_hash_table_get_n_entries (activation->entries);
2150 _dbus_hash_iter_init (activation->entries, &iter);
2180 dbus_activation_systemd_failure (BusActivation *activation,
2204 bus_context_log (activation->context,
2205 DBUS_SYSTEM_LOG_INFO, "Activation via systemd failed for unit '%s': %s",
2209 _dbus_hash_iter_init (activation->pending_activations,
2392 BusActivation *activation;
2410 entry = activation_find_entry (d->activation, d->service_name, &error);
2453 BusActivation *activation;
2464 activation = bus_activation_new (NULL, &address, &directories, NULL);
2465 if (!activation)
2468 d.activation = activation;
2523 bus_activation_unref (activation);