mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
sd-id128: id128_write overwrites target file
This commit is contained in:
parent
a6f72863ad
commit
da2d142114
@ -186,7 +186,7 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) {
|
||||
int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
||||
fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444);
|
||||
fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_TRUNC, 0444);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -83,7 +83,8 @@ check expected "$r/etc/machine-id"
|
||||
|
||||
r="$(pwd)/transient-machine-id"
|
||||
setup_root "$r"
|
||||
touch "$r/etc/machine-id"
|
||||
systemd-machine-id-setup --print --root "$r"
|
||||
echo abc >>"$r/etc/machine-id"
|
||||
mount -o remount,ro "$r"
|
||||
mount -t tmpfs tmpfs "$r/run"
|
||||
transient_id=$(systemd-machine-id-setup --print --root "$r")
|
||||
|
Loading…
Reference in New Issue
Block a user