mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
path-util: introduce filename_or_absolute_path_is_valid() helper
This commit is contained in:
@@ -145,6 +145,12 @@ static inline bool path_is_safe(const char *p) {
|
||||
return path_is_valid_full(p, /* accept_dot_dot= */ false);
|
||||
}
|
||||
bool path_is_normalized(const char *p) _pure_;
|
||||
static inline bool filename_or_absolute_path_is_valid(const char *p) {
|
||||
if (path_is_absolute(p))
|
||||
return path_is_valid(p);
|
||||
|
||||
return filename_is_valid(p);
|
||||
}
|
||||
|
||||
int file_in_same_dir(const char *path, const char *filename, char **ret);
|
||||
|
||||
|
||||
@@ -1512,7 +1512,7 @@ int bus_set_transient_exec_command(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!path_is_absolute(path) && !filename_is_valid(path))
|
||||
if (!filename_or_absolute_path_is_valid(path))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"\"%s\" is neither a valid executable name nor an absolute path",
|
||||
path);
|
||||
|
||||
@@ -974,7 +974,7 @@ int config_parse_exec(
|
||||
return ignore ? 0 : -ENOEXEC;
|
||||
}
|
||||
|
||||
if (!(path_is_absolute(path) ? path_is_valid(path) : filename_is_valid(path))) {
|
||||
if (!filename_or_absolute_path_is_valid(path)) {
|
||||
log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0,
|
||||
"Neither a valid executable name nor an absolute path%s: %s",
|
||||
ignore ? ", ignoring" : "", path);
|
||||
|
||||
Reference in New Issue
Block a user