Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bus/activation.c b/bus/activation.c
- index 614ce65..65ac55d 100644
- --- a/bus/activation.c
- +++ b/bus/activation.c
- @@ -46,6 +46,7 @@ struct BusActivation
- {
- int refcount;
- DBusHashTable *entries;
- + DBusHashTable *activatable_entries;
- DBusHashTable *pending_activations;
- char *server_address;
- BusContext *context;
- @@ -255,7 +256,7 @@ update_desktop_file_entry (BusActivation *activation,
- BusDesktopFile *desktop_file,
- DBusError *error)
- {
- - char *name, *exec, *user, *exec_tmp, *systemd_service;
- + char *name, *exec, *user, *exec_tmp, *systemd_service, *activatable;
- BusActivationEntry *entry;
- DBusStat stat_buf;
- DBusString file_path;
- @@ -272,6 +273,7 @@ update_desktop_file_entry (BusActivation *activation,
- exec_tmp = NULL;
- entry = NULL;
- systemd_service = NULL;
- + activatable = NULL;
- dbus_error_init (&tmp_error);
- @@ -372,8 +374,39 @@ update_desktop_file_entry (BusActivation *activation,
- entry = _dbus_hash_table_lookup_string (s_dir->entries,
- _dbus_string_get_const_data (filename));
- +
- +
- + /*
- + * First check hashtable for activation
- + * If not, check file and if key exists, write to hashtable
- + */
- + if (!(activatable = _dbus_hash_table_lookup_string(activation->activatable_entries,
- + name)))
- + {
- + bus_desktop_file_get_string (desktop_file,
- + DBUS_SERVICE_SECTION,
- + "Activatable",
- + &activatable, &tmp_error);
- + if (activatable != NULL) {
- + if (!_dbus_hash_table_insert_string (activation->activatable_entries, name, activatable))
- + {
- + BUS_SET_OOM (error);
- + goto out;
- + }
- + }
- + }
- +
- + /* If activation key is set to "no" skip rest of function and return TRUE */
- + if (activatable != NULL) {
- + if (strcasecmp(activatable, "no") == 0) {
- + retval = TRUE;
- + goto out;
- + }
- + }
- +
- if (entry == NULL) /* New file */
- {
- +
- /* FIXME we need a better-defined algorithm for which service file to
- * pick than "whichever one is first in the directory listing"
- */
- @@ -481,6 +514,7 @@ out:
- dbus_free (exec);
- dbus_free (user);
- dbus_free (systemd_service);
- + dbus_free (activatable);
- _dbus_string_free (&file_path);
- if (entry)
- @@ -780,6 +814,16 @@ bus_activation_reload (BusActivation *activation,
- BUS_SET_OOM (error);
- goto failed;
- }
- +
- + activation->activatable_entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
- + (DBusFreeFunction)bus_activation_entry_unref);
- +
- + if (activation->activatable_entries == NULL)
- + {
- + BUS_SET_OOM (error);
- + goto failed;
- + }
- +
- if (activation->directories != NULL)
- _dbus_hash_table_unref (activation->directories);
- @@ -928,6 +972,8 @@ bus_activation_unref (BusActivation *activation)
- return;
- dbus_free (activation->server_address);
- + if (activation->activatable_entries)
- + _dbus_hash_table_unref (activation->activatable_entries);
- if (activation->entries)
- _dbus_hash_table_unref (activation->entries);
- if (activation->pending_activations)
- @@ -1657,6 +1703,10 @@ bus_activation_activate_service (BusActivation *activation,
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
- + if (bus_context_get_activatable(activation->context) == FALSE) {
- + return TRUE;
- + }
- +
- if (activation->n_pending_activations >=
- bus_context_get_max_pending_activations (activation->context))
- {
- diff --git a/bus/bus.c b/bus/bus.c
- index 9f1daa2..0c234f9 100644
- --- a/bus/bus.c
- +++ b/bus/bus.c
- @@ -72,6 +72,7 @@ struct BusContext
- unsigned int keep_umask : 1;
- unsigned int allow_anonymous : 1;
- unsigned int systemd_activation : 1;
- + unsigned int activatable : 1;
- dbus_bool_t watches_enabled;
- };
- @@ -276,7 +277,7 @@ process_config_first_time_only (BusContext *context,
- DBusString log_prefix;
- DBusList *link;
- DBusList **addresses;
- - const char *user, *pidfile;
- + const char *user, *pidfile, *activatable;
- char **auth_mechanisms;
- DBusList **auth_mechanisms_list;
- int len;
- @@ -347,6 +348,8 @@ process_config_first_time_only (BusContext *context,
- if (bus_config_parser_get_type (parser) != NULL && context->type == NULL)
- goto oom;
- + context->activatable = bus_config_parser_get_activatable (parser);
- +
- user = bus_config_parser_get_user (parser);
- if (user != NULL)
- {
- @@ -1207,6 +1210,12 @@ bus_context_get_systemd_activation (BusContext *context)
- return context->systemd_activation;
- }
- +dbus_bool_t
- +bus_context_get_activatable (BusContext *context)
- +{
- + return context->activatable;
- +}
- +
- BusRegistry*
- bus_context_get_registry (BusContext *context)
- {
- diff --git a/bus/bus.h b/bus/bus.h
- index 3fab59f..028b17a 100644
- --- a/bus/bus.h
- +++ b/bus/bus.h
- @@ -92,6 +92,7 @@ const char* bus_context_get_type (BusContext
- const char* bus_context_get_address (BusContext *context);
- const char* bus_context_get_servicehelper (BusContext *context);
- dbus_bool_t bus_context_get_systemd_activation (BusContext *context);
- +dbus_bool_t bus_context_get_activatable (BusContext *context);
- BusRegistry* bus_context_get_registry (BusContext *context);
- BusConnections* bus_context_get_connections (BusContext *context);
- BusActivation* bus_context_get_activation (BusContext *context);
- diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c
- index 5db6b28..79d4c7b 100644
- --- a/bus/config-parser-common.c
- +++ b/bus/config-parser-common.c
- @@ -39,6 +39,10 @@ bus_config_parser_element_name_to_type (const char *name)
- {
- return ELEMENT_BUSCONFIG;
- }
- + else if (strcmp (name, "activatable") == 0)
- + {
- + return ELEMENT_ACTIVATABLE;
- + }
- else if (strcmp (name, "user") == 0)
- {
- return ELEMENT_USER;
- @@ -171,6 +175,8 @@ bus_config_parser_element_type_to_name (ElementType type)
- return "servicedir";
- case ELEMENT_SERVICEHELPER:
- return "servicehelper";
- + case ELEMENT_ACTIVATABLE:
- + return "activatable";
- case ELEMENT_INCLUDEDIR:
- return "includedir";
- case ELEMENT_CONFIGTYPE:
- diff --git a/bus/config-parser-common.h b/bus/config-parser-common.h
- index 382a014..59023ee 100644
- --- a/bus/config-parser-common.h
- +++ b/bus/config-parser-common.h
- @@ -50,7 +50,8 @@ typedef enum
- ELEMENT_KEEP_UMASK,
- ELEMENT_SYSLOG,
- ELEMENT_ALLOW_ANONYMOUS,
- - ELEMENT_APPARMOR
- + ELEMENT_APPARMOR,
- + ELEMENT_ACTIVATABLE
- } ElementType;
- ElementType bus_config_parser_element_name_to_type (const char *element_name);
- diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c
- index 03ad838..57526cc 100644
- --- a/bus/config-parser-trivial.c
- +++ b/bus/config-parser-trivial.c
- @@ -39,6 +39,7 @@ struct BusConfigParser
- DBusString user; /**< User the dbus-daemon runs as */
- DBusString bus_type; /**< Message bus type */
- DBusString service_helper; /**< Location of the setuid helper */
- + DBusString activatable; /** Activatable **/
- DBusList *service_dirs; /**< Directories to look for services in */
- };
- @@ -163,6 +164,7 @@ bus_config_parser_start_element (BusConfigParser *parser,
- switch (parser->type)
- {
- case ELEMENT_SERVICEHELPER:
- + case ELEMENT_ACTIVATABLE:
- case ELEMENT_USER:
- case ELEMENT_CONFIGTYPE:
- /* content about to be handled */
- @@ -267,6 +269,16 @@ bus_config_parser_content (BusConfigParser *parser,
- }
- break;
- + case ELEMENT_ACTIVATABLE:
- + {
- + if (!_dbus_string_copy (&content_sane, 0, &parser->activatable, 0))
- + {
- + BUS_SET_OOM (error);
- + goto out_content;
- + }
- + }
- + break;
- +
- case ELEMENT_USER:
- {
- if (!_dbus_string_copy (&content_sane, 0, &parser->user, 0))
- diff --git a/bus/config-parser.c b/bus/config-parser.c
- index adba69e..a1bd2a8 100644
- --- a/bus/config-parser.c
- +++ b/bus/config-parser.c
- @@ -94,6 +94,8 @@ struct BusConfigParser
- char *servicehelper; /**< location of the setuid helper */
- + char *activatable;
- +
- char *bus_type; /**< Message bus type */
- DBusList *listen_on; /**< List of addresses to listen to */
- @@ -336,6 +338,13 @@ merge_included (BusConfigParser *parser,
- included->servicehelper = NULL;
- }
- + if (included->activatable != NULL)
- + {
- + dbus_free (parser->activatable);
- + parser->activatable = included->activatable;
- + included->activatable = NULL;
- + }
- +
- while ((link = _dbus_list_pop_first_link (&included->listen_on)))
- _dbus_list_append_link (&parser->listen_on, link);
- @@ -505,6 +514,7 @@ bus_config_parser_unref (BusConfigParser *parser)
- dbus_free (parser->user);
- dbus_free (parser->servicehelper);
- + dbus_free (parser->activatable);
- dbus_free (parser->bus_type);
- dbus_free (parser->pidfile);
- @@ -817,6 +827,19 @@ start_busconfig_child (BusConfigParser *parser,
- return TRUE;
- }
- + else if (element_type == ELEMENT_ACTIVATABLE)
- + {
- + if (!check_no_attributes (parser, "activatable", attribute_names, attribute_values, error))
- + return FALSE;
- +
- + if (push_element (parser, ELEMENT_ACTIVATABLE) == NULL)
- + {
- + BUS_SET_OOM (error);
- + return FALSE;
- + }
- +
- + return TRUE;
- + }
- else if (element_type == ELEMENT_INCLUDEDIR)
- {
- if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
- @@ -2038,6 +2061,10 @@ bus_config_parser_end_element (BusConfigParser *parser,
- n = bus_config_parser_element_type_to_name (t);
- _dbus_assert (n != NULL);
- + //fprintf(stderr, n);
- + //fprintf(stderr, "...");
- + //fprintf(stderr, element_name);
- + //fprintf(stderr, "\n\n");
- if (strcmp (n, element_name) != 0)
- {
- /* should probably be an assertion failure but
- @@ -2066,6 +2093,7 @@ bus_config_parser_end_element (BusConfigParser *parser,
- case ELEMENT_AUTH:
- case ELEMENT_SERVICEDIR:
- case ELEMENT_SERVICEHELPER:
- + case ELEMENT_ACTIVATABLE:
- case ELEMENT_INCLUDEDIR:
- case ELEMENT_LIMIT:
- if (!e->had_content)
- @@ -2544,6 +2572,20 @@ bus_config_parser_content (BusConfigParser *parser,
- parser->user = s;
- }
- break;
- +
- + case ELEMENT_ACTIVATABLE:
- + {
- + char *s;
- +
- + e->had_content = TRUE;
- +
- + if (!_dbus_string_copy_data (content, &s))
- + goto nomem;
- +
- + dbus_free (parser->activatable);
- + parser->activatable = s;
- + }
- + break;
- case ELEMENT_CONFIGTYPE:
- {
- @@ -2758,6 +2800,16 @@ bus_config_parser_get_servicehelper (BusConfigParser *parser)
- return parser->servicehelper;
- }
- +dbus_bool_t
- +bus_config_parser_get_activatable (BusConfigParser *parser)
- +{
- + if (parser->activatable == NULL) return TRUE;
- + if (strcasecmp(parser->activatable, "no") == 0)
- + return FALSE;
- + else
- + return TRUE;
- +}
- +
- BusPolicy*
- bus_config_parser_steal_policy (BusConfigParser *parser)
- {
- diff --git a/bus/config-parser.h b/bus/config-parser.h
- index ba5bf74..a9104ee 100644
- --- a/bus/config-parser.h
- +++ b/bus/config-parser.h
- @@ -68,6 +68,7 @@ dbus_bool_t bus_config_parser_get_syslog (BusConfigParser *parser);
- dbus_bool_t bus_config_parser_get_keep_umask (BusConfigParser *parser);
- const char* bus_config_parser_get_pidfile (BusConfigParser *parser);
- const char* bus_config_parser_get_servicehelper (BusConfigParser *parser);
- +dbus_bool_t bus_config_parser_get_activatable (BusConfigParser *parser);
- DBusList** bus_config_parser_get_service_dirs (BusConfigParser *parser);
- DBusList** bus_config_parser_get_conf_dirs (BusConfigParser *parser);
- BusPolicy* bus_config_parser_steal_policy (BusConfigParser *parser);
- diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
- index 32599f7..8618aaf 100644
- --- a/dbus/dbus-sysdeps-util-unix.c
- +++ b/dbus/dbus-sysdeps-util-unix.c
- @@ -1337,7 +1337,16 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
- if (!_dbus_string_append (&servicedir_path, ":"))
- goto oom;
- +/*
- + DBusString etc_dir;
- + _dbus_string_init_const (&etc_dir, "/etc");
- + if (!_dbus_concat_dir_and_file (&servicedir_path, &etc_dir))
- + goto oom;
- +
- + if (!_dbus_string_append (&servicedir_path, ":"))
- + goto oom;
- +*/
- if (xdg_data_dirs != NULL)
- {
- if (!_dbus_string_append (&servicedir_path, xdg_data_dirs))
- @@ -1348,7 +1357,7 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
- }
- else
- {
- - if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:"))
- + if (!_dbus_string_append (&servicedir_path, "/etc:/usr/local/share:/usr/share:"))
- goto oom;
- }
- @@ -1406,6 +1415,7 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs)
- * be available.
- */
- static const char standard_search_path[] =
- + "/etc:"
- "/usr/local/share:"
- "/usr/share:"
- DBUS_DATADIR ":"
Advertisement
Add Comment
Please, Sign In to add comment