]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Rename find_binary to find_executable
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Sep 2020 11:44:12 +0000 (13:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 18 Sep 2020 13:28:48 +0000 (15:28 +0200)
"executable" is more correct than "binary", since scripts are OK too.

src/basic/path-util.c
src/basic/path-util.h
src/journal/test-compress.c
src/run/run.c
src/shared/mkfs-util.c
src/test/test-execute.c
src/test/test-path-util.c
src/xdg-autostart-generator/xdg-autostart-service.c

index 9e44f2e8048ee853209fd179e536e36e3c977f92..d24b82268fdb83991a512a1f44f57b2a9079cc5c 100644 (file)
@@ -593,7 +593,7 @@ char* path_join_internal(const char *first, ...) {
         return joined;
 }
 
-int find_binary(const char *name, char **ret) {
+int find_executable(const char *name, char **ret) {
         int last_error, r;
         const char *p;
 
@@ -612,10 +612,7 @@ int find_binary(const char *name, char **ret) {
                 return 0;
         }
 
-        /**
-         * Plain getenv, not secure_getenv, because we want
-         * to actually allow the user to pick the binary.
-         */
+        /* Plain getenv, not secure_getenv, because we want to actually allow the user to pick the binary. */
         p = getenv("PATH");
         if (!p)
                 p = DEFAULT_PATH;
@@ -649,9 +646,7 @@ int find_binary(const char *name, char **ret) {
                         if (access(with_dash, X_OK) >= 0)
                                 continue;
 
-                        /**
-                         * We can't just `continue` inverting this case, since we need to update last_error.
-                         */
+                        /* We can't just `continue` inverting this case, since we need to update last_error. */
                         if (errno == ENOTDIR) {
                                 /* Found it! */
                                 if (ret)
@@ -704,18 +699,17 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
         return changed;
 }
 
-static int binary_is_good(const char *binary) {
+static int executable_is_good(const char *executable) {
         _cleanup_free_ char *p = NULL, *d = NULL;
         int r;
 
-        r = find_binary(binary, &p);
+        r = find_executable(executable, &p);
         if (r == -ENOENT)
                 return 0;
         if (r < 0)
                 return r;
 
-        /* An fsck that is linked to /bin/true is a non-existent
-         * fsck */
+        /* An fsck that is linked to /bin/true is a non-existent fsck */
 
         r = readlink_malloc(p, &d);
         if (r == -EINVAL) /* not a symlink */
@@ -738,7 +732,7 @@ int fsck_exists(const char *fstype) {
                 return -EINVAL;
 
         checker = strjoina("fsck.", fstype);
-        return binary_is_good(checker);
+        return executable_is_good(checker);
 }
 
 int parse_path_argument_and_warn(const char *path, bool suppress_root, char **arg) {
index 1afbebd77feda747114e7416d2d83bbcdcd12028..93e0f82bdc62b6204f85ee014d6f0d13015d8115 100644 (file)
@@ -80,7 +80,7 @@ int path_strv_make_absolute_cwd(char **l);
 char** path_strv_resolve(char **l, const char *root);
 char** path_strv_resolve_uniq(char **l, const char *root);
 
-int find_binary(const char *name, char **filename);
+int find_executable(const char *name, char **filename);
 
 bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
 
index f50fb0acea82dc635bb5759137e9011a7e2efaeb..96a441a5a6021599d025159bec127ca7f87bb9e0 100644 (file)
@@ -176,7 +176,7 @@ _unused_ static void test_compress_stream(const char *compression,
         _cleanup_free_ char *cmd = NULL, *cmd2 = NULL;
         struct stat st = {};
 
-        r = find_binary(cat, NULL);
+        r = find_executable(cat, NULL);
         if (r < 0) {
                 log_error_errno(r, "Skipping %s, could not find %s binary: %m", __func__, cat);
                 return;
index 38446d8814d0045a2ee45c79c9c58204447c5e43..bdd82c085a1d3a4e2e442c546147d88bb96c698e 100644 (file)
@@ -1725,7 +1725,7 @@ static int run(int argc, char* argv[]) {
 
                 /* Patch in an absolute path */
 
-                r = find_binary(arg_cmdline[0], &command);
+                r = find_executable(arg_cmdline[0], &command);
                 if (r < 0)
                         return log_error_errno(r, "Failed to find executable %s: %m", arg_cmdline[0]);
 
index 583ef90e65042b775ac34080e8da6ee290145fc5..6289a7339910a719fc41f1c557e575bf10e908b5 100644 (file)
@@ -20,7 +20,7 @@ int mkfs_exists(const char *fstype) {
         if (!filename_is_valid(mkfs)) /* refuse file system types with slashes and similar */
                 return -EINVAL;
 
-        r = find_binary(mkfs, NULL);
+        r = find_executable(mkfs, NULL);
         if (r == -ENOENT)
                 return false;
         if (r < 0)
@@ -44,7 +44,7 @@ int make_filesystem(
         assert(label);
 
         if (streq(fstype, "swap")) {
-                r = find_binary("mkswap", &mkfs);
+                r = find_executable("mkswap", &mkfs);
                 if (r == -ENOENT)
                         return log_error_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT), "mkswap binary not available.");
                 if (r < 0)
index 367d29a9a11a2456c703d9999a0561d73c8104a2..c18d68683e1684a3ef74b3934cefc1b0a1dfac94 100644 (file)
@@ -328,7 +328,7 @@ static void test_exec_privatedevices(Manager *m) {
 
         /* We use capsh to test if the capabilities are
          * properly set, so be sure that it exists */
-        r = find_binary("capsh", NULL);
+        r = find_executable("capsh", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Could not find capsh binary, skipping remaining tests in %s: %m", __func__);
                 return;
@@ -361,7 +361,7 @@ static void test_exec_protectkernelmodules(Manager *m) {
                 return;
         }
 
-        r = find_binary("capsh", NULL);
+        r = find_executable("capsh", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
                 return;
@@ -435,7 +435,7 @@ static void test_exec_systemcallfilter(Manager *m) {
         test(m, "exec-systemcallfilter-failing.service", SIGSYS, CLD_KILLED);
         test(m, "exec-systemcallfilter-failing2.service", SIGSYS, CLD_KILLED);
 
-        r = find_binary("python3", NULL);
+        r = find_executable("python3", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Skipping remaining tests in %s, could not find python3 binary: %m", __func__);
                 return;
@@ -458,7 +458,7 @@ static void test_exec_systemcallerrornumber(Manager *m) {
                 return;
         }
 
-        r = find_binary("python3", NULL);
+        r = find_executable("python3", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Skipping %s, could not find python3 binary: %m", __func__);
                 return;
@@ -694,7 +694,7 @@ static void test_exec_runtimedirectory(Manager *m) {
 static void test_exec_capabilityboundingset(Manager *m) {
         int r;
 
-        r = find_binary("capsh", NULL);
+        r = find_executable("capsh", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
                 return;
@@ -756,7 +756,7 @@ static void test_exec_ambientcapabilities(Manager *m) {
 static void test_exec_privatenetwork(Manager *m) {
         int r;
 
-        r = find_binary("ip", NULL);
+        r = find_executable("ip", NULL);
         if (r < 0) {
                 log_notice_errno(r, "Skipping %s, could not find ip binary: %m", __func__);
                 return;
index f0033bb545cf4ba5b5b20fe125f668bd51e67698..83336fc7feddcc2f22314ed69dd0bd849a95b193 100644 (file)
@@ -164,31 +164,31 @@ static void test_path_equal_root(void) {
         assert_se(!path_equal_or_files_same("/", "/.../", AT_SYMLINK_NOFOLLOW));
 }
 
-static void test_find_binary(const char *self) {
+static void test_find_executable(const char *self) {
         char *p;
 
         log_info("/* %s */", __func__);
 
-        assert_se(find_binary("/bin/sh", &p) == 0);
+        assert_se(find_executable("/bin/sh", &p) == 0);
         puts(p);
         assert_se(path_equal(p, "/bin/sh"));
         free(p);
 
-        assert_se(find_binary(self, &p) == 0);
+        assert_se(find_executable(self, &p) == 0);
         puts(p);
         /* libtool might prefix the binary name with "lt-" */
         assert_se(endswith(p, "/lt-test-path-util") || endswith(p, "/test-path-util"));
         assert_se(path_is_absolute(p));
         free(p);
 
-        assert_se(find_binary("sh", &p) == 0);
+        assert_se(find_executable("sh", &p) == 0);
         puts(p);
         assert_se(endswith(p, "/sh"));
         assert_se(path_is_absolute(p));
         free(p);
 
-        assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
-        assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
+        assert_se(find_executable("xxxx-xxxx", &p) == -ENOENT);
+        assert_se(find_executable("/some/dir/xxxx-xxxx", &p) == -ENOENT);
 }
 
 static void test_prefixes(void) {
@@ -670,7 +670,7 @@ int main(int argc, char **argv) {
         test_print_paths();
         test_path();
         test_path_equal_root();
-        test_find_binary(argv[0]);
+        test_find_executable(argv[0]);
         test_prefixes();
         test_path_join();
         test_fsck_exists();
index c6f39f25bdb01d8b6e5ac84c71bb55195624dfa1..0485c90fc923c4e224b7e89a90900516603f2c01 100644 (file)
@@ -405,7 +405,7 @@ int xdg_autostart_format_exec_start(
 
                         /* This is the executable, find it in $PATH */
                         first_arg = false;
-                        r = find_binary(c, &executable);
+                        r = find_executable(c, &executable);
                         if (r < 0)
                                 return log_info_errno(r, "Exec binary '%s' does not exist: %m", c);
 
@@ -481,7 +481,7 @@ static int xdg_autostart_generate_desktop_condition(
         if (!isempty(condition)) {
                 _cleanup_free_ char *gnome_autostart_condition_path = NULL, *e_autostart_condition = NULL;
 
-                r = find_binary(test_binary, &gnome_autostart_condition_path);
+                r = find_executable(test_binary, &gnome_autostart_condition_path);
                 if (r < 0) {
                         log_full_errno(r == -ENOENT ? LOG_INFO : LOG_WARNING, r,
                                        "%s not found: %m", test_binary);
@@ -536,10 +536,10 @@ int xdg_autostart_service_generate_unit(
 
         /*
          * The TryExec key cannot be checked properly from the systemd unit,
-         * it is trivial to check using find_binary though.
+         * it is trivial to check using find_executable though.
          */
         if (service->try_exec) {
-                r = find_binary(service->try_exec, NULL);
+                r = find_executable(service->try_exec, NULL);
                 if (r < 0) {
                         log_full_errno(r == -ENOENT ? LOG_INFO : LOG_WARNING, r,
                                        "Not generating service for XDG autostart %s, could not find TryExec= binary %s: %m",