In rescue mode, always set hostname from /lib/finit/rescue.conf

If hostname is missing from /lib/finit/rescue.conf the system will
default to the configured default hostname (noname).

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-12-30 21:20:06 +01:00
parent 3f7e03e813
commit 55cb50ef90
+4
View File
@@ -184,6 +184,9 @@ void set_hostname(char **hostname)
{
FILE *fp;
if (rescue)
goto done;
fp = fopen("/etc/hostname", "r");
if (fp) {
struct stat st;
@@ -204,6 +207,7 @@ void set_hostname(char **hostname)
fclose(fp);
}
done:
if (*hostname)
sethostname(*hostname, strlen(*hostname));
}