X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=hostname-setup.c;h=67891a52e62c9d82ef49faa86ad41a45774072d4;hp=5f3ee77ac01a61d3ffc94745d5609f967f47ba46;hb=d7c114c00030309435fc56c77c8578a25d228ebe;hpb=206bf5c294d300cf05ee7b17c5bf42a21f6a52c0 diff --git a/hostname-setup.c b/hostname-setup.c index 5f3ee77ac..67891a52e 100644 --- a/hostname-setup.c +++ b/hostname-setup.c @@ -75,6 +75,47 @@ finish: fclose(f); return r; +#elif defined(TARGET_ARCH) + int r; + FILE *f; + + assert(hn); + + if (!(f = fopen("/etc/rc.conf", "re"))) + return -errno; + + for (;;) { + char line[LINE_MAX]; + char *s, *k; + + if (!fgets(line, sizeof(line), f)) { + if (feof(f)) + break; + + r = -errno; + goto finish; + } + + s = strstrip(line); + + if (!startswith(s, "HOSTNAME=")) + continue; + + if (!(k = strdup(s+9))) { + r = -ENOMEM; + goto finish; + } + + *hn = k; + break; + } + + r = 0; + +finish: + fclose(f); + return r; + #elif defined(TARGET_SUSE) int r; char *s, *k;