basic/path-util: enhance find_executable() for the fixed path case
This commit is contained in:
@@ -585,9 +585,9 @@ char* path_join_internal(const char *first, ...) {
|
||||
return joined;
|
||||
}
|
||||
|
||||
int find_executable(const char *name, char **ret) {
|
||||
int find_executable_full(const char *name, bool use_path_envvar, char **ret) {
|
||||
int last_error, r;
|
||||
const char *p;
|
||||
const char *p = NULL;
|
||||
|
||||
assert(name);
|
||||
|
||||
@@ -604,8 +604,10 @@ int find_executable(const char *name, char **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Plain getenv, not secure_getenv, because we want to actually allow the user to pick the binary. */
|
||||
p = getenv("PATH");
|
||||
if (use_path_envvar)
|
||||
/* 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;
|
||||
|
||||
|
||||
@@ -88,7 +88,10 @@ 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_executable(const char *name, char **filename);
|
||||
int find_executable_full(const char *name, bool use_path_envvar, char **ret);
|
||||
static inline int find_executable(const char *name, char **ret) {
|
||||
return find_executable_full(name, true, ret);
|
||||
}
|
||||
|
||||
bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user