X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fmachine-id-setup.c;h=063f705ede8477f533204ca4cf3fdd2273fc491e;hb=c43b2132f37264600cc26e07c8d85dfdd6c969f0;hp=74582a5dcd0be2121778197e6301bc0f922fc4b7;hpb=979ef53a268d6f54a309fc5c6015df5d4accbbd5;p=elogind.git diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index 74582a5dc..063f705ed 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -73,7 +72,7 @@ static int generate(char id[34], const char *root) { if (isempty(root)) dbus_machine_id = "/var/lib/dbus/machine-id"; else - dbus_machine_id = strappenda(root, "/var/lib/dbus/machine-id"); + dbus_machine_id = strjoina(root, "/var/lib/dbus/machine-id"); /* First, try reading the D-Bus machine id, unless it is a symlink */ fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW); @@ -182,7 +181,7 @@ static int write_machine_id(int fd, char id[34]) { assert(id); lseek(fd, 0, SEEK_SET); - if (loop_write(fd, id, 33, false) == 33) + if (loop_write(fd, id, 33, false) == 0) return 0; return -errno; @@ -199,13 +198,13 @@ int machine_id_commit(const char *root) { else { char *x; - x = strappenda(root, "/etc/machine-id"); + x = strjoina(root, "/etc/machine-id"); etc_machine_id = path_kill_slashes(x); } r = path_is_mount_point(etc_machine_id, false); if (r < 0) - return log_error_errno(r, "Failed to determine wether %s is a mount point: %m", etc_machine_id); + return log_error_errno(r, "Failed to determine whether %s is a mount point: %m", etc_machine_id); if (r == 0) { log_debug("%s is is not a mount point. Nothing to do.", etc_machine_id); return 0; @@ -281,10 +280,10 @@ int machine_id_setup(const char *root) { } else { char *x; - x = strappenda(root, "/etc/machine-id"); + x = strjoina(root, "/etc/machine-id"); etc_machine_id = path_kill_slashes(x); - x = strappenda(root, "/run/machine-id"); + x = strjoina(root, "/run/machine-id"); run_machine_id = path_kill_slashes(x); } @@ -329,10 +328,9 @@ int machine_id_setup(const char *root) { if (r < 0) return r; - if (S_ISREG(st.st_mode) && writable) { + if (S_ISREG(st.st_mode) && writable) if (write_machine_id(fd, id) == 0) return 0; - } fd = safe_close(fd);