summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-06 07:58:05 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-06 07:58:05 -0400
commit7b792fa1a977587cdfe9275eb1dbf0b8008dbe8b (patch)
tree6a48e3eddafd2776067700cc454fe1b2ca1a11c4 /src
parent64af424063c5277a97bdc9693a227019c7c2f16e (diff)
parentf5e754e0d78596a8ff41859b792099cf08c6a08d (diff)
Merge pull request #2970 from msekletar/machine-id-prefix-roota
machine-id-setup: simplify by using prefix_roota
Diffstat (limited to 'src')
-rw-r--r--src/core/machine-id-setup.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 9e6b3d3292..7b25349c07 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -120,10 +120,7 @@ static int generate_machine_id(char id[34], const char *root) {
assert(id);
- if (isempty(root))
- dbus_machine_id = "/var/lib/dbus/machine-id";
- else
- dbus_machine_id = strjoina(root, "/var/lib/dbus/machine-id");
+ dbus_machine_id = prefix_roota(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);
@@ -203,18 +200,8 @@ int machine_id_setup(const char *root, sd_id128_t machine_id) {
char id[34]; /* 32 + \n + \0 */
int r;
- if (isempty(root)) {
- etc_machine_id = "/etc/machine-id";
- run_machine_id = "/run/machine-id";
- } else {
- char *x;
-
- x = strjoina(root, "/etc/machine-id");
- etc_machine_id = path_kill_slashes(x);
-
- x = strjoina(root, "/run/machine-id");
- run_machine_id = path_kill_slashes(x);
- }
+ etc_machine_id = prefix_roota(root, "/etc/machine-id");
+ run_machine_id = prefix_roota(root, "/run/machine-id");
RUN_WITH_UMASK(0000) {
/* We create this 0444, to indicate that this isn't really
@@ -301,14 +288,7 @@ int machine_id_commit(const char *root) {
char id[34]; /* 32 + \n + \0 */
int r;
- if (isempty(root))
- etc_machine_id = "/etc/machine-id";
- else {
- char *x;
-
- x = strjoina(root, "/etc/machine-id");
- etc_machine_id = path_kill_slashes(x);
- }
+ etc_machine_id = prefix_roota(root, "/etc/machine-id");
r = path_is_mount_point(etc_machine_id, 0);
if (r < 0)