Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142537951
D24288.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D24288.diff
View Options
Index: head/stand/defaults/loader.conf
===================================================================
--- head/stand/defaults/loader.conf
+++ head/stand/defaults/loader.conf
@@ -33,6 +33,11 @@
screensave_load="NO" # Set to YES to load a screensaver module
screensave_name="green_saver" # Set to the name of the screensaver module
+### Early hostid configuration ############################
+hostuuid_load="YES"
+hostuuid_name="/etc/hostid"
+hostuuid_type="hostuuid"
+
### Random number generator configuration ##################
# See rc.conf(5). The entropy_boot_file config variable must agree with the
# settings below.
Index: head/sys/kern/kern_jail.c
===================================================================
--- head/sys/kern/kern_jail.c
+++ head/sys/kern/kern_jail.c
@@ -48,6 +48,7 @@
#include <sys/taskqueue.h>
#include <sys/fcntl.h>
#include <sys/jail.h>
+#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/racct.h>
@@ -61,6 +62,7 @@
#include <sys/socket.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
+#include <sys/uuid.h>
#include <sys/vnode.h>
#include <net/if.h>
@@ -75,6 +77,7 @@
#include <security/mac/mac_framework.h>
#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"
+#define PRISON0_HOSTUUID_MODULE "hostuuid"
MALLOC_DEFINE(M_PRISON, "prison", "Prison structures");
static MALLOC_DEFINE(M_PRISON_RACCT, "prison_racct", "Prison racct structures");
@@ -218,10 +221,38 @@
void
prison0_init(void)
{
+ uint8_t *file, *data;
+ size_t size;
prison0.pr_cpuset = cpuset_ref(thread0.td_cpuset);
prison0.pr_osreldate = osreldate;
strlcpy(prison0.pr_osrelease, osrelease, sizeof(prison0.pr_osrelease));
+
+ /* If we have a preloaded hostuuid, use it. */
+ file = preload_search_by_type(PRISON0_HOSTUUID_MODULE);
+ if (file != NULL) {
+ data = preload_fetch_addr(file);
+ size = preload_fetch_size(file);
+ if (data != NULL) {
+ /*
+ * The preloaded data may include trailing whitespace, almost
+ * certainly a newline; skip over any whitespace or
+ * non-printable characters to be safe.
+ */
+ while (size > 0 && data[size - 1] <= 0x20) {
+ data[size--] = '\0';
+ }
+ if (validate_uuid(data, size, NULL, 0) == 0) {
+ (void)strlcpy(prison0.pr_hostuuid, data,
+ size + 1);
+ } else if (bootverbose) {
+ printf("hostuuid: preload data malformed: '%s'",
+ data);
+ }
+ }
+ }
+ if (bootverbose)
+ printf("hostuuid: using %s\n", prison0.pr_hostuuid);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 21, 6:23 PM (17 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27786441
Default Alt Text
D24288.diff (2 KB)
Attached To
Mode
D24288: Allow hostuuid to be preloaded for early-boot use
Attached
Detach File
Event Timeline
Log In to Comment