Page MenuHomeFreeBSD

D24288.diff
No OneTemporary

D24288.diff

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

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)

Event Timeline