"executable" is more correct than "binary", since scripts are OK too.
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;
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;
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)
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 */
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) {
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);
_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;
/* 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]);
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)
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)
/* 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;
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;
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;
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;
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;
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;
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) {
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();
/* 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);
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);
/*
* 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",