050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * CDDL HEADER START
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * The contents of this file are subject to the terms of the
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * Common Development and Distribution License (the "License").
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * You may not use this file except in compliance with the License.
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * or http://www.opensolaris.org/os/licensing.
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * See the License for the specific language governing permissions
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * and limitations under the License.
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * When distributing Covered Code, include this CDDL HEADER in each
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * If applicable, add the following below this CDDL HEADER, with the
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * fields enclosed by brackets "[]" replaced with your own identifying
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * information: Portions Copyright [yyyy] [name of copyright owner]
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * CDDL HEADER END
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram * Use is subject to license terms.
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers * Pull in the following three interfaces from libscf without introducing
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers * a dependency on it, which since libscf depends on libc would be circular:
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers * scf_simple_prop_get
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers * scf_simple_prop_next_boolean
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers * scf_simple_prop_free
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilerstypedef scf_simple_prop_t *(*scf_simple_prop_get_t)(scf_handle_t *,
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers const char *, const char *, const char *);
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilersstatic scf_simple_prop_get_t real_scf_simple_prop_get = NULL;
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilerstypedef uint8_t *(*scf_simple_prop_next_boolean_t)(scf_simple_prop_t *);
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilersstatic scf_simple_prop_next_boolean_t real_scf_simple_prop_next_boolean = NULL;
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilerstypedef void (*scf_simple_prop_free_t)(scf_simple_prop_t *);
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilersstatic scf_simple_prop_free_t real_scf_simple_prop_free = NULL;
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers void *scf_handle = dlopen("libscf.so.1", RTLD_LAZY);
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers scf_simple_prop_get_t scf_simple_prop_get = (scf_handle == NULL)? NULL :
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers (scf_simple_prop_get_t)dlsym(scf_handle, "scf_simple_prop_get");
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers scf_simple_prop_next_boolean_t scf_simple_prop_next_boolean =
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers (scf_simple_prop_next_boolean_t)dlsym(scf_handle,
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers "scf_simple_prop_next_boolean");
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers scf_simple_prop_free_t scf_simple_prop_free =
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers (scf_simple_prop_free_t)dlsym(scf_handle, "scf_simple_prop_free");
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_next_boolean == NULL ||
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_get = (scf_simple_prop_get_t)(-1);
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_get = scf_simple_prop_get;
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_free = scf_simple_prop_free;
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram char *fmri = "svc:/system/boot-config:default";
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_next_boolean == NULL ||
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers if (real_scf_simple_prop_get == (scf_simple_prop_get_t)(-1) ||
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers real_scf_simple_prop_free == (scf_simple_prop_free_t)(-1)) {
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers prop = real_scf_simple_prop_get(NULL, fmri, "config",
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers "uadmin_boot_archive_sync");
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers if ((ret_val = real_scf_simple_prop_next_boolean(prop)) !=
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers (void) system("/sbin/bootadm update-archive");
4ed6ceb3446c24afa0c760ea49cd78dbc7692329Jan Setje-Eilers extern int __uadmin(int cmd, int fcn, uintptr_t mdep);
050c4bfe6b1d1f7437af48ce2b7670e840e94f97Gangadhar Mylapuram if (geteuid() == 0 && getzoneid() == GLOBAL_ZONEID &&