mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
sd-id128: tighten rules on chasing machine-id files
This commit is contained in:
@@ -136,7 +136,6 @@ _public_ int sd_id128_get_machine(sd_id128_t *ret) {
|
||||
}
|
||||
|
||||
int id128_get_machine_at(int rfd, sd_id128_t *ret) {
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(rfd >= 0 || rfd == AT_FDCWD);
|
||||
@@ -147,7 +146,8 @@ int id128_get_machine_at(int rfd, sd_id128_t *ret) {
|
||||
if (r > 0)
|
||||
return sd_id128_get_machine(ret);
|
||||
|
||||
fd = chase_and_openat(rfd, "/etc/machine-id", CHASE_AT_RESOLVE_IN_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
|
||||
_cleanup_close_ int fd =
|
||||
chase_and_openat(rfd, "/etc/machine-id", CHASE_AT_RESOLVE_IN_ROOT|CHASE_MUST_BE_REGULAR, O_RDONLY|O_CLOEXEC|O_NOCTTY, /* ret_path= */ NULL);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
@@ -155,12 +155,11 @@ int id128_get_machine_at(int rfd, sd_id128_t *ret) {
|
||||
}
|
||||
|
||||
int id128_get_machine(const char *root, sd_id128_t *ret) {
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
if (empty_or_root(root))
|
||||
return sd_id128_get_machine(ret);
|
||||
|
||||
fd = chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
|
||||
_cleanup_close_ int fd =
|
||||
chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT|CHASE_MUST_BE_REGULAR, O_RDONLY|O_CLOEXEC|O_NOCTTY, /* ret_path= */ NULL);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user