From 99d758f40a3001a0e2e03921c5c560e11eb8e142 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 26 Feb 2013 15:27:22 +0100 Subject: [PATCH] setup: install - write machine-id to default pattern --- src/setup/setup.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/setup/setup.c b/src/setup/setup.c index 9f71bb7..d36aad5 100644 --- a/src/setup/setup.c +++ b/src/setup/setup.c @@ -1202,24 +1202,22 @@ static int remove_variables(const uint8_t uuid[16], const char *path, bool in_or static int install_loader_config(const char *esp_path) { char *p = NULL; - char line[LINE_MAX]; + char line[64]; char *vendor = NULL; FILE *f; - f = fopen("/etc/os-release", "re"); + f = fopen("/etc/machine-id", "re"); if (!f) return -errno; - while (fgets(line, sizeof(line), f) != NULL) { + if (fgets(line, sizeof(line), f) != NULL) { char *s; - if (strncmp(line, "ID=", 3) != 0) - continue; - vendor = line + 3; - s = strchr(vendor, '\n'); + s = strchr(line, '\n'); if (s) s[0] = '\0'; - break; + if (strlen(line) == 32) + vendor = line; } fclose(f); -- 2.7.4