yithar7153_2

dbus3.diff

Jul 25th, 2016
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 13.51 KB | None | 0 0
  1. diff --git a/bus/activation.c b/bus/activation.c
  2. index 614ce65..65ac55d 100644
  3. --- a/bus/activation.c
  4. +++ b/bus/activation.c
  5. @@ -46,6 +46,7 @@ struct BusActivation
  6.  {
  7.    int refcount;
  8.    DBusHashTable *entries;
  9. +  DBusHashTable *activatable_entries;
  10.    DBusHashTable *pending_activations;
  11.    char *server_address;
  12.    BusContext *context;
  13. @@ -255,7 +256,7 @@ update_desktop_file_entry (BusActivation       *activation,
  14.                             BusDesktopFile      *desktop_file,
  15.                             DBusError           *error)
  16.  {
  17. -  char *name, *exec, *user, *exec_tmp, *systemd_service;
  18. +  char *name, *exec, *user, *exec_tmp, *systemd_service, *activatable;
  19.    BusActivationEntry *entry;
  20.    DBusStat stat_buf;
  21.    DBusString file_path;
  22. @@ -272,6 +273,7 @@ update_desktop_file_entry (BusActivation       *activation,
  23.    exec_tmp = NULL;
  24.    entry = NULL;
  25.    systemd_service = NULL;
  26. +  activatable = NULL;
  27.  
  28.    dbus_error_init (&tmp_error);
  29.  
  30. @@ -372,8 +374,39 @@ update_desktop_file_entry (BusActivation       *activation,
  31.    entry = _dbus_hash_table_lookup_string (s_dir->entries,
  32.                                            _dbus_string_get_const_data (filename));
  33.  
  34. +
  35. +
  36. +  /*
  37. +   * First check hashtable for activation
  38. +   * If not, check file and if key exists, write to hashtable
  39. +   */
  40. +  if (!(activatable = _dbus_hash_table_lookup_string(activation->activatable_entries,
  41. +          name)))
  42. +      {
  43. +        bus_desktop_file_get_string (desktop_file,
  44. +                                      DBUS_SERVICE_SECTION,
  45. +                                      "Activatable",
  46. +                                      &activatable, &tmp_error);
  47. +        if (activatable != NULL) {
  48. +          if (!_dbus_hash_table_insert_string (activation->activatable_entries, name, activatable))
  49. +          {
  50. +            BUS_SET_OOM (error);
  51. +            goto out;
  52. +          }
  53. +        }
  54. +      }
  55. +
  56. +  /* If activation key is set to "no" skip rest of function and return TRUE */
  57. +  if (activatable != NULL) {
  58. +    if (strcasecmp(activatable, "no") == 0) {
  59. +      retval = TRUE;
  60. +      goto out;
  61. +    }
  62. +  }
  63. +
  64.    if (entry == NULL) /* New file */
  65.      {
  66. +
  67.        /* FIXME we need a better-defined algorithm for which service file to
  68.         * pick than "whichever one is first in the directory listing"
  69.         */
  70. @@ -481,6 +514,7 @@ out:
  71.    dbus_free (exec);
  72.    dbus_free (user);
  73.    dbus_free (systemd_service);
  74. +  dbus_free (activatable);
  75.    _dbus_string_free (&file_path);
  76.  
  77.    if (entry)
  78. @@ -780,6 +814,16 @@ bus_activation_reload (BusActivation     *activation,
  79.        BUS_SET_OOM (error);
  80.        goto failed;
  81.      }
  82. +  
  83. +  activation->activatable_entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
  84. +                                             (DBusFreeFunction)bus_activation_entry_unref);
  85. +
  86. +  if (activation->activatable_entries == NULL)
  87. +    {
  88. +      BUS_SET_OOM (error);
  89. +      goto failed;
  90. +    }
  91. +
  92.  
  93.    if (activation->directories != NULL)
  94.      _dbus_hash_table_unref (activation->directories);
  95. @@ -928,6 +972,8 @@ bus_activation_unref (BusActivation *activation)
  96.      return;
  97.  
  98.    dbus_free (activation->server_address);
  99. +  if (activation->activatable_entries)
  100. +    _dbus_hash_table_unref (activation->activatable_entries);
  101.    if (activation->entries)
  102.      _dbus_hash_table_unref (activation->entries);
  103.    if (activation->pending_activations)
  104. @@ -1657,6 +1703,10 @@ bus_activation_activate_service (BusActivation  *activation,
  105.  
  106.    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
  107.  
  108. +  if (bus_context_get_activatable(activation->context) == FALSE) {
  109. +    return TRUE;
  110. +  }
  111. +
  112.    if (activation->n_pending_activations >=
  113.        bus_context_get_max_pending_activations (activation->context))
  114.      {
  115. diff --git a/bus/bus.c b/bus/bus.c
  116. index 9f1daa2..0c234f9 100644
  117. --- a/bus/bus.c
  118. +++ b/bus/bus.c
  119. @@ -72,6 +72,7 @@ struct BusContext
  120.    unsigned int keep_umask : 1;
  121.    unsigned int allow_anonymous : 1;
  122.    unsigned int systemd_activation : 1;
  123. +  unsigned int activatable : 1;
  124.    dbus_bool_t watches_enabled;
  125.  };
  126.  
  127. @@ -276,7 +277,7 @@ process_config_first_time_only (BusContext       *context,
  128.    DBusString log_prefix;
  129.    DBusList *link;
  130.    DBusList **addresses;
  131. -  const char *user, *pidfile;
  132. +  const char *user, *pidfile, *activatable;
  133.    char **auth_mechanisms;
  134.    DBusList **auth_mechanisms_list;
  135.    int len;
  136. @@ -347,6 +348,8 @@ process_config_first_time_only (BusContext       *context,
  137.    if (bus_config_parser_get_type (parser) != NULL && context->type == NULL)
  138.      goto oom;
  139.  
  140. +  context->activatable = bus_config_parser_get_activatable (parser);
  141. +
  142.    user = bus_config_parser_get_user (parser);
  143.    if (user != NULL)
  144.      {
  145. @@ -1207,6 +1210,12 @@ bus_context_get_systemd_activation (BusContext *context)
  146.    return context->systemd_activation;
  147.  }
  148.  
  149. +dbus_bool_t
  150. +bus_context_get_activatable (BusContext *context)
  151. +{
  152. +  return context->activatable;
  153. +}
  154. +
  155.  BusRegistry*
  156.  bus_context_get_registry (BusContext  *context)
  157.  {
  158. diff --git a/bus/bus.h b/bus/bus.h
  159. index 3fab59f..028b17a 100644
  160. --- a/bus/bus.h
  161. +++ b/bus/bus.h
  162. @@ -92,6 +92,7 @@ const char*       bus_context_get_type                           (BusContext
  163.  const char*       bus_context_get_address                        (BusContext       *context);
  164.  const char*       bus_context_get_servicehelper                  (BusContext       *context);
  165.  dbus_bool_t       bus_context_get_systemd_activation             (BusContext       *context);
  166. +dbus_bool_t       bus_context_get_activatable             (BusContext       *context);
  167.  BusRegistry*      bus_context_get_registry                       (BusContext       *context);
  168.  BusConnections*   bus_context_get_connections                    (BusContext       *context);
  169.  BusActivation*    bus_context_get_activation                     (BusContext       *context);
  170. diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c
  171. index 5db6b28..79d4c7b 100644
  172. --- a/bus/config-parser-common.c
  173. +++ b/bus/config-parser-common.c
  174. @@ -39,6 +39,10 @@ bus_config_parser_element_name_to_type (const char *name)
  175.      {
  176.        return ELEMENT_BUSCONFIG;
  177.      }
  178. +  else if (strcmp (name, "activatable") == 0)
  179. +    {
  180. +      return ELEMENT_ACTIVATABLE;
  181. +    }
  182.    else if (strcmp (name, "user") == 0)
  183.      {
  184.        return ELEMENT_USER;
  185. @@ -171,6 +175,8 @@ bus_config_parser_element_type_to_name (ElementType type)
  186.        return "servicedir";
  187.      case ELEMENT_SERVICEHELPER:
  188.        return "servicehelper";
  189. +    case ELEMENT_ACTIVATABLE:
  190. +      return "activatable";
  191.      case ELEMENT_INCLUDEDIR:
  192.        return "includedir";
  193.      case ELEMENT_CONFIGTYPE:
  194. diff --git a/bus/config-parser-common.h b/bus/config-parser-common.h
  195. index 382a014..59023ee 100644
  196. --- a/bus/config-parser-common.h
  197. +++ b/bus/config-parser-common.h
  198. @@ -50,7 +50,8 @@ typedef enum
  199.    ELEMENT_KEEP_UMASK,
  200.    ELEMENT_SYSLOG,
  201.    ELEMENT_ALLOW_ANONYMOUS,
  202. -  ELEMENT_APPARMOR
  203. +  ELEMENT_APPARMOR,
  204. +  ELEMENT_ACTIVATABLE
  205.  } ElementType;
  206.  
  207.  ElementType bus_config_parser_element_name_to_type (const char *element_name);
  208. diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c
  209. index 03ad838..57526cc 100644
  210. --- a/bus/config-parser-trivial.c
  211. +++ b/bus/config-parser-trivial.c
  212. @@ -39,6 +39,7 @@ struct BusConfigParser
  213.    DBusString user;                  /**< User the dbus-daemon runs as */
  214.    DBusString bus_type;              /**< Message bus type */
  215.    DBusString service_helper;        /**< Location of the setuid helper */
  216. +  DBusString activatable;           /** Activatable **/
  217.    DBusList *service_dirs;           /**< Directories to look for services in */
  218.  };
  219.  
  220. @@ -163,6 +164,7 @@ bus_config_parser_start_element (BusConfigParser   *parser,
  221.    switch (parser->type)
  222.      {
  223.      case ELEMENT_SERVICEHELPER:
  224. +    case ELEMENT_ACTIVATABLE:
  225.      case ELEMENT_USER:
  226.      case ELEMENT_CONFIGTYPE:
  227.        /* content about to be handled */
  228. @@ -267,6 +269,16 @@ bus_config_parser_content (BusConfigParser   *parser,
  229.        }
  230.        break;
  231.  
  232. +    case ELEMENT_ACTIVATABLE:
  233. +      {
  234. +        if (!_dbus_string_copy (&content_sane, 0, &parser->activatable, 0))
  235. +          {
  236. +            BUS_SET_OOM (error);
  237. +            goto out_content;
  238. +          }
  239. +      }
  240. +      break;
  241. +
  242.      case ELEMENT_USER:
  243.        {
  244.          if (!_dbus_string_copy (&content_sane, 0, &parser->user, 0))
  245. diff --git a/bus/config-parser.c b/bus/config-parser.c
  246. index adba69e..a1bd2a8 100644
  247. --- a/bus/config-parser.c
  248. +++ b/bus/config-parser.c
  249. @@ -94,6 +94,8 @@ struct BusConfigParser
  250.  
  251.    char *servicehelper; /**< location of the setuid helper */
  252.  
  253. +  char *activatable;
  254. +
  255.    char *bus_type;          /**< Message bus type */
  256.    
  257.    DBusList *listen_on; /**< List of addresses to listen to */
  258. @@ -336,6 +338,13 @@ merge_included (BusConfigParser *parser,
  259.        included->servicehelper = NULL;
  260.      }
  261.  
  262. +  if (included->activatable != NULL)
  263. +    {
  264. +      dbus_free (parser->activatable);
  265. +      parser->activatable = included->activatable;
  266. +      included->activatable = NULL;
  267. +    }
  268. +
  269.    while ((link = _dbus_list_pop_first_link (&included->listen_on)))
  270.      _dbus_list_append_link (&parser->listen_on, link);
  271.  
  272. @@ -505,6 +514,7 @@ bus_config_parser_unref (BusConfigParser *parser)
  273.  
  274.        dbus_free (parser->user);
  275.        dbus_free (parser->servicehelper);
  276. +      dbus_free (parser->activatable);
  277.        dbus_free (parser->bus_type);
  278.        dbus_free (parser->pidfile);
  279.        
  280. @@ -817,6 +827,19 @@ start_busconfig_child (BusConfigParser   *parser,
  281.  
  282.        return TRUE;
  283.      }
  284. +  else if (element_type == ELEMENT_ACTIVATABLE)
  285. +    {
  286. +      if (!check_no_attributes (parser, "activatable", attribute_names, attribute_values, error))
  287. +        return FALSE;
  288. +
  289. +      if (push_element (parser, ELEMENT_ACTIVATABLE) == NULL)
  290. +        {
  291. +          BUS_SET_OOM (error);
  292. +          return FALSE;
  293. +        }
  294. +
  295. +      return TRUE;
  296. +    }
  297.    else if (element_type == ELEMENT_INCLUDEDIR)
  298.      {
  299.        if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
  300. @@ -2038,6 +2061,10 @@ bus_config_parser_end_element (BusConfigParser   *parser,
  301.  
  302.    n = bus_config_parser_element_type_to_name (t);
  303.    _dbus_assert (n != NULL);
  304. +  //fprintf(stderr, n);
  305. +  //fprintf(stderr, "...");
  306. +  //fprintf(stderr, element_name);
  307. +  //fprintf(stderr, "\n\n");
  308.    if (strcmp (n, element_name) != 0)
  309.      {
  310.        /* should probably be an assertion failure but
  311. @@ -2066,6 +2093,7 @@ bus_config_parser_end_element (BusConfigParser   *parser,
  312.      case ELEMENT_AUTH:
  313.      case ELEMENT_SERVICEDIR:
  314.      case ELEMENT_SERVICEHELPER:
  315. +    case ELEMENT_ACTIVATABLE:
  316.      case ELEMENT_INCLUDEDIR:
  317.      case ELEMENT_LIMIT:
  318.        if (!e->had_content)
  319. @@ -2544,6 +2572,20 @@ bus_config_parser_content (BusConfigParser   *parser,
  320.          parser->user = s;
  321.        }
  322.        break;
  323. +    
  324. +    case ELEMENT_ACTIVATABLE:
  325. +      {
  326. +        char *s;
  327. +
  328. +        e->had_content = TRUE;
  329. +        
  330. +        if (!_dbus_string_copy_data (content, &s))
  331. +          goto nomem;
  332. +          
  333. +        dbus_free (parser->activatable);
  334. +        parser->activatable = s;
  335. +      }
  336. +      break;
  337.  
  338.      case ELEMENT_CONFIGTYPE:
  339.        {
  340. @@ -2758,6 +2800,16 @@ bus_config_parser_get_servicehelper (BusConfigParser   *parser)
  341.    return parser->servicehelper;
  342.  }
  343.  
  344. +dbus_bool_t
  345. +bus_config_parser_get_activatable (BusConfigParser   *parser)
  346. +{
  347. +  if (parser->activatable == NULL) return TRUE;
  348. +  if (strcasecmp(parser->activatable, "no") == 0)
  349. +    return FALSE;
  350. +  else
  351. +    return TRUE;
  352. +}
  353. +
  354.  BusPolicy*
  355.  bus_config_parser_steal_policy (BusConfigParser *parser)
  356.  {
  357. diff --git a/bus/config-parser.h b/bus/config-parser.h
  358. index ba5bf74..a9104ee 100644
  359. --- a/bus/config-parser.h
  360. +++ b/bus/config-parser.h
  361. @@ -68,6 +68,7 @@ dbus_bool_t bus_config_parser_get_syslog       (BusConfigParser *parser);
  362.  dbus_bool_t bus_config_parser_get_keep_umask   (BusConfigParser *parser);
  363.  const char* bus_config_parser_get_pidfile      (BusConfigParser *parser);
  364.  const char* bus_config_parser_get_servicehelper (BusConfigParser *parser);
  365. +dbus_bool_t bus_config_parser_get_activatable (BusConfigParser *parser);
  366.  DBusList**  bus_config_parser_get_service_dirs (BusConfigParser *parser);
  367.  DBusList**  bus_config_parser_get_conf_dirs    (BusConfigParser *parser);
  368.  BusPolicy*  bus_config_parser_steal_policy     (BusConfigParser *parser);
  369. diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
  370. index 32599f7..8618aaf 100644
  371. --- a/dbus/dbus-sysdeps-util-unix.c
  372. +++ b/dbus/dbus-sysdeps-util-unix.c
  373. @@ -1337,7 +1337,16 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
  374.  
  375.    if (!_dbus_string_append (&servicedir_path, ":"))
  376.      goto oom;
  377. +/*
  378. +    DBusString etc_dir;
  379.  
  380. +    _dbus_string_init_const (&etc_dir, "/etc");
  381. +    if (!_dbus_concat_dir_and_file (&servicedir_path, &etc_dir))
  382. +      goto oom;
  383. +
  384. +  if (!_dbus_string_append (&servicedir_path, ":"))
  385. +    goto oom;
  386. +*/
  387.    if (xdg_data_dirs != NULL)
  388.      {
  389.        if (!_dbus_string_append (&servicedir_path, xdg_data_dirs))
  390. @@ -1348,7 +1357,7 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
  391.      }
  392.    else
  393.      {
  394. -      if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:"))
  395. +      if (!_dbus_string_append (&servicedir_path, "/etc:/usr/local/share:/usr/share:"))
  396.          goto oom;
  397.      }
  398.  
  399. @@ -1406,6 +1415,7 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs)
  400.     * be available.
  401.     */
  402.    static const char standard_search_path[] =
  403. +    "/etc:"
  404.      "/usr/local/share:"
  405.      "/usr/share:"
  406.      DBUS_DATADIR ":"
Advertisement
Add Comment
Please, Sign In to add comment