* Initialize the parts of prison0 that can't be static-initialized with * constants. This is called from proc0_init() after creating thread0 cpuset. */
| 229 | * constants. This is called from proc0_init() after creating thread0 cpuset. |
| 230 | */ |
| 231 | void |
| 232 | prison0_init(void) |
| 233 | { |
| 234 | uint8_t *file, *data; |
| 235 | size_t size; |
| 236 | |
| 237 | prison0.pr_cpuset = cpuset_ref(thread0.td_cpuset); |
| 238 | prison0.pr_osreldate = osreldate; |
| 239 | strlcpy(prison0.pr_osrelease, osrelease, sizeof(prison0.pr_osrelease)); |
| 240 | |
| 241 | /* If we have a preloaded hostuuid, use it. */ |
| 242 | file = preload_search_by_type(PRISON0_HOSTUUID_MODULE); |
| 243 | if (file != NULL) { |
| 244 | data = preload_fetch_addr(file); |
| 245 | size = preload_fetch_size(file); |
| 246 | if (data != NULL) { |
| 247 | /* |
| 248 | * The preloaded data may include trailing whitespace, almost |
| 249 | * certainly a newline; skip over any whitespace or |
| 250 | * non-printable characters to be safe. |
| 251 | */ |
| 252 | while (size > 0 && data[size - 1] <= 0x20) { |
| 253 | data[size--] = '\0'; |
| 254 | } |
| 255 | if (validate_uuid(data, size, NULL, 0) == 0) { |
| 256 | (void)strlcpy(prison0.pr_hostuuid, data, |
| 257 | size + 1); |
| 258 | } else if (bootverbose) { |
| 259 | printf("hostuuid: preload data malformed: '%s'", |
| 260 | data); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | if (bootverbose) |
| 265 | printf("hostuuid: using %s\n", prison0.pr_hostuuid); |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | * struct jail_args { |
no test coverage detected