diff options
| author | Mike Frysinger <vapier@gentoo.org> | 2011-12-03 05:46:48 -0500 |
|---|---|---|
| committer | William Hubbs <w.d.hubbs@gmail.com> | 2024-07-25 18:37:37 -0500 |
| commit | dfb69a4e5d0011911c275dd86f342cb5e1ed10a7 (patch) | |
| tree | 0061ba94689df8c247ec8aa0ebc4ec433f6f9ed5 | |
| parent | ba6de6db466d30dd2dcb8f1c89c4a4bf5af80c20 (diff) | |
rc: use sethostname to set the hostnameorigin/vapier
This is significantly less overhead than an init script.
| -rw-r--r-- | src/openrc/rc.c | 19 |
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? */ |
