mirror of
https://github.com/OpenRC/openrc.git
synced 2024-11-27 03:44:16 +08:00
rc: use sethostname to set the hostname
This is significantly less overhead than an init script.
This commit is contained in:
parent
ba6de6db46
commit
dfb69a4e5d
@ -473,12 +473,31 @@ handle_signal(int sig)
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
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? */
|
||||
|
Loading…
Reference in New Issue
Block a user