xref: /illumos-gate/usr/src/cmd/svr4pkg/libinst/setlist.c (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
1*5c51f124SMoriah Waterland /*
2*5c51f124SMoriah Waterland  * CDDL HEADER START
3*5c51f124SMoriah Waterland  *
4*5c51f124SMoriah Waterland  * The contents of this file are subject to the terms of the
5*5c51f124SMoriah Waterland  * Common Development and Distribution License (the "License").
6*5c51f124SMoriah Waterland  * You may not use this file except in compliance with the License.
7*5c51f124SMoriah Waterland  *
8*5c51f124SMoriah Waterland  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5c51f124SMoriah Waterland  * or http://www.opensolaris.org/os/licensing.
10*5c51f124SMoriah Waterland  * See the License for the specific language governing permissions
11*5c51f124SMoriah Waterland  * and limitations under the License.
12*5c51f124SMoriah Waterland  *
13*5c51f124SMoriah Waterland  * When distributing Covered Code, include this CDDL HEADER in each
14*5c51f124SMoriah Waterland  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5c51f124SMoriah Waterland  * If applicable, add the following below this CDDL HEADER, with the
16*5c51f124SMoriah Waterland  * fields enclosed by brackets "[]" replaced with your own identifying
17*5c51f124SMoriah Waterland  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5c51f124SMoriah Waterland  *
19*5c51f124SMoriah Waterland  * CDDL HEADER END
20*5c51f124SMoriah Waterland  */
21*5c51f124SMoriah Waterland 
22*5c51f124SMoriah Waterland /*
23*5c51f124SMoriah Waterland  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*5c51f124SMoriah Waterland  * Use is subject to license terms.
25*5c51f124SMoriah Waterland  */
26*5c51f124SMoriah Waterland 
27*5c51f124SMoriah Waterland /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*5c51f124SMoriah Waterland /* All Rights Reserved */
29*5c51f124SMoriah Waterland 
30*5c51f124SMoriah Waterland 
31*5c51f124SMoriah Waterland 
32*5c51f124SMoriah Waterland #include <stdio.h>
33*5c51f124SMoriah Waterland #include <errno.h>
34*5c51f124SMoriah Waterland #include <string.h>
35*5c51f124SMoriah Waterland #include <ctype.h>
36*5c51f124SMoriah Waterland #include <stdlib.h>
37*5c51f124SMoriah Waterland #include <unistd.h>
38*5c51f124SMoriah Waterland #include <locale.h>
39*5c51f124SMoriah Waterland #include <libintl.h>
40*5c51f124SMoriah Waterland #include <pkglocs.h>
41*5c51f124SMoriah Waterland #include <pkglib.h>
42*5c51f124SMoriah Waterland #include "libinst.h"
43*5c51f124SMoriah Waterland 
44*5c51f124SMoriah Waterland int	cl_NClasses = -1;
45*5c51f124SMoriah Waterland static int	cl_handle = -1;	/* list array handle */
46*5c51f124SMoriah Waterland 
47*5c51f124SMoriah Waterland struct cl_attr	**cl_Classes = NULL;
48*5c51f124SMoriah Waterland 
49*5c51f124SMoriah Waterland static int new_order;
50*5c51f124SMoriah Waterland static struct cl_attr	*new_cl_attr(char *cl_name);
51*5c51f124SMoriah Waterland 
52*5c51f124SMoriah Waterland static unsigned	s_verify(char *class_name), d_verify(char *class_name);
53*5c51f124SMoriah Waterland static unsigned	s_pathtype(char *class_name);
54*5c51f124SMoriah Waterland 
55*5c51f124SMoriah Waterland #define	MALSIZ	64
56*5c51f124SMoriah Waterland #define	ERR_MEMORY	"memory allocation failure"
57*5c51f124SMoriah Waterland 
58*5c51f124SMoriah Waterland static struct cl_attr *
new_cl_attr(char * cl_name)59*5c51f124SMoriah Waterland new_cl_attr(char *cl_name)
60*5c51f124SMoriah Waterland {
61*5c51f124SMoriah Waterland 	struct cl_attr *class, **class_ptr;
62*5c51f124SMoriah Waterland 
63*5c51f124SMoriah Waterland 	if (cl_handle == -1) {
64*5c51f124SMoriah Waterland 		cl_handle = ar_create(MALSIZ, sizeof (struct cl_attr),
65*5c51f124SMoriah Waterland 		    "package class");
66*5c51f124SMoriah Waterland 		if (cl_handle == -1) {
67*5c51f124SMoriah Waterland 			progerr(gettext(ERR_MEMORY));
68*5c51f124SMoriah Waterland 			return (NULL);
69*5c51f124SMoriah Waterland 		}
70*5c51f124SMoriah Waterland 	}
71*5c51f124SMoriah Waterland 
72*5c51f124SMoriah Waterland 	class_ptr = (struct cl_attr **)ar_next_avail(cl_handle);
73*5c51f124SMoriah Waterland 
74*5c51f124SMoriah Waterland 	if (class_ptr == NULL || *class_ptr == NULL) {
75*5c51f124SMoriah Waterland 		progerr(gettext(ERR_MEMORY));
76*5c51f124SMoriah Waterland 		return (NULL);
77*5c51f124SMoriah Waterland 	}
78*5c51f124SMoriah Waterland 
79*5c51f124SMoriah Waterland 	class = *class_ptr;
80*5c51f124SMoriah Waterland 
81*5c51f124SMoriah Waterland 	strcpy(class->name, cl_name);
82*5c51f124SMoriah Waterland 	class->inst_script = NULL;
83*5c51f124SMoriah Waterland 	class->rem_script = NULL;
84*5c51f124SMoriah Waterland 	class->src_verify = s_verify(cl_name);
85*5c51f124SMoriah Waterland 	class->dst_verify = d_verify(cl_name);
86*5c51f124SMoriah Waterland 	class->relpath_2_CAS = s_pathtype(cl_name);
87*5c51f124SMoriah Waterland 
88*5c51f124SMoriah Waterland 	return (class);
89*5c51f124SMoriah Waterland }
90*5c51f124SMoriah Waterland 
91*5c51f124SMoriah Waterland /* Insert a single class into the list. */
92*5c51f124SMoriah Waterland void
addlist(struct cl_attr *** listp,char * item)93*5c51f124SMoriah Waterland addlist(struct cl_attr ***listp, char *item)
94*5c51f124SMoriah Waterland {
95*5c51f124SMoriah Waterland 	int	i;
96*5c51f124SMoriah Waterland 
97*5c51f124SMoriah Waterland 	/* If the list is already there, scan for this item */
98*5c51f124SMoriah Waterland 	if (*listp) {
99*5c51f124SMoriah Waterland 		for (i = 0; (*listp)[i]; i++)
100*5c51f124SMoriah Waterland 			if (strcmp(item, (*listp)[i]->name) == 0)
101*5c51f124SMoriah Waterland 				return;
102*5c51f124SMoriah Waterland 	} else {
103*5c51f124SMoriah Waterland 		i = 0;
104*5c51f124SMoriah Waterland 	}
105*5c51f124SMoriah Waterland 
106*5c51f124SMoriah Waterland 	/* Insert the new entry */
107*5c51f124SMoriah Waterland 	if (new_cl_attr(item) == NULL)
108*5c51f124SMoriah Waterland 		quit(99);
109*5c51f124SMoriah Waterland 
110*5c51f124SMoriah Waterland 	/* Point the passed pointer to the head of the list. */
111*5c51f124SMoriah Waterland 	(*listp) = (struct cl_attr **)ar_get_head(cl_handle);
112*5c51f124SMoriah Waterland }
113*5c51f124SMoriah Waterland 
114*5c51f124SMoriah Waterland /*
115*5c51f124SMoriah Waterland  * Create a list of all classes involved in this installation as well as
116*5c51f124SMoriah Waterland  * their attributes.
117*5c51f124SMoriah Waterland  */
118*5c51f124SMoriah Waterland int
setlist(struct cl_attr *** plist,char * slist)119*5c51f124SMoriah Waterland setlist(struct cl_attr ***plist, char *slist)
120*5c51f124SMoriah Waterland {
121*5c51f124SMoriah Waterland 	struct cl_attr	**list, *struct_ptr;
122*5c51f124SMoriah Waterland 	char	*pt;
123*5c51f124SMoriah Waterland 	int	n;
124*5c51f124SMoriah Waterland 	int	i;
125*5c51f124SMoriah Waterland 	int	sn = -1;
126*5c51f124SMoriah Waterland 
127*5c51f124SMoriah Waterland 	/* Initialize the environment scanners. */
128*5c51f124SMoriah Waterland 	(void) s_verify(NULL);
129*5c51f124SMoriah Waterland 	(void) d_verify(NULL);
130*5c51f124SMoriah Waterland 	(void) s_pathtype(NULL);
131*5c51f124SMoriah Waterland 
132*5c51f124SMoriah Waterland 	n = 0;
133*5c51f124SMoriah Waterland 
134*5c51f124SMoriah Waterland 	/*
135*5c51f124SMoriah Waterland 	 * This looks like a serious memory leak, however pkgmk depends on
136*5c51f124SMoriah Waterland 	 * this creating a second list and forgetting any prior ones. The
137*5c51f124SMoriah Waterland 	 * pkgmk utility does a reasonable job of keeping track of a prior
138*5c51f124SMoriah Waterland 	 * list constructed from the prototype file using addlist() above.
139*5c51f124SMoriah Waterland 	 * Perhaps this should be reviewed later, but I do not believe this
140*5c51f124SMoriah Waterland 	 * to be a problem from what I've seen. - JST
141*5c51f124SMoriah Waterland 	 */
142*5c51f124SMoriah Waterland 	cl_handle = -1;		/* forget other lists */
143*5c51f124SMoriah Waterland 
144*5c51f124SMoriah Waterland 	/* Isolate the first token. */
145*5c51f124SMoriah Waterland 	pt = strtok(slist, " \t\n");
146*5c51f124SMoriah Waterland 	while (pt) {
147*5c51f124SMoriah Waterland 		if (sn == -1 && strcmp(pt, "none") == 0)
148*5c51f124SMoriah Waterland 			sn = n;
149*5c51f124SMoriah Waterland 
150*5c51f124SMoriah Waterland 		/* Add new class to list. */
151*5c51f124SMoriah Waterland 		if ((struct_ptr = new_cl_attr(pt)) == NULL)
152*5c51f124SMoriah Waterland 			quit(99);
153*5c51f124SMoriah Waterland 
154*5c51f124SMoriah Waterland 		/* Next token. */
155*5c51f124SMoriah Waterland 		n++;
156*5c51f124SMoriah Waterland 		pt = strtok(NULL, " \t\n");
157*5c51f124SMoriah Waterland 		if (pt && sn != -1)
158*5c51f124SMoriah Waterland 			if (strcmp(pt, "none") == 0)
159*5c51f124SMoriah Waterland 				pt = strtok(NULL, " \t\n");
160*5c51f124SMoriah Waterland 	}
161*5c51f124SMoriah Waterland 	/*
162*5c51f124SMoriah Waterland 	 * According to the ABI, if there is a class "none", it will be
163*5c51f124SMoriah Waterland 	 * the first class to be installed.  This insures that iff there
164*5c51f124SMoriah Waterland 	 * is a class "none", it will be the first to be installed.
165*5c51f124SMoriah Waterland 	 * If there is no class "none", nothing happens!
166*5c51f124SMoriah Waterland 	 */
167*5c51f124SMoriah Waterland 	new_order = 0;
168*5c51f124SMoriah Waterland 
169*5c51f124SMoriah Waterland 	/* Get the head of the array. */
170*5c51f124SMoriah Waterland 	list = (struct cl_attr **)ar_get_head(cl_handle);
171*5c51f124SMoriah Waterland 
172*5c51f124SMoriah Waterland 	if (sn > 0) {
173*5c51f124SMoriah Waterland 		struct_ptr = list[sn];
174*5c51f124SMoriah Waterland 		for (i = sn; i > 0; i--)
175*5c51f124SMoriah Waterland 			list[i] = list[i - 1];
176*5c51f124SMoriah Waterland 		list[0] = struct_ptr;
177*5c51f124SMoriah Waterland 		new_order++;	/* the order is different now */
178*5c51f124SMoriah Waterland 	}
179*5c51f124SMoriah Waterland 
180*5c51f124SMoriah Waterland 	/* Point the passed pointer to the head of the list. */
181*5c51f124SMoriah Waterland 	*plist = list;
182*5c51f124SMoriah Waterland 
183*5c51f124SMoriah Waterland 	return (n);
184*5c51f124SMoriah Waterland }
185*5c51f124SMoriah Waterland 
186*5c51f124SMoriah Waterland /* Process the class list from the caller. */
187*5c51f124SMoriah Waterland void
cl_sets(char * slist)188*5c51f124SMoriah Waterland cl_sets(char *slist)
189*5c51f124SMoriah Waterland {
190*5c51f124SMoriah Waterland 	char *list_ptr;
191*5c51f124SMoriah Waterland 
192*5c51f124SMoriah Waterland 	/* If there is a list, process it; else skip it */
193*5c51f124SMoriah Waterland 	if (slist && *slist) {
194*5c51f124SMoriah Waterland 		list_ptr = qstrdup(slist);
195*5c51f124SMoriah Waterland 
196*5c51f124SMoriah Waterland 		if (list_ptr && *list_ptr) {
197*5c51f124SMoriah Waterland 			cl_NClasses = setlist(&cl_Classes, list_ptr);
198*5c51f124SMoriah Waterland 			if (new_order)		/* if list order changed ... */
199*5c51f124SMoriah Waterland 				/* ... tell the environment. */
200*5c51f124SMoriah Waterland 				cl_putl("CLASSES", cl_Classes);
201*5c51f124SMoriah Waterland 		}
202*5c51f124SMoriah Waterland 	}
203*5c51f124SMoriah Waterland }
204*5c51f124SMoriah Waterland 
205*5c51f124SMoriah Waterland int
cl_getn(void)206*5c51f124SMoriah Waterland cl_getn(void)
207*5c51f124SMoriah Waterland {
208*5c51f124SMoriah Waterland 	return (cl_NClasses);
209*5c51f124SMoriah Waterland }
210*5c51f124SMoriah Waterland 
211*5c51f124SMoriah Waterland /*
212*5c51f124SMoriah Waterland  * Since the order may have changed, this puts the CLASSES list back into
213*5c51f124SMoriah Waterland  * the environment in the precise order to be used.
214*5c51f124SMoriah Waterland  */
215*5c51f124SMoriah Waterland void
cl_putl(char * parm_name,struct cl_attr ** list)216*5c51f124SMoriah Waterland cl_putl(char *parm_name, struct cl_attr **list)
217*5c51f124SMoriah Waterland {
218*5c51f124SMoriah Waterland 	int i;
219*5c51f124SMoriah Waterland 	size_t j;
220*5c51f124SMoriah Waterland 	char *pt = NULL;
221*5c51f124SMoriah Waterland 
222*5c51f124SMoriah Waterland 	if (list && *list) {
223*5c51f124SMoriah Waterland 		j = 1; /* room for ending null */
224*5c51f124SMoriah Waterland 		for (i = 0; list[i]; i++)
225*5c51f124SMoriah Waterland 			j += strlen(list[i]->name) + 1;
226*5c51f124SMoriah Waterland 		pt = calloc(j, sizeof (char));
227*5c51f124SMoriah Waterland 		(void) strcpy(pt, list[0]->name);
228*5c51f124SMoriah Waterland 		for (i = 1; list[i]; i++) {
229*5c51f124SMoriah Waterland 			(void) strcat(pt, " ");
230*5c51f124SMoriah Waterland 			(void) strcat(pt, list[i]->name);
231*5c51f124SMoriah Waterland 		}
232*5c51f124SMoriah Waterland 		if (parm_name && *parm_name)
233*5c51f124SMoriah Waterland 			putparam(parm_name, pt);
234*5c51f124SMoriah Waterland 		free(pt);
235*5c51f124SMoriah Waterland 	}
236*5c51f124SMoriah Waterland }
237*5c51f124SMoriah Waterland 
238*5c51f124SMoriah Waterland 
239*5c51f124SMoriah Waterland int
cl_idx(char * cl_nam)240*5c51f124SMoriah Waterland cl_idx(char *cl_nam)
241*5c51f124SMoriah Waterland {
242*5c51f124SMoriah Waterland 	int	n;
243*5c51f124SMoriah Waterland 
244*5c51f124SMoriah Waterland 	for (n = 0; n < cl_NClasses; n++)
245*5c51f124SMoriah Waterland 		if (strcmp(cl_Classes[n]->name, cl_nam) == 0)
246*5c51f124SMoriah Waterland 			return (n);
247*5c51f124SMoriah Waterland 	return (-1);
248*5c51f124SMoriah Waterland }
249*5c51f124SMoriah Waterland 
250*5c51f124SMoriah Waterland /* Return source verification level for this class */
251*5c51f124SMoriah Waterland unsigned
cl_svfy(int idx)252*5c51f124SMoriah Waterland cl_svfy(int idx)
253*5c51f124SMoriah Waterland {
254*5c51f124SMoriah Waterland 	if (cl_Classes && idx >= 0 && idx < cl_NClasses)
255*5c51f124SMoriah Waterland 		return (cl_Classes[idx]->src_verify);
256*5c51f124SMoriah Waterland 	return (0);
257*5c51f124SMoriah Waterland }
258*5c51f124SMoriah Waterland 
259*5c51f124SMoriah Waterland /* Return destination verify level for this class */
260*5c51f124SMoriah Waterland unsigned
cl_dvfy(int idx)261*5c51f124SMoriah Waterland cl_dvfy(int idx)
262*5c51f124SMoriah Waterland {
263*5c51f124SMoriah Waterland 	if (cl_Classes && idx >= 0 && idx < cl_NClasses)
264*5c51f124SMoriah Waterland 		return (cl_Classes[idx]->dst_verify);
265*5c51f124SMoriah Waterland 	return (0);
266*5c51f124SMoriah Waterland }
267*5c51f124SMoriah Waterland 
268*5c51f124SMoriah Waterland /* Return path argument type for this class. */
269*5c51f124SMoriah Waterland unsigned
cl_pthrel(int idx)270*5c51f124SMoriah Waterland cl_pthrel(int idx)
271*5c51f124SMoriah Waterland {
272*5c51f124SMoriah Waterland 	if (cl_Classes && idx >= 0 && idx < cl_NClasses)
273*5c51f124SMoriah Waterland 		return (cl_Classes[idx]->relpath_2_CAS);
274*5c51f124SMoriah Waterland 	return (0);
275*5c51f124SMoriah Waterland }
276*5c51f124SMoriah Waterland 
277*5c51f124SMoriah Waterland /* Return the class name associated with this class index */
278*5c51f124SMoriah Waterland char *
cl_nam(int idx)279*5c51f124SMoriah Waterland cl_nam(int idx)
280*5c51f124SMoriah Waterland {
281*5c51f124SMoriah Waterland 	if (cl_Classes && idx >= 0 && idx < cl_NClasses)
282*5c51f124SMoriah Waterland 		return (cl_Classes[idx]->name);
283*5c51f124SMoriah Waterland 	return (NULL);
284*5c51f124SMoriah Waterland }
285*5c51f124SMoriah Waterland 
286*5c51f124SMoriah Waterland void
cl_setl(struct cl_attr ** cl_lst)287*5c51f124SMoriah Waterland cl_setl(struct cl_attr **cl_lst)
288*5c51f124SMoriah Waterland {
289*5c51f124SMoriah Waterland 	int	i;
290*5c51f124SMoriah Waterland 	int	sn = -1;
291*5c51f124SMoriah Waterland 	struct cl_attr	*pt;
292*5c51f124SMoriah Waterland 
293*5c51f124SMoriah Waterland 	if (cl_lst) {
294*5c51f124SMoriah Waterland 		for (cl_NClasses = 0; cl_lst[cl_NClasses]; cl_NClasses++)
295*5c51f124SMoriah Waterland 			if (strcmp(cl_lst[cl_NClasses]->name, "none") == 0)
296*5c51f124SMoriah Waterland 				if (sn == -1)
297*5c51f124SMoriah Waterland 					sn = cl_NClasses;
298*5c51f124SMoriah Waterland 		if (sn > 0) {
299*5c51f124SMoriah Waterland 			pt = cl_lst[sn];
300*5c51f124SMoriah Waterland 			for (i = sn; i > 0; i--)
301*5c51f124SMoriah Waterland 				cl_lst[i] = cl_lst[i - 1];
302*5c51f124SMoriah Waterland 			cl_lst[0] = pt;
303*5c51f124SMoriah Waterland 		}
304*5c51f124SMoriah Waterland 		i = 1;
305*5c51f124SMoriah Waterland 		while (i < cl_NClasses) {
306*5c51f124SMoriah Waterland 			if (strcmp(cl_lst[i]->name, "none") == 0)
307*5c51f124SMoriah Waterland 				for (sn = i; sn < (cl_NClasses - 1); sn++)
308*5c51f124SMoriah Waterland 					cl_lst[sn] = cl_lst[sn + 1];
309*5c51f124SMoriah Waterland 			i++;
310*5c51f124SMoriah Waterland 		}
311*5c51f124SMoriah Waterland 		cl_Classes = cl_lst;
312*5c51f124SMoriah Waterland 	} else {
313*5c51f124SMoriah Waterland 		cl_Classes = NULL;
314*5c51f124SMoriah Waterland 		cl_NClasses = -1;
315*5c51f124SMoriah Waterland 	}
316*5c51f124SMoriah Waterland }
317*5c51f124SMoriah Waterland 
318*5c51f124SMoriah Waterland /*
319*5c51f124SMoriah Waterland  * Scan the given environment variable for an occurrance of the given
320*5c51f124SMoriah Waterland  * class name. Return 0 if not found or 1 if found.
321*5c51f124SMoriah Waterland  */
322*5c51f124SMoriah Waterland static unsigned
is_in_env(char * class_name,char * paramname,char ** paramvalue,int * noentry)323*5c51f124SMoriah Waterland is_in_env(char *class_name, char *paramname, char **paramvalue, int *noentry)
324*5c51f124SMoriah Waterland {
325*5c51f124SMoriah Waterland 	unsigned retval = 0;
326*5c51f124SMoriah Waterland 	char *test_class;
327*5c51f124SMoriah Waterland 
328*5c51f124SMoriah Waterland 	if (class_name && *class_name) {
329*5c51f124SMoriah Waterland 		/*
330*5c51f124SMoriah Waterland 		 * If a prior getenv() has not failed and there is no
331*5c51f124SMoriah Waterland 		 * environment string then get environment info on
332*5c51f124SMoriah Waterland 		 * this parameter.
333*5c51f124SMoriah Waterland 		 */
334*5c51f124SMoriah Waterland 		if (!(*noentry) && *paramvalue == NULL) {
335*5c51f124SMoriah Waterland 			*paramvalue = getenv(paramname);
336*5c51f124SMoriah Waterland 			if (*paramvalue == NULL)
337*5c51f124SMoriah Waterland 				(*noentry)++;
338*5c51f124SMoriah Waterland 		}
339*5c51f124SMoriah Waterland 
340*5c51f124SMoriah Waterland 		/* If there's something there, evaluate it. */
341*5c51f124SMoriah Waterland 		if (!(*noentry)) {
342*5c51f124SMoriah Waterland 			int n;
343*5c51f124SMoriah Waterland 
344*5c51f124SMoriah Waterland 			n = strlen(class_name);	/* end of class name */
345*5c51f124SMoriah Waterland 			test_class = *paramvalue;	/* environ ptr */
346*5c51f124SMoriah Waterland 
347*5c51f124SMoriah Waterland 			while (test_class = strstr(test_class, class_name)) {
348*5c51f124SMoriah Waterland 				/*
349*5c51f124SMoriah Waterland 				 * At this point we have a pointer to a
350*5c51f124SMoriah Waterland 				 * substring within param that matches
351*5c51f124SMoriah Waterland 				 * class_name for its length, but class_name
352*5c51f124SMoriah Waterland 				 * may be a substring of the test_class, so
353*5c51f124SMoriah Waterland 				 * we check that next.
354*5c51f124SMoriah Waterland 				 */
355*5c51f124SMoriah Waterland 				if (isspace(*(test_class + n)) ||
356*5c51f124SMoriah Waterland 				    *(test_class + n) == '\0') {
357*5c51f124SMoriah Waterland 					retval = 1;
358*5c51f124SMoriah Waterland 					break;
359*5c51f124SMoriah Waterland 				}
360*5c51f124SMoriah Waterland 				if (*(++test_class) == '\0')
361*5c51f124SMoriah Waterland 					break;
362*5c51f124SMoriah Waterland 			}
363*5c51f124SMoriah Waterland 		}
364*5c51f124SMoriah Waterland 	}
365*5c51f124SMoriah Waterland 	return (retval);
366*5c51f124SMoriah Waterland }
367*5c51f124SMoriah Waterland 
368*5c51f124SMoriah Waterland /* Assign source path verification level to this class */
369*5c51f124SMoriah Waterland static unsigned
s_verify(char * class_name)370*5c51f124SMoriah Waterland s_verify(char *class_name)
371*5c51f124SMoriah Waterland {
372*5c51f124SMoriah Waterland 	static int noentry;
373*5c51f124SMoriah Waterland 	static char *noverify;
374*5c51f124SMoriah Waterland 
375*5c51f124SMoriah Waterland 	if (class_name == NULL) {	/* initialize */
376*5c51f124SMoriah Waterland 		noentry = 0;
377*5c51f124SMoriah Waterland 		noverify = NULL;
378*5c51f124SMoriah Waterland 	} else {
379*5c51f124SMoriah Waterland 		if (is_in_env(class_name, "PKG_SRC_NOVERIFY", &noverify,
380*5c51f124SMoriah Waterland 		    &noentry))
381*5c51f124SMoriah Waterland 			return (NOVERIFY);
382*5c51f124SMoriah Waterland 		else
383*5c51f124SMoriah Waterland 			return (DEFAULT);
384*5c51f124SMoriah Waterland 	}
385*5c51f124SMoriah Waterland 	return (0);
386*5c51f124SMoriah Waterland }
387*5c51f124SMoriah Waterland 
388*5c51f124SMoriah Waterland /*
389*5c51f124SMoriah Waterland  * Set destination verify to default. This is usually called by pkgdbmerg()
390*5c51f124SMoriah Waterland  * in order to correct verification conflicts.
391*5c51f124SMoriah Waterland  */
392*5c51f124SMoriah Waterland void
cl_def_dverify(int idx)393*5c51f124SMoriah Waterland cl_def_dverify(int idx)
394*5c51f124SMoriah Waterland {
395*5c51f124SMoriah Waterland 	if (cl_Classes && idx >= 0 && idx < cl_NClasses)
396*5c51f124SMoriah Waterland 		cl_Classes[idx]->dst_verify = DEFAULT;
397*5c51f124SMoriah Waterland }
398*5c51f124SMoriah Waterland 
399*5c51f124SMoriah Waterland /* Assign destination path verification level to this path. */
400*5c51f124SMoriah Waterland static unsigned
d_verify(char * class_name)401*5c51f124SMoriah Waterland d_verify(char *class_name)
402*5c51f124SMoriah Waterland {
403*5c51f124SMoriah Waterland 	static int noentry;
404*5c51f124SMoriah Waterland 	static char *qkverify;
405*5c51f124SMoriah Waterland 
406*5c51f124SMoriah Waterland 	if (class_name == NULL) {	/* initialize */
407*5c51f124SMoriah Waterland 		noentry = 0;
408*5c51f124SMoriah Waterland 		qkverify = NULL;
409*5c51f124SMoriah Waterland 	} else {
410*5c51f124SMoriah Waterland 		if (is_in_env(class_name, "PKG_DST_QKVERIFY", &qkverify,
411*5c51f124SMoriah Waterland 		    &noentry))
412*5c51f124SMoriah Waterland 			return (QKVERIFY);
413*5c51f124SMoriah Waterland 		else
414*5c51f124SMoriah Waterland 			return (DEFAULT);
415*5c51f124SMoriah Waterland 	}
416*5c51f124SMoriah Waterland 	return (0);
417*5c51f124SMoriah Waterland }
418*5c51f124SMoriah Waterland 
419*5c51f124SMoriah Waterland /* Assign CAS path type to this class */
420*5c51f124SMoriah Waterland static unsigned
s_pathtype(char * class_name)421*5c51f124SMoriah Waterland s_pathtype(char *class_name)
422*5c51f124SMoriah Waterland {
423*5c51f124SMoriah Waterland 	static int noentry;
424*5c51f124SMoriah Waterland 	static char *type_list;
425*5c51f124SMoriah Waterland 
426*5c51f124SMoriah Waterland 	if (class_name == NULL) {	/* initialize */
427*5c51f124SMoriah Waterland 		noentry = 0;
428*5c51f124SMoriah Waterland 		type_list = NULL;
429*5c51f124SMoriah Waterland 	} else {
430*5c51f124SMoriah Waterland 		if (is_in_env(class_name, "PKG_CAS_PASSRELATIVE", &type_list,
431*5c51f124SMoriah Waterland 		    &noentry))
432*5c51f124SMoriah Waterland 			return (REL_2_CAS);
433*5c51f124SMoriah Waterland 		else
434*5c51f124SMoriah Waterland 			return (DEFAULT);
435*5c51f124SMoriah Waterland 	}
436*5c51f124SMoriah Waterland 	return (0);
437*5c51f124SMoriah Waterland }
438