]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
build-path: make pin_callout_binary() optionally provides the path to the found execu...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Apr 2025 14:41:42 +0000 (23:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Apr 2025 12:02:18 +0000 (21:02 +0900)
src/basic/build-path.c
src/basic/build-path.h
src/core/manager.c

index bc0dfc7f9b3bdaa9ba0f4b19af3fe26d0a13c5b3..ba49273cd396d3da3d38090356a0b0b353e7287e 100644 (file)
@@ -246,7 +246,7 @@ int invoke_callout_binary(const char *path, char *const argv[]) {
         return -errno;
 }
 
-static int open_executable(const char *path) {
+static int open_executable(const char *path, char **ret_path) {
         int r;
 
         assert(path);
@@ -263,15 +263,22 @@ static int open_executable(const char *path) {
         if (r < 0)
                 return r;
 
+        if (ret_path) {
+                r = fd_get_path(fd, ret_path);
+                if (r < 0)
+                        return r;
+        }
+
         return TAKE_FD(fd);
 }
 
-int pin_callout_binary(const char *path) {
+int pin_callout_binary(const char *path, char **ret_path) {
         int r;
 
         assert(path);
 
-        /* Similar to invoke_callout_binary(), but pins (i.e. O_PATH opens) the binary instead of executing it. */
+        /* Similar to invoke_callout_binary(), but pins (i.e. O_PATH opens) the binary instead of executing
+         * it, also optionally provides the path to the binary. */
 
         _cleanup_free_ char *fn = NULL;
         r = path_extract_filename(path, &fn);
@@ -282,14 +289,14 @@ int pin_callout_binary(const char *path) {
 
         const char *e;
         if (find_environment_binary(fn, &e) >= 0)
-                return open_executable(e);
+                return open_executable(e, ret_path);
 
         _cleanup_free_ char *np = NULL;
         if (find_build_dir_binary(fn, &np) >= 0) {
-                r = open_executable(np);
+                r = open_executable(np, ret_path);
                 if (r >= 0)
                         return r;
         }
 
-        return open_executable(path);
+        return open_executable(path, ret_path);
 }
index 6c38a4a3bb50b864d01abccc37d06b440fd8e55f..214f8ef5649b8337a39162d92342eaea73cc6f40 100644 (file)
@@ -5,4 +5,4 @@ int get_build_exec_dir(char **ret);
 
 int invoke_callout_binary(const char *path, char *const argv[]);
 
-int pin_callout_binary(const char *path);
+int pin_callout_binary(const char *path, char **ret_path);
index 06d6f51a13b21fe6e9242a5df61ede1e2d373fa3..02623be4bf68842bfa6c5e73da9d64541512513a 100644 (file)
@@ -1048,7 +1048,7 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags,
         }
 
         if (!FLAGS_SET(test_run_flags, MANAGER_TEST_DONT_OPEN_EXECUTOR)) {
-                m->executor_fd = pin_callout_binary(SYSTEMD_EXECUTOR_BINARY_PATH);
+                m->executor_fd = pin_callout_binary(SYSTEMD_EXECUTOR_BINARY_PATH, /* ret_path = */ NULL);
                 if (m->executor_fd < 0)
                         return log_debug_errno(m->executor_fd, "Failed to pin executor binary: %m");