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 /*
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Joyent, Inc.
25 * Copyright 2012 Milan Jurik. All rights reserved.
26 * Copyright 2017 RackTop Systems.
27 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
28 */
29
30
31 #include <alloca.h>
32 #include <assert.h>
33 #include <ctype.h>
34 #include <door.h>
35 #include <errno.h>
36 #include <fcntl.h>
37 #include <fnmatch.h>
38 #include <inttypes.h>
39 #include <libintl.h>
40 #include <libnvpair.h>
41 #include <libscf.h>
42 #include <libscf_priv.h>
43 #include <libtecla.h>
44 #include <libuutil.h>
9726 {
9727 struct pg_elts elts;
9728 int ret;
9729
9730 /*
9731 * In case there are properties which don't correspond to child
9732 * entities of the service entity, we'll set up a pg_elts structure to
9733 * put them in.
9734 */
9735 (void) memset(&elts, 0, sizeof (elts));
9736
9737 /* Walk the properties, looking for special ones. */
9738 if (scf_iter_pg_properties(exp_prop_iter, pg) != SCF_SUCCESS)
9739 scfdie();
9740
9741 while ((ret = scf_iter_next_property(exp_prop_iter, exp_prop)) == 1) {
9742 if (scf_property_get_name(exp_prop, exp_str, exp_str_sz) < 0)
9743 scfdie();
9744
9745 if (strcmp(exp_str, SCF_PROPERTY_SINGLE_INSTANCE) == 0) {
9746 if (prop_check_type(exp_prop, SCF_TYPE_BOOLEAN) == 0 &&
9747 prop_get_val(exp_prop, exp_val) == 0) {
9748 uint8_t b;
9749
9750 if (scf_value_get_boolean(exp_val, &b) !=
9751 SCF_SUCCESS)
9752 scfdie();
9753
9754 if (b) {
9755 selts->single_instance =
9756 xmlNewNode(NULL,
9757 (xmlChar *)"single_instance");
9758 if (selts->single_instance == NULL)
9759 uu_die(emsg_create_xml);
9760 }
9761
9762 continue;
9763 }
9764 } else if (strcmp(exp_str, SCF_PROPERTY_RESTARTER) == 0) {
9765 xmlNodePtr rnode, sfnode;
|
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 /*
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Joyent, Inc.
25 * Copyright 2012 Milan Jurik. All rights reserved.
26 * Copyright 2017 RackTop Systems.
27 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
28 */
29
30
31 #include <alloca.h>
32 #include <assert.h>
33 #include <ctype.h>
34 #include <door.h>
35 #include <errno.h>
36 #include <fcntl.h>
37 #include <fnmatch.h>
38 #include <inttypes.h>
39 #include <libintl.h>
40 #include <libnvpair.h>
41 #include <libscf.h>
42 #include <libscf_priv.h>
43 #include <libtecla.h>
44 #include <libuutil.h>
9726 {
9727 struct pg_elts elts;
9728 int ret;
9729
9730 /*
9731 * In case there are properties which don't correspond to child
9732 * entities of the service entity, we'll set up a pg_elts structure to
9733 * put them in.
9734 */
9735 (void) memset(&elts, 0, sizeof (elts));
9736
9737 /* Walk the properties, looking for special ones. */
9738 if (scf_iter_pg_properties(exp_prop_iter, pg) != SCF_SUCCESS)
9739 scfdie();
9740
9741 while ((ret = scf_iter_next_property(exp_prop_iter, exp_prop)) == 1) {
9742 if (scf_property_get_name(exp_prop, exp_str, exp_str_sz) < 0)
9743 scfdie();
9744
9745 if (strcmp(exp_str, SCF_PROPERTY_SINGLE_INSTANCE) == 0) {
9746 /*
9747 * Unimplemented and obsolete, but we still process it
9748 * for compatibility purposes.
9749 */
9750 if (prop_check_type(exp_prop, SCF_TYPE_BOOLEAN) == 0 &&
9751 prop_get_val(exp_prop, exp_val) == 0) {
9752 uint8_t b;
9753
9754 if (scf_value_get_boolean(exp_val, &b) !=
9755 SCF_SUCCESS)
9756 scfdie();
9757
9758 if (b) {
9759 selts->single_instance =
9760 xmlNewNode(NULL,
9761 (xmlChar *)"single_instance");
9762 if (selts->single_instance == NULL)
9763 uu_die(emsg_create_xml);
9764 }
9765
9766 continue;
9767 }
9768 } else if (strcmp(exp_str, SCF_PROPERTY_RESTARTER) == 0) {
9769 xmlNodePtr rnode, sfnode;
|