xref: /onnv-gate/usr/src/lib/libc/sparc/sys/uadmin.c (revision 10052:86e6866e392d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/types.h>
27 #include <libscf.h>
28 #include <sys/uadmin.h>
29 #include <unistd.h>
30 #include <stdlib.h>
31 #include <zone.h>
32 
33 int
34 uadmin(int cmd, int fcn, uintptr_t mdep)
35 {
36 	extern int __uadmin(int cmd, int fcn, uintptr_t mdep);
37 	scf_simple_prop_t *prop = NULL;
38 	uint8_t *ret_val = NULL;
39 	boolean_t update_flag = B_FALSE;
40 	char *fmri = "svc:/system/boot-config:default";
41 
42 	if (geteuid() == 0 && getzoneid() == GLOBAL_ZONEID &&
43 	    (cmd == A_SHUTDOWN || cmd == A_REBOOT)) {
44 		prop = scf_simple_prop_get(NULL, fmri, "config",
45 		    "uadmin_boot_archive_sync");
46 		if (prop) {
47 			if ((ret_val = scf_simple_prop_next_boolean(prop)) !=
48 			    NULL)
49 				update_flag = (*ret_val == 0) ? B_FALSE :
50 				    B_TRUE;
51 			scf_simple_prop_free(prop);
52 		}
53 
54 		if (update_flag == B_TRUE)
55 			(void) system("/sbin/bootadm update-archive");
56 	}
57 
58 	return (__uadmin(cmd, fcn, mdep));
59 }
60