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]
23 * Copyright (c) 2017 Peter Tribble.
27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
50 #define DEFMAIL "root"
52 extern struct admin adm
; /* holds info about install admin */
53 extern int warnflag
; /* != 0 non-fatal error occurred 2 */
59 &adm
.action
, "action",
60 &adm
.basedir
, "basedir",
61 &adm
.conflict
, "conflict",
62 &adm
.idepend
, "idepend",
63 &adm
.instance
, "instance",
65 &adm
.partial
, "partial",
66 &adm
.rdepend
, "rdepend",
67 &adm
.RSCRIPTALT
, RSCRIPTALT_KEYWORD
,
68 &adm
.runlevel
, "runlevel",
69 &adm
.setuid
, "setuid",
71 /* MUST BE LAST ENTRY IN LIST */
72 (char **)NULL
, (char *)NULL
76 * Name: setadminSetting
77 * Description: set one administration parameter setting
78 * Arguments: a_paramName - pointer to string representing the name of
79 * the administration parameter to set
80 * a_paramValue - pointer to string representing the value
81 * to set the specified administration parameter to
83 * - old value the parameter had before being set
84 * == NULL - the old paramter was not set
88 setadminSetting(char *a_paramName
, char *a_paramValue
)
90 char *oldValue
= (char *)NULL
;
93 /* locate and update the specified admin setting */
95 for (i
= 0; admlist
[i
].memloc
; i
++) {
96 if (strcmp(a_paramName
, admlist
[i
].tag
) == 0) {
97 oldValue
= *admlist
[i
].memloc
;
98 *admlist
[i
].memloc
= a_paramValue
;
103 if (admlist
[i
].memloc
== (char **)NULL
) {
104 logerr(WRN_UNKNOWN_ADM_PARAM
, a_paramName
);
112 * Description: read and remember settings from administration file
113 * Arguments: file - pointer to string representing the path to the
114 * administration file to read - if this is NULL
115 * then the name "default" is used - if this is
116 * the string "none" then the admin "basedir"
117 * setting is set to "ask" so that the location
118 * of the administration file will be interactively
119 * asked at the appropriate time
124 setadminFile(char *file
)
128 char param
[MAX_PKG_PARAM_LENGTH
];
135 else if (strcmp(file
, "none") == 0) {
141 (void) strcpy(path
, file
);
143 (void) snprintf(path
, sizeof (path
), "%s/admin/%s",
145 if (access(path
, R_OK
)) {
146 (void) snprintf(path
, sizeof (path
), "%s/admin/%s",
151 if ((fp
= fopen(path
, "r")) == NULL
) {
152 progerr(ERR_OPEN_ADMIN_FILE
, file
, strerror(errno
));
157 while (value
= fpkgparam(fp
, param
)) {
158 if (strcmp(param
, "mail") == 0) {
161 if (value
[0] == '\0') {
163 continue; /* same as not being set at all */
165 for (i
= 0; admlist
[i
].memloc
; i
++) {
166 if (strcmp(param
, admlist
[i
].tag
) == 0) {
167 *admlist
[i
].memloc
= value
;
171 if (admlist
[i
].memloc
== NULL
) {
172 logerr(WRN_UNKNOWN_ADM_PARAM
, param
);
181 adm
.mail
= DEFMAIL
; /* if we don't assign anything to it */