Skip to content

Commit

Permalink
rc: use /etc/hostname if available
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 Jan 24, 2023
1 parent 0b86c06 commit a4cfc9b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/openrc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,33 @@ handle_signal(int sig)
errno = serrno;
}

static void
do_early_hostname(void)
{
#ifdef __linux__
/* 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);
}
#endif
}

static void
do_sysinit()
{
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 a4cfc9b

Please sign in to comment.