753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * CDDL HEADER START
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * The contents of this file are subject to the terms of the
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Common Development and Distribution License (the "License").
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * You may not use this file except in compliance with the License.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * See the License for the specific language governing permissions
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * and limitations under the License.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * When distributing Covered Code, include this CDDL HEADER in each
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * If applicable, add the following below this CDDL HEADER, with the
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * fields enclosed by brackets "[]" replaced with your own identifying
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * information: Portions Copyright [yyyy] [name of copyright owner]
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * CDDL HEADER END
e557d412e15c7f384b2ea3bf316a739a0f81cd55Christopher Kiick * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Use is subject to license terms.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * This file contains high level functions used by multiple utilities.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Check whether the platform is on the fastreboot_blacklist.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Return 1 if the platform has been blacklisted, 0 otherwise.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * If there's no SMBIOS, assume it's blacklisted.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if ((shp = smbios_open(NULL, SMB_VERSION, 0, &err)) == NULL)
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * If we can't read system info, assume it's blacklisted.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if ((id = smbios_info_system(shp, &sys)) == SMB_ERR ||
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore smbios_info_common(shp, id, &info) == SMB_ERR) {
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * If we can't read the "platforms" property from property group
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * BOOT_CONFIG_PG_FBBLACKLIST, assume no platforms have
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * been blacklisted.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if ((prop = scf_simple_prop_get(NULL, FMRI_BOOT_CONFIG,
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore BOOT_CONFIG_PG_FBBLACKLIST, "platforms")) == NULL)
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore for (i = 0; i < numvals; i++) {
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore platform_name = scf_simple_prop_next_astring(prop);
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if (strcmp(platform_name, info.smbi_product) == 0) {
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Add or get a property group given an FMRI.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Return SCF_SUCCESS on success, SCF_FAILED on failure.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moorescf_fmri_pg_get_or_add(const char *fmri, const char *pgname,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore if ((handle = scf_handle_create(SCF_VERSION)) == NULL ||
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore (inst = scf_instance_create(handle)) == NULL ||
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore scf_handle_decode_fmri(handle, fmri, NULL, NULL,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore inst, NULL, NULL, SCF_DECODE_FMRI_EXACT) != SCF_SUCCESS)
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore rc = scf_instance_add_pg(inst, pgname, pgtype, pgflags, NULL);
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * If the property group already exists, return SCF_SUCCESS.
57b30532f440463cfdc0decec0c4b07e9c0991f6Sherry Moore if (rc != SCF_SUCCESS && scf_error() == SCF_ERROR_EXISTS)
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore#endif /* __x86 */
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Get config properties from svc:/system/boot-config:default.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * It prints errors with uu_warn().
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Property vector for BOOT_CONFIG_PG_PARAMS property group.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore { FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore { FASTREBOOT_ONPANIC, NULL, SCF_TYPE_BOOLEAN, NULL,
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore for (prop = ua_boot_config; prop->pv_prop != NULL; prop++)
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if (scf_read_propvec(FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_PARAMS,
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore B_TRUE, ua_boot_config, &prop) != SCF_FAILED) {
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Unset both flags if the platform has been
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * blacklisted.
e557d412e15c7f384b2ea3bf316a739a0f81cd55Christopher Kiick#endif /* __x86 */
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore BOOT_CONFIG_PG_PARAMS, scf_strerror(scf_error()));
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore#endif /* FASTREBOOT_DEBUG */
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Get or set properties in non-persistent "config_ovr" property group
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * in svc:/system/boot-config:default.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * It prints errors with uu_warn().
4196e26398ab7019943a8f276006fa66937b4425Sherry Moorescf_getset_boot_config_ovr(int set, uint8_t *boot_config_ovr)
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Property vector for BOOT_CONFIG_PG_OVR property group.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore { FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
c90a5fbe436d54a1d69dbcf41c7f1cc7b2834a18Sherry Moore { FASTREBOOT_ONPANIC, NULL, SCF_TYPE_BOOLEAN, NULL,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore "property group '%s'\n",
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore#endif /* FASTREBOOT_DEBUG */
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore for (prop = ua_boot_config_ovr; prop->pv_prop != NULL; prop++)
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore BOOT_CONFIG_PG_OVR, ua_boot_config_ovr, &prop);
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore BOOT_CONFIG_PG_OVR, B_FALSE, ua_boot_config_ovr,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore#endif /* FASTREBOOT_DEBUG */
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore#endif /* __x86 */
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Get values of properties in non-persistent "config_ovr" property group.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moorescf_get_boot_config_ovr(uint8_t *boot_config_ovr)
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore (void) scf_getset_boot_config_ovr(B_FALSE, boot_config_ovr);
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Set value of "config_ovr/fastreboot_default".
4196e26398ab7019943a8f276006fa66937b4425Sherry Moorescf_fastreboot_default_set_transient(boolean_t value)
c90a5fbe436d54a1d69dbcf41c7f1cc7b2834a18Sherry Moore boot_config_ovr = UA_FASTREBOOT_DEFAULT | UA_FASTREBOOT_ONPANIC;
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore return (scf_getset_boot_config_ovr(B_TRUE, &boot_config_ovr));
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Check whether Fast Reboot is the default operating mode.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Return 0 if
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * 1. the platform is xVM
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * 2. svc:/system/boot-config:default service doesn't exist,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * 3. property "config/fastreboot_default" doesn't exist,
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * 4. value of property "config/fastreboot_default" is set to "false"
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * and "config_ovr/fastreboot_default" is not set to "true",
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * 5. the platform has been blacklisted.
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * 6. value of property "config_ovr/fastreboot_default" is set to "false".
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * Return non-zero otherwise.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore * If we are on xVM, do not fast reboot by default.
753a6d457b330b1b29b2d3eefcd0831116ce950dSherry Moore if (sysinfo(SI_PLATFORM, procbuf, sizeof (procbuf)) == -1 ||
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Get property values from "config" property group
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore * Get property values from non-persistent "config_ovr" property group
4196e26398ab7019943a8f276006fa66937b4425Sherry Moore return (boot_config & boot_config_ovr & UA_FASTREBOOT_DEFAULT);
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe * Read the default security-flags from system/process-security and return a
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe * secflagset_t suitable for psecflags(2)
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe * Unfortunately, this symbol must _exist_ in the native build, for the sake
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe * of the mapfile, even though we don't ever use it, and it will never work.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowescf_default_secflags(scf_handle_t *hndl, scf_secflags_t *flags)
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe for (flag = 0; (flagname = secflag_to_str(flag)) != NULL;
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe return (-1);
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe if ((prop = scf_property_create(hndl)) == NULL) {
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe return (-1);
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#endif /* !NATIVE_BUILD */