Skip to content

Commit

Permalink
rc: use sethostname to set the hostname
Browse files Browse the repository at this point in the history
This is significantly less overhead than an init script.
  • Loading branch information
vapier authored and williamh committed Jul 25, 2024
1 parent ba6de6d commit dfb69a4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/openrc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand Down

0 comments on commit dfb69a4

Please sign in to comment.