File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -451,12 +451,33 @@ handle_signal(int sig)
451451 errno = serrno ;
452452}
453453
454+ static void
455+ do_early_hostname (void )
456+ {
457+ #ifdef __linux__
458+ /* Set hostname if available */
459+ char * buffer = NULL ;
460+ size_t len ;
461+
462+ if (rc_getfile (RC_SYSCONFDIR "/hostname" , & buffer , & len )) {
463+ if (buffer [len - 2 ] == '\n' )
464+ buffer [-- len - 1 ] = '\0' ;
465+ if (sethostname (buffer , len )) {
466+ /* ignore */ ;
467+ }
468+ free (buffer );
469+ }
470+ #endif
471+ }
472+
454473static void
455474do_sysinit ()
456475{
457476 struct utsname uts ;
458477 const char * sys ;
459478
479+ do_early_hostname ();
480+
460481 /* exec init-early.sh if it exists
461482 * This should just setup the console to use the correct
462483 * font. Maybe it should setup the keyboard too? */
You can’t perform that action at this time.
0 commit comments