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.
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.
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]
22 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
25 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
38 #include <libscf_priv.h>
40 #include <sys/types.h>
41 #include <sys/uadmin.h>
44 #define SMF_RST "/etc/svc/volatile/resetting"
45 #define RETRY_COUNT 15 /* number of 1 sec retries for audit(8) to complete */
47 static const char *Usage
= "Usage: %s cmd fcn [mdep]\n";
50 main(int argc
, char *argv
[])
53 uintptr_t mdep
= (uintptr_t)NULL
;
56 if (argc
< 3 || argc
> 4) {
57 (void) fprintf(stderr
, Usage
, argv
[0]);
61 (void) sigfillset(&set
);
62 (void) sigprocmask(SIG_BLOCK
, &set
, NULL
);
66 if (argc
== 4) { /* mdep argument given */
67 if (cmd
!= A_REBOOT
&& cmd
!= A_SHUTDOWN
&& cmd
!= A_DUMP
&&
69 (void) fprintf(stderr
, "%s: mdep argument not "
70 "allowed for this cmd value\n", argv
[0]);
71 (void) fprintf(stderr
, Usage
, argv
[0]);
74 mdep
= (uintptr_t)argv
[3];
88 case AD_FASTREBOOT_DRYRUN
:
89 mdep
= (uintptr_t)NULL
; /* Ignore all arguments */
95 if (cmd
== A_CONFIG
) {
96 uint8_t boot_config
= 0;
97 uint8_t boot_config_ovr
= 0;
100 case AD_UPDATE_BOOT_CONFIG
:
101 scf_get_boot_config(&boot_config
);
102 boot_config_ovr
= boot_config
;
103 scf_get_boot_config_ovr(&boot_config_ovr
);
104 boot_config
&= boot_config_ovr
;
105 mdep
= (uintptr_t)(&boot_config
);
110 if (geteuid() == 0) {
111 if (cmd
== A_SHUTDOWN
|| cmd
== A_REBOOT
)
112 (void) creat(SMF_RST
, 0777);
115 if (uadmin(cmd
, fcn
, mdep
) < 0) {
118 (void) unlink(SMF_RST
);