]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
bus: search for system-services in /etc/ and /run/ by default
authorLuca Boccassi <bluca@debian.org>
Fri, 13 Sep 2024 17:42:11 +0000 (19:42 +0200)
committerLuca Boccassi <bluca@debian.org>
Wed, 2 Oct 2024 23:58:29 +0000 (00:58 +0100)
Tthis is useful when an asset manager wants to install a system
service while /usr/ is read-only (e.g.: portable
services running on a different namespaced image). Unlike other
directories, enforce strict naming and do not set up an inotify,
as the directories might not even exist until much later. Also
search in /run/ for ephemeral services that will disappear after
a reboot.

Signed-off-by: Luca Boccassi <bluca@debian.org>
bus/config-parser.c
dbus/dbus-sysdeps-util-unix.c
dbus/dbus-sysdeps-util-win.c
dbus/dbus-sysdeps.h
doc/dbus-daemon.1.xml.in

index de9a1398d9e096beb349f05b0fde780cabe28817..2b630d181f870a9a5cb879441a297dab740c5bf3 100644 (file)
@@ -943,6 +943,24 @@ start_busconfig_child (BusConfigParser   *parser,
           return FALSE;
         }
 
+      /* /etc/ and /run/ are a recent addition, so we treat them differently
+       * than the other directories: strict naming is enforced, and we do not
+       * set up an inotify as it might very well not exist until much later at
+       * boot. */
+      if (!_dbus_get_local_system_servicedirs (&dirs))
+        {
+          BUS_SET_OOM (error);
+          return FALSE;
+        }
+
+      if (!service_dirs_absorb_string_list (&parser->service_dirs, &dirs,
+                                            BUS_SERVICE_DIR_FLAGS_NO_WATCH|BUS_SERVICE_DIR_FLAGS_STRICT_NAMING))
+        {
+          BUS_SET_OOM (error);
+          _dbus_list_clear_full (&dirs, dbus_free);
+          return FALSE;
+        }
+
       if (!_dbus_get_standard_system_servicedirs (&dirs))
         {
           BUS_SET_OOM (error);
index ce127388db4f003005200681b017d54b7ca890dc..c1158c377077625d21e20806bd762b2b1e1efd31 100644 (file)
@@ -1478,6 +1478,34 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs)
                                        dirs);
 }
 
+
+/**
+ * Returns the local admin directories for a system bus to look for service
+ * activation files
+ *
+ * On UNIX this should be the /etc/ and /run/ directories.
+ *
+ * On Windows there is no system bus and this function can return nothing.
+ *
+ * @param dirs the directory list we are returning
+ * @returns #FALSE on OOM
+ */
+
+dbus_bool_t
+_dbus_get_local_system_servicedirs (DBusList **dirs)
+{
+  static const char standard_search_path[] =
+    "/etc:"
+    "/run";
+  DBusString servicedir_path;
+
+  _dbus_string_init_const (&servicedir_path, standard_search_path);
+
+  return _dbus_split_paths_and_append (&servicedir_path,
+                                       DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR,
+                                       dirs);
+}
+
 /**
  * Get the absolute path of the system.conf file
  * (there is no system bus on Windows so this can just
index bb185f0527c2878b6a30da88dc25bd6f96c6dff3..6dd9456652a1740a6d8dafc727c0f70f01f8cf81 100644 (file)
@@ -1614,6 +1614,26 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs)
   return TRUE;
 }
 
+
+/**
+ * Returns the local admin directories for a system bus to look for service
+ * activation files
+ *
+ * On UNIX this should be the /etc/ and /run/ directories.
+ *
+ * On Windows there is no system bus and this function can return nothing.
+ *
+ * @param dirs the directory list we are returning
+ * @returns #FALSE on OOM
+ */
+
+dbus_bool_t
+_dbus_get_local_system_servicedirs (DBusList **dirs)
+{
+  *dirs = NULL;
+  return TRUE;
+}
+
 static dbus_bool_t
 _dbus_get_config_file_name (DBusString *str,
                             const char *basename)
index 27053a43e598ff7bcc196a07d50a5353fbb189ae..e022d4f5767f3bb152f17bf757ea70d4a3d01453 100644 (file)
@@ -493,6 +493,7 @@ dbus_bool_t _dbus_path_is_absolute    (const DBusString *filename);
 
 dbus_bool_t _dbus_get_standard_session_servicedirs (DBusList **dirs);
 dbus_bool_t _dbus_get_standard_system_servicedirs (DBusList **dirs);
+dbus_bool_t _dbus_get_local_system_servicedirs (DBusList **dirs);
 dbus_bool_t _dbus_set_up_transient_session_servicedirs (DBusList  **dirs,
                                                         DBusError  *error);
 
index ae9b5aa3b4bb3a464b0696f744ca7751d3a6cb92..5bf93b93d833d1fa04a8a4ff5d7bb27c3e88148e 100644 (file)
@@ -725,6 +725,22 @@ configuration file would probably be nonsense.</para>
 <para>
   On Unix, the standard system service directories are:
   <itemizedlist>
+    <listitem>
+      <para>
+        /etc/dbus-1/system-services: this location is specified
+        by the D-Bus Specification, and is suitable for software
+        installed locally by the system administrator,
+        or by an asset manager deploying services that are
+        not part of the OS (perhaps while /usr/ is read-only)
+      </para>
+    </listitem>
+    <listitem>
+      <para>
+        /run/dbus-1/system-services: this location is specified
+        by the D-Bus Specification, and is suitable for ephemeral
+        services that will disappear after a reboot
+      </para>
+    </listitem>
     <listitem>
       <para>
         /usr/local/share/dbus-1/system-services: this location is