]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-path: allow the default search path to be queried
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 26 Mar 2018 07:51:12 +0000 (09:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 16 Apr 2018 14:09:46 +0000 (16:09 +0200)
man/systemd-path.xml
man/systemd.service.xml
src/libsystemd/sd-path/sd-path.c
src/path/path.c
src/systemd/sd-path.h

index 7144569d59d70219f303b9709dcf811e0fcbd27d..025247c8839d2c85d59e5cf161b0f78d74ebff0d 100644 (file)
@@ -52,7 +52,9 @@
 
   <refsynopsisdiv>
     <cmdsynopsis>
-      <command>systemd-path <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">NAME</arg></command>
+      <command>systemd-path</command>
+      <arg choice="opt" rep="repeat">OPTIONS</arg>
+      <arg choice="opt" rep="repeat">NAME</arg>
     </cmdsynopsis>
   </refsynopsisdiv>
 
@@ -81,8 +83,7 @@
       <varlistentry>
         <term><option>--suffix=</option></term>
 
-        <listitem><para>The printed paths are suffixed by the
-        specified string.</para></listitem>
+        <listitem><para>Printed paths are suffixed by the specified string.</para></listitem>
       </varlistentry>
 
       <xi:include href="standard-options.xml" xpointer="help" />
index e89cfe3f0eaccab0cf871df327ff5245c71f33fa..55a9c6fbdcabd581e02aff99200a37a95de371fc 100644 (file)
     <filename>bin/</filename> and <filename>sbin/</filename>. It is thus safe to use just the
     executable name in case of executables located in any of the "standard" directories, and an
     absolute path must be used in other cases. Using an absolute path is recommended to avoid
-    ambiguity.</para>
+    ambiguity. Hint: this search path may be queried using
+    <command>systemd-path search-binaries-default</command>.</para>
 
     <para>Example:</para>
 
index 419c763668ed7fa202e0e128b5cf5ff479412890..b2e8e63c1b3e594965f5ff0dee5757da504d6f7e 100644 (file)
@@ -348,6 +348,7 @@ _public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
 
         if (IN_SET(type,
                    SD_PATH_SEARCH_BINARIES,
+                   SD_PATH_SEARCH_BINARIES_DEFAULT,
                    SD_PATH_SEARCH_LIBRARY_PRIVATE,
                    SD_PATH_SEARCH_LIBRARY_ARCH,
                    SD_PATH_SEARCH_SHARED,
@@ -566,7 +567,17 @@ static int get_search(uint64_t type, char ***list) {
                                                false,
                                                "/etc",
                                                NULL);
-        }
+
+        case SD_PATH_SEARCH_BINARIES_DEFAULT: {
+                char **t;
+
+                t = strv_split_nulstr(DEFAULT_PATH_NULSTR);
+                if (!t)
+                        return -ENOMEM;
+
+                *list = t;
+                return 0;
+        }}
 
         return -EOPNOTSUPP;
 }
@@ -579,6 +590,7 @@ _public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
 
         if (!IN_SET(type,
                     SD_PATH_SEARCH_BINARIES,
+                    SD_PATH_SEARCH_BINARIES_DEFAULT,
                     SD_PATH_SEARCH_LIBRARY_PRIVATE,
                     SD_PATH_SEARCH_LIBRARY_ARCH,
                     SD_PATH_SEARCH_SHARED,
index 0f029c4ae63dcb4598dd42fa585a187f3bac7b3a..be17a444d3b208c8412e0bab86bac016027dc425 100644 (file)
@@ -67,6 +67,7 @@ static const char* const path_table[_SD_PATH_MAX] = {
         [SD_PATH_USER_TEMPLATES] = "user-templates",
         [SD_PATH_USER_DESKTOP] = "user-desktop",
         [SD_PATH_SEARCH_BINARIES] = "search-binaries",
+        [SD_PATH_SEARCH_BINARIES_DEFAULT] = "search-binaries-default",
         [SD_PATH_SEARCH_LIBRARY_PRIVATE] = "search-library-private",
         [SD_PATH_SEARCH_LIBRARY_ARCH] = "search-library-arch",
         [SD_PATH_SEARCH_SHARED] = "search-shared",
index 2dfc8967b4bf8218426ce462001a58ee0a9f6b24..19f48b73ebb41e97aaf2d134925ca9e51d922fc6 100644 (file)
@@ -74,6 +74,7 @@ enum {
 
         /* Search paths */
         SD_PATH_SEARCH_BINARIES,
+        SD_PATH_SEARCH_BINARIES_DEFAULT,
         SD_PATH_SEARCH_LIBRARY_PRIVATE,
         SD_PATH_SEARCH_LIBRARY_ARCH,
         SD_PATH_SEARCH_SHARED,