summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openrc/rc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/openrc/rc.c b/src/openrc/rc.c
index 5bee9e6c..483db4cc 100644
--- a/src/openrc/rc.c
+++ b/src/openrc/rc.c
@@ -474,11 +474,30 @@ handle_signal(int sig)
}
static void
+do_early_hostname(void)
+{
+ /* Set hostname if available */
+ char *buffer = NULL;
+ size_t len;
+
+ if (rc_getfile(RC_SYSCONFDIR "/hostname", &buffer, &len)) {
+ if (buffer[len - 2] == '\n')
+ buffer[--len - 1] = '\0';
+ if (sethostname(buffer, len)) {
+ /* ignore */;
+ }
+ free(buffer);
+ }
+}
+
+static void
do_sysinit(void)
{
struct utsname uts;
const char *sys;
+ do_early_hostname();
+
/* exec init-early.sh if it exists
* This should just setup the console to use the correct
* font. Maybe it should setup the keyboard too? */