mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
core: use chase_symlinks_and_access() where appropriate
This commit is contained in:
@@ -1702,8 +1702,6 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
|
||||
"Specified switch root path '%s' does not seem to be an OS tree. os-release file is missing.",
|
||||
root);
|
||||
} else {
|
||||
_cleanup_free_ char *chased = NULL;
|
||||
|
||||
if (!path_is_valid(init))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Path to init binary '%s' is not a valid path.", init);
|
||||
@@ -1712,19 +1710,13 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Path to init binary '%s' not absolute.", init);
|
||||
|
||||
r = chase_symlinks(init, root, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &chased, NULL);
|
||||
r = chase_symlinks_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL, NULL);
|
||||
if (r == -EACCES)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Init binary %s is not executable.", init);
|
||||
if (r < 0)
|
||||
return sd_bus_error_set_errnof(error, r,
|
||||
"Could not resolve init executable %s: %m", init);
|
||||
|
||||
if (laccess(chased, X_OK) < 0) {
|
||||
if (errno == EACCES)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Init binary %s is not executable.", init);
|
||||
|
||||
return sd_bus_error_set_errnof(error, r,
|
||||
"Could not check whether init binary %s is executable: %m", init);
|
||||
}
|
||||
}
|
||||
|
||||
rt = strdup(root);
|
||||
|
||||
Reference in New Issue
Block a user