mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
bootspec: use verify_fsroot_dir() in verify_xbootldr() too
Let's share some code between verify_xbootldr() and verify_esp().
This commit is contained in:
parent
85d021023f
commit
4a4994b68d
@ -964,43 +964,25 @@ static int verify_xbootldr(
|
|||||||
bool unprivileged_mode,
|
bool unprivileged_mode,
|
||||||
sd_id128_t *ret_uuid) {
|
sd_id128_t *ret_uuid) {
|
||||||
|
|
||||||
struct stat st, st2;
|
|
||||||
bool relax_checks;
|
bool relax_checks;
|
||||||
const char *t2;
|
dev_t devid;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
relax_checks = getenv_bool("SYSTEMD_RELAX_XBOOTLDR_CHECKS") > 0;
|
relax_checks = getenv_bool("SYSTEMD_RELAX_XBOOTLDR_CHECKS") > 0;
|
||||||
|
|
||||||
if (stat(p, &st) < 0)
|
r = verify_fsroot_dir(p, searching, unprivileged_mode, &devid);
|
||||||
return log_full_errno((searching && errno == ENOENT) ||
|
|
||||||
(unprivileged_mode && errno == EACCES) ? LOG_DEBUG : LOG_ERR, errno,
|
|
||||||
"Failed to determine block device node of \"%s\": %m", p);
|
|
||||||
|
|
||||||
if (major(st.st_dev) == 0)
|
|
||||||
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
|
|
||||||
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
|
|
||||||
"Block device node of \"%s\" is invalid.", p);
|
|
||||||
|
|
||||||
t2 = strjoina(p, "/..");
|
|
||||||
r = stat(t2, &st2);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_full_errno(unprivileged_mode && errno == EACCES ? LOG_DEBUG : LOG_ERR, errno,
|
return r;
|
||||||
"Failed to determine block device node of parent of \"%s\": %m", p);
|
|
||||||
|
|
||||||
if (st.st_dev == st2.st_dev)
|
|
||||||
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
|
|
||||||
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
|
|
||||||
"Directory \"%s\" is not the root of the XBOOTLDR file system.", p);
|
|
||||||
|
|
||||||
if (detect_container() > 0 || relax_checks)
|
if (detect_container() > 0 || relax_checks)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
if (unprivileged_mode)
|
if (unprivileged_mode)
|
||||||
return verify_xbootldr_udev(st.st_dev, searching, ret_uuid);
|
return verify_xbootldr_udev(devid, searching, ret_uuid);
|
||||||
else
|
else
|
||||||
return verify_xbootldr_blkid(st.st_dev, searching, ret_uuid);
|
return verify_xbootldr_blkid(devid, searching, ret_uuid);
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (ret_uuid)
|
if (ret_uuid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user