/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file contains high level functions used by multiple utilities.
*/
#include "libscf_impl.h"
#include <assert.h>
#include <libuutil.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <sys/systeminfo.h>
#include <sys/secflags.h>
#ifdef __x86
#include <smbios.h>
/*
* Check whether the platform is on the fastreboot_blacklist.
* Return 1 if the platform has been blacklisted, 0 otherwise.
*/
static int
scf_is_fb_blacklisted(void)
{
int err;
int i;
char *platform_name;
int blacklisted = 0;
/*
* If there's no SMBIOS, assume it's blacklisted.
*/
return (1);
/*
* If we can't read system info, assume it's blacklisted.
*/
blacklisted = 1;
goto fb_out;
}
/*
* If we can't read the "platforms" property from property group
* BOOT_CONFIG_PG_FBBLACKLIST, assume no platforms have
* been blacklisted.
*/
goto fb_out;
for (i = 0; i < numvals; i++) {
if (platform_name == NULL)
break;
blacklisted = 1;
break;
}
}
return (blacklisted);
}
/*
* Add or get a property group given an FMRI.
* Return SCF_SUCCESS on success, SCF_FAILED on failure.
*/
static int
{
int error;
scf_handle_bind(handle) != 0 ||
goto scferror;
if (add) {
/*
* If the property group already exists, return SCF_SUCCESS.
*/
rc = SCF_SUCCESS;
} else {
}
if (rc != SCF_SUCCESS)
if (handle)
(void) scf_handle_unbind(handle);
if (rc != SCF_SUCCESS)
(void) scf_set_error(error);
return (rc);
}
#endif /* __x86 */
/*
* Get config properties from svc:/system/boot-config:default.
* It prints errors with uu_warn().
*/
void
{
*boot_config = 0;
{
/*
* Property vector for BOOT_CONFIG_PG_PARAMS property group.
*/
{ NULL }
};
#ifdef __x86
/*
* Unset both flags if the platform has been
* blacklisted.
*/
if (scf_is_fb_blacklisted())
return;
#endif /* __x86 */
return;
}
#if defined(FASTREBOOT_DEBUG)
(void) uu_warn("Service %s property '%s/%s' "
"not found.\n", FMRI_BOOT_CONFIG,
} else {
(void) uu_warn("Unable to read service %s "
"property '%s': %s\n", FMRI_BOOT_CONFIG,
}
#endif /* FASTREBOOT_DEBUG */
}
}
/*
* Get or set properties in non-persistent "config_ovr" property group
* in svc:/system/boot-config:default.
* It prints errors with uu_warn().
*/
/*ARGSUSED*/
static int
{
#ifndef __x86
return (rc);
#else
{
/*
* Property vector for BOOT_CONFIG_PG_OVR property group.
*/
{ NULL }
};
if (rc != SCF_SUCCESS) {
#if defined(FASTREBOOT_DEBUG)
if (set)
(void) uu_warn("Unable to add service %s "
"property group '%s'\n",
#endif /* FASTREBOOT_DEBUG */
return (rc);
}
if (set)
else
&prop);
#if defined(FASTREBOOT_DEBUG)
if (rc != SCF_SUCCESS) {
(void) uu_warn("Service %s property '%s/%s' "
"not found.\n", FMRI_BOOT_CONFIG,
} else {
(void) uu_warn("Unable to %s service %s "
scf_strerror(scf_error()));
}
}
#endif /* FASTREBOOT_DEBUG */
if (set)
(void) smf_refresh_instance(FMRI_BOOT_CONFIG);
return (rc);
}
#endif /* __x86 */
}
/*
* Get values of properties in non-persistent "config_ovr" property group.
*/
void
{
}
/*
* Set value of "config_ovr/fastreboot_default".
*/
int
{
}
/*
* Check whether Fast Reboot is the default operating mode.
* Return 0 if
* 1. the platform is xVM
* or
* 2. svc:/system/boot-config:default service doesn't exist,
* or
* 3. property "config/fastreboot_default" doesn't exist,
* or
* 4. value of property "config/fastreboot_default" is set to "false"
* and "config_ovr/fastreboot_default" is not set to "true",
* or
* 5. the platform has been blacklisted.
* or
* 6. value of property "config_ovr/fastreboot_default" is set to "false".
* Return non-zero otherwise.
*/
int
scf_is_fastboot_default(void)
{
/*
* If we are on xVM, do not fast reboot by default.
*/
return (0);
/*
* Get property values from "config" property group
*/
/*
* Get property values from non-persistent "config_ovr" property group
*/
}
/*
* Read the default security-flags from system/process-security and return a
* secflagset_t suitable for psecflags(2)
*
* Unfortunately, this symbol must _exist_ in the native build, for the sake
* of the mapfile, even though we don't ever use it, and it will never work.
*/
struct group_desc {
char *fmri;
};
int
{
#if !defined(NATIVE_BUILD)
const char *flagname;
int flag;
struct group_desc *g;
{NULL, "svc:/system/process-security/"
":properties/default"},
{NULL, "svc:/system/process-security/"
":properties/lower"},
{NULL, "svc:/system/process-security/"
":properties/upper"},
};
flag++) {
char *pfmri;
return (-1);
return (-1);
}
uu_die("Allocation failure\n");
goto next;
goto next;
if (flagval != 0)
else
next:
}
}
return (0);
#else
assert(0);
abort();
#endif /* !NATIVE_BUILD */
}