1*9781SMoriah.Waterland@Sun.COM /*
2*9781SMoriah.Waterland@Sun.COM * CDDL HEADER START
3*9781SMoriah.Waterland@Sun.COM *
4*9781SMoriah.Waterland@Sun.COM * The contents of this file are subject to the terms of the
5*9781SMoriah.Waterland@Sun.COM * Common Development and Distribution License (the "License").
6*9781SMoriah.Waterland@Sun.COM * You may not use this file except in compliance with the License.
7*9781SMoriah.Waterland@Sun.COM *
8*9781SMoriah.Waterland@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9781SMoriah.Waterland@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*9781SMoriah.Waterland@Sun.COM * See the License for the specific language governing permissions
11*9781SMoriah.Waterland@Sun.COM * and limitations under the License.
12*9781SMoriah.Waterland@Sun.COM *
13*9781SMoriah.Waterland@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*9781SMoriah.Waterland@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9781SMoriah.Waterland@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*9781SMoriah.Waterland@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*9781SMoriah.Waterland@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*9781SMoriah.Waterland@Sun.COM *
19*9781SMoriah.Waterland@Sun.COM * CDDL HEADER END
20*9781SMoriah.Waterland@Sun.COM */
21*9781SMoriah.Waterland@Sun.COM
22*9781SMoriah.Waterland@Sun.COM /*
23*9781SMoriah.Waterland@Sun.COM * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24*9781SMoriah.Waterland@Sun.COM * Use is subject to license terms.
25*9781SMoriah.Waterland@Sun.COM */
26*9781SMoriah.Waterland@Sun.COM
27*9781SMoriah.Waterland@Sun.COM /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*9781SMoriah.Waterland@Sun.COM /* All Rights Reserved */
29*9781SMoriah.Waterland@Sun.COM
30*9781SMoriah.Waterland@Sun.COM
31*9781SMoriah.Waterland@Sun.COM #include <stdio.h>
32*9781SMoriah.Waterland@Sun.COM #include <limits.h>
33*9781SMoriah.Waterland@Sun.COM #include <string.h>
34*9781SMoriah.Waterland@Sun.COM #include <stdlib.h>
35*9781SMoriah.Waterland@Sun.COM #include <sys/stat.h> /* mkdir declaration is here? */
36*9781SMoriah.Waterland@Sun.COM #include <unistd.h>
37*9781SMoriah.Waterland@Sun.COM #include <errno.h>
38*9781SMoriah.Waterland@Sun.COM #include <utmpx.h>
39*9781SMoriah.Waterland@Sun.COM #include <dirent.h>
40*9781SMoriah.Waterland@Sun.COM #include <sys/types.h>
41*9781SMoriah.Waterland@Sun.COM #include <locale.h>
42*9781SMoriah.Waterland@Sun.COM #include <libintl.h>
43*9781SMoriah.Waterland@Sun.COM #include <pkgstrct.h>
44*9781SMoriah.Waterland@Sun.COM #include <pkglocs.h>
45*9781SMoriah.Waterland@Sun.COM #include "install.h"
46*9781SMoriah.Waterland@Sun.COM #include <pkglib.h>
47*9781SMoriah.Waterland@Sun.COM #include "libadm.h"
48*9781SMoriah.Waterland@Sun.COM #include "libinst.h"
49*9781SMoriah.Waterland@Sun.COM #include "pkginstall.h"
50*9781SMoriah.Waterland@Sun.COM
51*9781SMoriah.Waterland@Sun.COM extern struct admin adm;
52*9781SMoriah.Waterland@Sun.COM extern struct cfextra **extlist;
53*9781SMoriah.Waterland@Sun.COM extern int ckquit, nocnflct, nosetuid, rprcflag;
54*9781SMoriah.Waterland@Sun.COM extern char ilockfile[], rlockfile[], instdir[], savlog[],
55*9781SMoriah.Waterland@Sun.COM tmpdir[], pkgloc[], pkgloc_sav[], pkgbin[], pkgsav[],
56*9781SMoriah.Waterland@Sun.COM *pkginst, *msgtext;
57*9781SMoriah.Waterland@Sun.COM extern char saveSpoolInstallDir[];
58*9781SMoriah.Waterland@Sun.COM
59*9781SMoriah.Waterland@Sun.COM static boolean_t preinstallCheck = B_FALSE;
60*9781SMoriah.Waterland@Sun.COM static char *zoneName = (char *)NULL;
61*9781SMoriah.Waterland@Sun.COM
62*9781SMoriah.Waterland@Sun.COM static char ask_cont[100];
63*9781SMoriah.Waterland@Sun.COM
64*9781SMoriah.Waterland@Sun.COM #define DISPSIZ 20 /* number of items to display on one page */
65*9781SMoriah.Waterland@Sun.COM
66*9781SMoriah.Waterland@Sun.COM #define MSG_RUNLEVEL "\\nThe current run-level of this machine is <%s>, " \
67*9781SMoriah.Waterland@Sun.COM "which is not a run-level suggested for installation " \
68*9781SMoriah.Waterland@Sun.COM "of this package. Suggested run-levels (in order of " \
69*9781SMoriah.Waterland@Sun.COM "preference) include:"
70*9781SMoriah.Waterland@Sun.COM #define HLP_RUNLEVEL "If this package is not installed in a run-level " \
71*9781SMoriah.Waterland@Sun.COM "which has been suggested, it is possible that the " \
72*9781SMoriah.Waterland@Sun.COM "package may not install or operate properly. If " \
73*9781SMoriah.Waterland@Sun.COM "you wish to follow the run-level suggestions, " \
74*9781SMoriah.Waterland@Sun.COM "answer 'n' to stop installation of the package."
75*9781SMoriah.Waterland@Sun.COM #define MSG_STATECHG "\\nTo change states, execute\\n\\tshutdown -y " \
76*9781SMoriah.Waterland@Sun.COM "-i%s -g0\\nafter exiting the installation process. " \
77*9781SMoriah.Waterland@Sun.COM "Please note that after changing states you " \
78*9781SMoriah.Waterland@Sun.COM "may have to mount appropriate filesystem(s) " \
79*9781SMoriah.Waterland@Sun.COM "in order to install this package."
80*9781SMoriah.Waterland@Sun.COM
81*9781SMoriah.Waterland@Sun.COM #define ASK_CONFLICT "Do you want to install these conflicting files"
82*9781SMoriah.Waterland@Sun.COM #define MSG_CONFLICT "\\nThe following files are already installed on the " \
83*9781SMoriah.Waterland@Sun.COM "system and are being used by another package:"
84*9781SMoriah.Waterland@Sun.COM #define MSG_ROGUE "\\n* - conflict with a file which does not " \
85*9781SMoriah.Waterland@Sun.COM "belong to any package."
86*9781SMoriah.Waterland@Sun.COM #define HLP_CONFLICT "If you choose to install conflicting files, the " \
87*9781SMoriah.Waterland@Sun.COM "files listed above will be overwritten and/or have " \
88*9781SMoriah.Waterland@Sun.COM "their access permissions changed. If you choose " \
89*9781SMoriah.Waterland@Sun.COM "not to install these files, installation will " \
90*9781SMoriah.Waterland@Sun.COM "proceed but these specific files will not be " \
91*9781SMoriah.Waterland@Sun.COM "installed. Note that sane operation of the " \
92*9781SMoriah.Waterland@Sun.COM "software being installed may require these files " \
93*9781SMoriah.Waterland@Sun.COM "be installed; thus choosing to not to do so may " \
94*9781SMoriah.Waterland@Sun.COM "cause inapropriate operation. If you wish to stop " \
95*9781SMoriah.Waterland@Sun.COM "installation of this package, enter 'q' to quit."
96*9781SMoriah.Waterland@Sun.COM
97*9781SMoriah.Waterland@Sun.COM #define ASK_SETUID "Do you want to install these as setuid/setgid files"
98*9781SMoriah.Waterland@Sun.COM #define MSG_SETUID "\\nThe following files are being installed with " \
99*9781SMoriah.Waterland@Sun.COM "setuid and/or setgid permissions:"
100*9781SMoriah.Waterland@Sun.COM #define MSG_OVERWR "\\n* - overwriting a file which is also " \
101*9781SMoriah.Waterland@Sun.COM "setuid/setgid."
102*9781SMoriah.Waterland@Sun.COM #define HLP_SETUID "The package being installed appears to contain " \
103*9781SMoriah.Waterland@Sun.COM "processes which will have their effective user or " \
104*9781SMoriah.Waterland@Sun.COM "group ids set upon execution. History has shown " \
105*9781SMoriah.Waterland@Sun.COM "that these types of processes can be a source of " \
106*9781SMoriah.Waterland@Sun.COM "security problems on your system. If you choose " \
107*9781SMoriah.Waterland@Sun.COM "not to install these as setuid files, installation " \
108*9781SMoriah.Waterland@Sun.COM "will proceed but these specific files will be " \
109*9781SMoriah.Waterland@Sun.COM "installed as regular files with setuid and/or " \
110*9781SMoriah.Waterland@Sun.COM "setgid permissions reset. Note that sane " \
111*9781SMoriah.Waterland@Sun.COM "operation of the software being installed may " \
112*9781SMoriah.Waterland@Sun.COM "require that these files be installed with setuid " \
113*9781SMoriah.Waterland@Sun.COM "or setgid permissions as delivered; thus choosing " \
114*9781SMoriah.Waterland@Sun.COM "to install them as regular files may cause " \
115*9781SMoriah.Waterland@Sun.COM "inapropriate operation. If you wish to stop " \
116*9781SMoriah.Waterland@Sun.COM "installation of this package, enter 'q' to quit."
117*9781SMoriah.Waterland@Sun.COM #define MSG_PARTINST "\\nThe installation of this package was previously " \
118*9781SMoriah.Waterland@Sun.COM "terminated and installation was never successfully " \
119*9781SMoriah.Waterland@Sun.COM "completed."
120*9781SMoriah.Waterland@Sun.COM #define MSG_PARTREM "\\nThe removal of this package was terminated at " \
121*9781SMoriah.Waterland@Sun.COM "some point in time, and package removal was only " \
122*9781SMoriah.Waterland@Sun.COM "partially completed."
123*9781SMoriah.Waterland@Sun.COM #define HLP_PARTIAL "Installation of partially installed packages is " \
124*9781SMoriah.Waterland@Sun.COM "normally allowable, but some packages providers " \
125*9781SMoriah.Waterland@Sun.COM "may suggest that a partially installed package be " \
126*9781SMoriah.Waterland@Sun.COM "completely removed before re-attempting " \
127*9781SMoriah.Waterland@Sun.COM "installation. Check the documentation provided " \
128*9781SMoriah.Waterland@Sun.COM "with this package, and then answer 'y' if you feel " \
129*9781SMoriah.Waterland@Sun.COM "it is advisable to continue the installation process."
130*9781SMoriah.Waterland@Sun.COM
131*9781SMoriah.Waterland@Sun.COM #define HLP_SPACE "It appears that there is not enough free space on " \
132*9781SMoriah.Waterland@Sun.COM "your system in which to install this package. It " \
133*9781SMoriah.Waterland@Sun.COM "is possible that one or more filesystems are not " \
134*9781SMoriah.Waterland@Sun.COM "properly mounted. Neither installation of the " \
135*9781SMoriah.Waterland@Sun.COM "package nor its operation can be guaranteed under " \
136*9781SMoriah.Waterland@Sun.COM "these conditions. If you choose to disregard this " \
137*9781SMoriah.Waterland@Sun.COM "warning, enter 'y' to continue the installation " \
138*9781SMoriah.Waterland@Sun.COM "process."
139*9781SMoriah.Waterland@Sun.COM #define HLP_DEPEND "The package being installed has indicated a " \
140*9781SMoriah.Waterland@Sun.COM "dependency on the existence (or non-existence) " \
141*9781SMoriah.Waterland@Sun.COM "of another software package. If this dependency is " \
142*9781SMoriah.Waterland@Sun.COM "not met before continuing, the package may not " \
143*9781SMoriah.Waterland@Sun.COM "install or operate properly. If you wish to " \
144*9781SMoriah.Waterland@Sun.COM "disregard this dependency, answer 'y' to continue " \
145*9781SMoriah.Waterland@Sun.COM "the installation process."
146*9781SMoriah.Waterland@Sun.COM
147*9781SMoriah.Waterland@Sun.COM #define MSG_PRIV "\\nThis package contains scripts which will be " \
148*9781SMoriah.Waterland@Sun.COM "executed with super-user permission during the " \
149*9781SMoriah.Waterland@Sun.COM "process of installing this package."
150*9781SMoriah.Waterland@Sun.COM #define HLP_PRIV "During the installation of this package, certain " \
151*9781SMoriah.Waterland@Sun.COM "scripts provided with the package will execute with " \
152*9781SMoriah.Waterland@Sun.COM "super-user permission. These scripts may modify or " \
153*9781SMoriah.Waterland@Sun.COM "otherwise change your system without your " \
154*9781SMoriah.Waterland@Sun.COM "knowledge. If you are certain of the origin and " \
155*9781SMoriah.Waterland@Sun.COM "trustworthiness of the package being installed, " \
156*9781SMoriah.Waterland@Sun.COM "answer 'y' to continue the installation process."
157*9781SMoriah.Waterland@Sun.COM
158*9781SMoriah.Waterland@Sun.COM #define ASK_CONT "Do you want to continue with the installation of <%s>"
159*9781SMoriah.Waterland@Sun.COM #define HLP_CONT "If you choose 'y', installation of this package " \
160*9781SMoriah.Waterland@Sun.COM "will continue. If you want to stop installation " \
161*9781SMoriah.Waterland@Sun.COM "of this package, choose 'n'."
162*9781SMoriah.Waterland@Sun.COM
163*9781SMoriah.Waterland@Sun.COM #define MSG_MKPKGDIR "unable to make packaging directory <%s>"
164*9781SMoriah.Waterland@Sun.COM
165*9781SMoriah.Waterland@Sun.COM #define MSG_CKCONFL_GZ "## Checking for conflicts with packages already " \
166*9781SMoriah.Waterland@Sun.COM "installed."
167*9781SMoriah.Waterland@Sun.COM #define MSG_CKCONFL_LZ "## Checking for conflicts with packages already " \
168*9781SMoriah.Waterland@Sun.COM "installed in zone <%s>."
169*9781SMoriah.Waterland@Sun.COM #define MSG_CKDEPEND_GZ "## Verifying package dependencies."
170*9781SMoriah.Waterland@Sun.COM #define MSG_CKDEPEND_LZ "## Verifying package dependencies in zone <%s>."
171*9781SMoriah.Waterland@Sun.COM #define MSG_CKSPACE_GZ "## Verifying disk space requirements."
172*9781SMoriah.Waterland@Sun.COM #define MSG_CKSPACE_LZ "## Verifying disk space requirements in zone <%s>."
173*9781SMoriah.Waterland@Sun.COM #define MSG_CKUID_GZ "## Checking for setuid/setgid programs."
174*9781SMoriah.Waterland@Sun.COM #define MSG_CKUID_LZ "## Checking for setuid/setgid programs in zone <%s>."
175*9781SMoriah.Waterland@Sun.COM
176*9781SMoriah.Waterland@Sun.COM #define MSG_SCRFND "Package scripts were found."
177*9781SMoriah.Waterland@Sun.COM #define MSG_UIDFND "Setuid/setgid processes detected."
178*9781SMoriah.Waterland@Sun.COM #define MSG_ATTRONLY "!%s %s <attribute change only>"
179*9781SMoriah.Waterland@Sun.COM
180*9781SMoriah.Waterland@Sun.COM #define MSG_CONTDISP "[Hit <RETURN> to continue display]"
181*9781SMoriah.Waterland@Sun.COM
182*9781SMoriah.Waterland@Sun.COM #define ERR_NO_RUNST "unable to determine current run-state"
183*9781SMoriah.Waterland@Sun.COM #define ERR_DEPFAILED "Dependency checking failed."
184*9781SMoriah.Waterland@Sun.COM #define ERR_SPCFAILED "Space checking failed."
185*9781SMoriah.Waterland@Sun.COM #define ERR_CNFFAILED "Conflict checking failed."
186*9781SMoriah.Waterland@Sun.COM #define ERR_BADFILE "packaging file <%s> is corrupt"
187*9781SMoriah.Waterland@Sun.COM
188*9781SMoriah.Waterland@Sun.COM /*
189*9781SMoriah.Waterland@Sun.COM * Return value: int
190*9781SMoriah.Waterland@Sun.COM * 0 - success
191*9781SMoriah.Waterland@Sun.COM * 1 - end of file
192*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
193*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
194*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
195*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
196*9781SMoriah.Waterland@Sun.COM * If "preinstallcheck" is set to B_TRUE:
197*9781SMoriah.Waterland@Sun.COM * 8 - partial install detected
198*9781SMoriah.Waterland@Sun.COM * 9 - partial removal detected
199*9781SMoriah.Waterland@Sun.COM */
200*9781SMoriah.Waterland@Sun.COM
201*9781SMoriah.Waterland@Sun.COM int
ckpartial(void)202*9781SMoriah.Waterland@Sun.COM ckpartial(void)
203*9781SMoriah.Waterland@Sun.COM {
204*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT];
205*9781SMoriah.Waterland@Sun.COM int n;
206*9781SMoriah.Waterland@Sun.COM
207*9781SMoriah.Waterland@Sun.COM if (ADM(partial, "nocheck")) {
208*9781SMoriah.Waterland@Sun.COM return (0);
209*9781SMoriah.Waterland@Sun.COM }
210*9781SMoriah.Waterland@Sun.COM
211*9781SMoriah.Waterland@Sun.COM if (access(ilockfile, F_OK) == 0) {
212*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
213*9781SMoriah.Waterland@Sun.COM return (8); /* partial install detected */
214*9781SMoriah.Waterland@Sun.COM }
215*9781SMoriah.Waterland@Sun.COM
216*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
217*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
218*9781SMoriah.Waterland@Sun.COM
219*9781SMoriah.Waterland@Sun.COM msgtext = gettext(MSG_PARTINST);
220*9781SMoriah.Waterland@Sun.COM ptext(stderr, msgtext);
221*9781SMoriah.Waterland@Sun.COM
222*9781SMoriah.Waterland@Sun.COM if (ADM(partial, "quit")) {
223*9781SMoriah.Waterland@Sun.COM return (4);
224*9781SMoriah.Waterland@Sun.COM }
225*9781SMoriah.Waterland@Sun.COM
226*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
227*9781SMoriah.Waterland@Sun.COM return (5);
228*9781SMoriah.Waterland@Sun.COM }
229*9781SMoriah.Waterland@Sun.COM
230*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
231*9781SMoriah.Waterland@Sun.COM
232*9781SMoriah.Waterland@Sun.COM ckquit = 0;
233*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_PARTIAL),
234*9781SMoriah.Waterland@Sun.COM ask_cont)) {
235*9781SMoriah.Waterland@Sun.COM return (n);
236*9781SMoriah.Waterland@Sun.COM }
237*9781SMoriah.Waterland@Sun.COM
238*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
239*9781SMoriah.Waterland@Sun.COM return (3);
240*9781SMoriah.Waterland@Sun.COM }
241*9781SMoriah.Waterland@Sun.COM ckquit = 1;
242*9781SMoriah.Waterland@Sun.COM }
243*9781SMoriah.Waterland@Sun.COM
244*9781SMoriah.Waterland@Sun.COM if (access(rlockfile, F_OK) == 0) {
245*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
246*9781SMoriah.Waterland@Sun.COM return (9); /* partial removal detected */
247*9781SMoriah.Waterland@Sun.COM }
248*9781SMoriah.Waterland@Sun.COM
249*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
250*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
251*9781SMoriah.Waterland@Sun.COM
252*9781SMoriah.Waterland@Sun.COM
253*9781SMoriah.Waterland@Sun.COM msgtext = gettext(MSG_PARTREM);
254*9781SMoriah.Waterland@Sun.COM ptext(stderr, msgtext);
255*9781SMoriah.Waterland@Sun.COM
256*9781SMoriah.Waterland@Sun.COM if (ADM(partial, "quit")) {
257*9781SMoriah.Waterland@Sun.COM return (4);
258*9781SMoriah.Waterland@Sun.COM }
259*9781SMoriah.Waterland@Sun.COM
260*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
261*9781SMoriah.Waterland@Sun.COM return (5);
262*9781SMoriah.Waterland@Sun.COM }
263*9781SMoriah.Waterland@Sun.COM
264*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
265*9781SMoriah.Waterland@Sun.COM
266*9781SMoriah.Waterland@Sun.COM ckquit = 0;
267*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_PARTIAL),
268*9781SMoriah.Waterland@Sun.COM ask_cont)) {
269*9781SMoriah.Waterland@Sun.COM return (n);
270*9781SMoriah.Waterland@Sun.COM }
271*9781SMoriah.Waterland@Sun.COM
272*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
273*9781SMoriah.Waterland@Sun.COM return (3);
274*9781SMoriah.Waterland@Sun.COM }
275*9781SMoriah.Waterland@Sun.COM ckquit = 1;
276*9781SMoriah.Waterland@Sun.COM }
277*9781SMoriah.Waterland@Sun.COM
278*9781SMoriah.Waterland@Sun.COM return (0);
279*9781SMoriah.Waterland@Sun.COM }
280*9781SMoriah.Waterland@Sun.COM
281*9781SMoriah.Waterland@Sun.COM /*
282*9781SMoriah.Waterland@Sun.COM * Return value: int
283*9781SMoriah.Waterland@Sun.COM * 0 - success
284*9781SMoriah.Waterland@Sun.COM * 1 - end of file
285*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
286*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
287*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
288*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
289*9781SMoriah.Waterland@Sun.COM * 99 - fatal error
290*9781SMoriah.Waterland@Sun.COM */
291*9781SMoriah.Waterland@Sun.COM
292*9781SMoriah.Waterland@Sun.COM int
ckrunlevel(void)293*9781SMoriah.Waterland@Sun.COM ckrunlevel(void)
294*9781SMoriah.Waterland@Sun.COM {
295*9781SMoriah.Waterland@Sun.COM struct utmpx utmpx;
296*9781SMoriah.Waterland@Sun.COM struct utmpx *putmpx;
297*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT], *pt, *istates, *pstate;
298*9781SMoriah.Waterland@Sun.COM int n;
299*9781SMoriah.Waterland@Sun.COM char *uxstate;
300*9781SMoriah.Waterland@Sun.COM
301*9781SMoriah.Waterland@Sun.COM if (ADM(runlevel, "nocheck")) {
302*9781SMoriah.Waterland@Sun.COM return (0);
303*9781SMoriah.Waterland@Sun.COM }
304*9781SMoriah.Waterland@Sun.COM
305*9781SMoriah.Waterland@Sun.COM pt = getenv("ISTATES");
306*9781SMoriah.Waterland@Sun.COM if (pt == NULL) {
307*9781SMoriah.Waterland@Sun.COM return (0);
308*9781SMoriah.Waterland@Sun.COM }
309*9781SMoriah.Waterland@Sun.COM
310*9781SMoriah.Waterland@Sun.COM utmpx.ut_type = RUN_LVL;
311*9781SMoriah.Waterland@Sun.COM putmpx = getutxid(&utmpx);
312*9781SMoriah.Waterland@Sun.COM if (putmpx == NULL) {
313*9781SMoriah.Waterland@Sun.COM progerr(gettext(ERR_NO_RUNST));
314*9781SMoriah.Waterland@Sun.COM return (99);
315*9781SMoriah.Waterland@Sun.COM }
316*9781SMoriah.Waterland@Sun.COM
317*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
318*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
319*9781SMoriah.Waterland@Sun.COM
320*9781SMoriah.Waterland@Sun.COM /*
321*9781SMoriah.Waterland@Sun.COM * this cryptic code is trying to pull the run level
322*9781SMoriah.Waterland@Sun.COM * out of the utmpx entry...the level starts in column
323*9781SMoriah.Waterland@Sun.COM * 11 - looks like "run-level %c"
324*9781SMoriah.Waterland@Sun.COM */
325*9781SMoriah.Waterland@Sun.COM uxstate = strtok(&putmpx->ut_line[10], " \t\n");
326*9781SMoriah.Waterland@Sun.COM
327*9781SMoriah.Waterland@Sun.COM istates = qstrdup(pt);
328*9781SMoriah.Waterland@Sun.COM if ((pt = strtok(pt, " \t\n, ")) == NULL) {
329*9781SMoriah.Waterland@Sun.COM return (0); /* no list is no list */
330*9781SMoriah.Waterland@Sun.COM }
331*9781SMoriah.Waterland@Sun.COM
332*9781SMoriah.Waterland@Sun.COM pstate = pt;
333*9781SMoriah.Waterland@Sun.COM do {
334*9781SMoriah.Waterland@Sun.COM if (strcmp(pt, uxstate) == 0) {
335*9781SMoriah.Waterland@Sun.COM free(istates);
336*9781SMoriah.Waterland@Sun.COM return (0);
337*9781SMoriah.Waterland@Sun.COM }
338*9781SMoriah.Waterland@Sun.COM } while (pt = strtok(NULL, " \t\n, "));
339*9781SMoriah.Waterland@Sun.COM
340*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
341*9781SMoriah.Waterland@Sun.COM msgtext = gettext(MSG_RUNLEVEL);
342*9781SMoriah.Waterland@Sun.COM ptext(stderr, msgtext, uxstate);
343*9781SMoriah.Waterland@Sun.COM } else {
344*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "runlevel=%s", uxstate);
345*9781SMoriah.Waterland@Sun.COM }
346*9781SMoriah.Waterland@Sun.COM
347*9781SMoriah.Waterland@Sun.COM pt = strtok(istates, " \t\n, ");
348*9781SMoriah.Waterland@Sun.COM do {
349*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
350*9781SMoriah.Waterland@Sun.COM ptext(stderr, "\\t%s", pt);
351*9781SMoriah.Waterland@Sun.COM } else {
352*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, ":%s", pt);
353*9781SMoriah.Waterland@Sun.COM }
354*9781SMoriah.Waterland@Sun.COM } while (pt = strtok(NULL, " \t\n, "));
355*9781SMoriah.Waterland@Sun.COM
356*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
357*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "\n");
358*9781SMoriah.Waterland@Sun.COM }
359*9781SMoriah.Waterland@Sun.COM
360*9781SMoriah.Waterland@Sun.COM free(istates);
361*9781SMoriah.Waterland@Sun.COM
362*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
363*9781SMoriah.Waterland@Sun.COM return (4);
364*9781SMoriah.Waterland@Sun.COM }
365*9781SMoriah.Waterland@Sun.COM
366*9781SMoriah.Waterland@Sun.COM if (ADM(runlevel, "quit")) {
367*9781SMoriah.Waterland@Sun.COM return (4);
368*9781SMoriah.Waterland@Sun.COM }
369*9781SMoriah.Waterland@Sun.COM
370*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
371*9781SMoriah.Waterland@Sun.COM return (5);
372*9781SMoriah.Waterland@Sun.COM }
373*9781SMoriah.Waterland@Sun.COM
374*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
375*9781SMoriah.Waterland@Sun.COM
376*9781SMoriah.Waterland@Sun.COM ckquit = 0;
377*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_RUNLEVEL),
378*9781SMoriah.Waterland@Sun.COM ask_cont)) {
379*9781SMoriah.Waterland@Sun.COM return (n);
380*9781SMoriah.Waterland@Sun.COM }
381*9781SMoriah.Waterland@Sun.COM
382*9781SMoriah.Waterland@Sun.COM ckquit = 1;
383*9781SMoriah.Waterland@Sun.COM
384*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) != NULL) {
385*9781SMoriah.Waterland@Sun.COM return (0);
386*9781SMoriah.Waterland@Sun.COM } else {
387*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
388*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_STATECHG), pstate);
389*9781SMoriah.Waterland@Sun.COM }
390*9781SMoriah.Waterland@Sun.COM return (3);
391*9781SMoriah.Waterland@Sun.COM }
392*9781SMoriah.Waterland@Sun.COM }
393*9781SMoriah.Waterland@Sun.COM
394*9781SMoriah.Waterland@Sun.COM /*
395*9781SMoriah.Waterland@Sun.COM * Return value: int
396*9781SMoriah.Waterland@Sun.COM * 0 - success
397*9781SMoriah.Waterland@Sun.COM * 1 - end of file
398*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
399*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
400*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
401*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
402*9781SMoriah.Waterland@Sun.COM */
403*9781SMoriah.Waterland@Sun.COM
404*9781SMoriah.Waterland@Sun.COM int
ckdepend(void)405*9781SMoriah.Waterland@Sun.COM ckdepend(void)
406*9781SMoriah.Waterland@Sun.COM {
407*9781SMoriah.Waterland@Sun.COM int n;
408*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT];
409*9781SMoriah.Waterland@Sun.COM char path[PATH_MAX];
410*9781SMoriah.Waterland@Sun.COM
411*9781SMoriah.Waterland@Sun.COM if (ADM(idepend, "nocheck")) {
412*9781SMoriah.Waterland@Sun.COM return (0);
413*9781SMoriah.Waterland@Sun.COM }
414*9781SMoriah.Waterland@Sun.COM
415*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/%s", instdir, DEPEND_FILE);
416*9781SMoriah.Waterland@Sun.COM if (access(path, F_OK) != 0) {
417*9781SMoriah.Waterland@Sun.COM return (0); /* no dependency file provided by package */
418*9781SMoriah.Waterland@Sun.COM }
419*9781SMoriah.Waterland@Sun.COM
420*9781SMoriah.Waterland@Sun.COM if (zoneName == (char *)NULL) {
421*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKDEPEND_GZ));
422*9781SMoriah.Waterland@Sun.COM } else {
423*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKDEPEND_LZ), zoneName);
424*9781SMoriah.Waterland@Sun.COM }
425*9781SMoriah.Waterland@Sun.COM
426*9781SMoriah.Waterland@Sun.COM if (dockdeps(path, 0, preinstallCheck)) {
427*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
428*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
429*9781SMoriah.Waterland@Sun.COM msgtext = gettext(ERR_DEPFAILED);
430*9781SMoriah.Waterland@Sun.COM
431*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
432*9781SMoriah.Waterland@Sun.COM return (4);
433*9781SMoriah.Waterland@Sun.COM }
434*9781SMoriah.Waterland@Sun.COM
435*9781SMoriah.Waterland@Sun.COM if (ADM(idepend, "quit")) {
436*9781SMoriah.Waterland@Sun.COM return (4);
437*9781SMoriah.Waterland@Sun.COM }
438*9781SMoriah.Waterland@Sun.COM
439*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
440*9781SMoriah.Waterland@Sun.COM return (5);
441*9781SMoriah.Waterland@Sun.COM }
442*9781SMoriah.Waterland@Sun.COM
443*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
444*9781SMoriah.Waterland@Sun.COM
445*9781SMoriah.Waterland@Sun.COM ckquit = 0;
446*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_DEPEND),
447*9781SMoriah.Waterland@Sun.COM ask_cont)) {
448*9781SMoriah.Waterland@Sun.COM return (n);
449*9781SMoriah.Waterland@Sun.COM }
450*9781SMoriah.Waterland@Sun.COM
451*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
452*9781SMoriah.Waterland@Sun.COM return (3);
453*9781SMoriah.Waterland@Sun.COM }
454*9781SMoriah.Waterland@Sun.COM
455*9781SMoriah.Waterland@Sun.COM ckquit = 1;
456*9781SMoriah.Waterland@Sun.COM }
457*9781SMoriah.Waterland@Sun.COM
458*9781SMoriah.Waterland@Sun.COM return (0);
459*9781SMoriah.Waterland@Sun.COM }
460*9781SMoriah.Waterland@Sun.COM
461*9781SMoriah.Waterland@Sun.COM void
cksetZoneName(char * a_zoneName)462*9781SMoriah.Waterland@Sun.COM cksetZoneName(char *a_zoneName)
463*9781SMoriah.Waterland@Sun.COM {
464*9781SMoriah.Waterland@Sun.COM zoneName = a_zoneName;
465*9781SMoriah.Waterland@Sun.COM }
466*9781SMoriah.Waterland@Sun.COM
467*9781SMoriah.Waterland@Sun.COM void
cksetPreinstallCheck(boolean_t a_preinstallCheck)468*9781SMoriah.Waterland@Sun.COM cksetPreinstallCheck(boolean_t a_preinstallCheck)
469*9781SMoriah.Waterland@Sun.COM {
470*9781SMoriah.Waterland@Sun.COM preinstallCheck = a_preinstallCheck;
471*9781SMoriah.Waterland@Sun.COM }
472*9781SMoriah.Waterland@Sun.COM
473*9781SMoriah.Waterland@Sun.COM /*
474*9781SMoriah.Waterland@Sun.COM * Return value: int
475*9781SMoriah.Waterland@Sun.COM * 0 - success
476*9781SMoriah.Waterland@Sun.COM * 1 - end of file
477*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
478*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
479*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
480*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
481*9781SMoriah.Waterland@Sun.COM */
482*9781SMoriah.Waterland@Sun.COM int
ckspace(void)483*9781SMoriah.Waterland@Sun.COM ckspace(void)
484*9781SMoriah.Waterland@Sun.COM {
485*9781SMoriah.Waterland@Sun.COM int n;
486*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT];
487*9781SMoriah.Waterland@Sun.COM char path[PATH_MAX];
488*9781SMoriah.Waterland@Sun.COM
489*9781SMoriah.Waterland@Sun.COM if (ADM(space, "nocheck")) {
490*9781SMoriah.Waterland@Sun.COM return (0);
491*9781SMoriah.Waterland@Sun.COM }
492*9781SMoriah.Waterland@Sun.COM
493*9781SMoriah.Waterland@Sun.COM if (zoneName == (char *)NULL) {
494*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKSPACE_GZ));
495*9781SMoriah.Waterland@Sun.COM } else {
496*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKSPACE_LZ), zoneName);
497*9781SMoriah.Waterland@Sun.COM }
498*9781SMoriah.Waterland@Sun.COM
499*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/install/space", instdir);
500*9781SMoriah.Waterland@Sun.COM if (access(path, F_OK) == 0) {
501*9781SMoriah.Waterland@Sun.COM n = dockspace(path);
502*9781SMoriah.Waterland@Sun.COM } else {
503*9781SMoriah.Waterland@Sun.COM n = dockspace(NULL);
504*9781SMoriah.Waterland@Sun.COM }
505*9781SMoriah.Waterland@Sun.COM
506*9781SMoriah.Waterland@Sun.COM if (n) {
507*9781SMoriah.Waterland@Sun.COM msgtext = gettext(ERR_SPCFAILED);
508*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
509*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
510*9781SMoriah.Waterland@Sun.COM
511*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
512*9781SMoriah.Waterland@Sun.COM return (4);
513*9781SMoriah.Waterland@Sun.COM }
514*9781SMoriah.Waterland@Sun.COM
515*9781SMoriah.Waterland@Sun.COM if (ADM(space, "quit")) {
516*9781SMoriah.Waterland@Sun.COM return (4);
517*9781SMoriah.Waterland@Sun.COM }
518*9781SMoriah.Waterland@Sun.COM
519*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
520*9781SMoriah.Waterland@Sun.COM return (5);
521*9781SMoriah.Waterland@Sun.COM }
522*9781SMoriah.Waterland@Sun.COM
523*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
524*9781SMoriah.Waterland@Sun.COM
525*9781SMoriah.Waterland@Sun.COM ckquit = 0;
526*9781SMoriah.Waterland@Sun.COM n = ckyorn(ans, NULL, NULL, gettext(HLP_SPACE), ask_cont);
527*9781SMoriah.Waterland@Sun.COM if (n != 0) {
528*9781SMoriah.Waterland@Sun.COM return (n);
529*9781SMoriah.Waterland@Sun.COM }
530*9781SMoriah.Waterland@Sun.COM
531*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
532*9781SMoriah.Waterland@Sun.COM return (3);
533*9781SMoriah.Waterland@Sun.COM }
534*9781SMoriah.Waterland@Sun.COM
535*9781SMoriah.Waterland@Sun.COM ckquit = 1;
536*9781SMoriah.Waterland@Sun.COM }
537*9781SMoriah.Waterland@Sun.COM return (0);
538*9781SMoriah.Waterland@Sun.COM }
539*9781SMoriah.Waterland@Sun.COM
540*9781SMoriah.Waterland@Sun.COM void
ckdirs(void)541*9781SMoriah.Waterland@Sun.COM ckdirs(void)
542*9781SMoriah.Waterland@Sun.COM {
543*9781SMoriah.Waterland@Sun.COM char path[PATH_MAX];
544*9781SMoriah.Waterland@Sun.COM
545*9781SMoriah.Waterland@Sun.COM if (mkpath(get_PKGADM())) {
546*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
547*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", get_PKGADM());
548*9781SMoriah.Waterland@Sun.COM } else {
549*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), get_PKGADM());
550*9781SMoriah.Waterland@Sun.COM }
551*9781SMoriah.Waterland@Sun.COM quit(99);
552*9781SMoriah.Waterland@Sun.COM }
553*9781SMoriah.Waterland@Sun.COM
554*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/admin", get_PKGADM());
555*9781SMoriah.Waterland@Sun.COM
556*9781SMoriah.Waterland@Sun.COM if (mkpath(path)) {
557*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
558*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", path);
559*9781SMoriah.Waterland@Sun.COM } else {
560*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), path);
561*9781SMoriah.Waterland@Sun.COM }
562*9781SMoriah.Waterland@Sun.COM quit(99);
563*9781SMoriah.Waterland@Sun.COM }
564*9781SMoriah.Waterland@Sun.COM
565*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/logs", get_PKGADM());
566*9781SMoriah.Waterland@Sun.COM
567*9781SMoriah.Waterland@Sun.COM if (mkpath(path)) {
568*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
569*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", path);
570*9781SMoriah.Waterland@Sun.COM } else {
571*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), path);
572*9781SMoriah.Waterland@Sun.COM }
573*9781SMoriah.Waterland@Sun.COM quit(99);
574*9781SMoriah.Waterland@Sun.COM }
575*9781SMoriah.Waterland@Sun.COM
576*9781SMoriah.Waterland@Sun.COM if (mkpath(PKGSCR)) {
577*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
578*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", PKGSCR);
579*9781SMoriah.Waterland@Sun.COM } else {
580*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), PKGSCR);
581*9781SMoriah.Waterland@Sun.COM }
582*9781SMoriah.Waterland@Sun.COM quit(99);
583*9781SMoriah.Waterland@Sun.COM }
584*9781SMoriah.Waterland@Sun.COM
585*9781SMoriah.Waterland@Sun.COM if (mkpath(get_PKGLOC())) {
586*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
587*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", get_PKGLOC());
588*9781SMoriah.Waterland@Sun.COM } else {
589*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), get_PKGLOC());
590*9781SMoriah.Waterland@Sun.COM }
591*9781SMoriah.Waterland@Sun.COM quit(99);
592*9781SMoriah.Waterland@Sun.COM }
593*9781SMoriah.Waterland@Sun.COM }
594*9781SMoriah.Waterland@Sun.COM
595*9781SMoriah.Waterland@Sun.COM /*
596*9781SMoriah.Waterland@Sun.COM * Return value: int
597*9781SMoriah.Waterland@Sun.COM * 0 - success
598*9781SMoriah.Waterland@Sun.COM * 99 - failure
599*9781SMoriah.Waterland@Sun.COM */
600*9781SMoriah.Waterland@Sun.COM
601*9781SMoriah.Waterland@Sun.COM int
ckpkgdirs(void)602*9781SMoriah.Waterland@Sun.COM ckpkgdirs(void)
603*9781SMoriah.Waterland@Sun.COM {
604*9781SMoriah.Waterland@Sun.COM boolean_t nonExistentPkgloc = B_FALSE;
605*9781SMoriah.Waterland@Sun.COM
606*9781SMoriah.Waterland@Sun.COM /*
607*9781SMoriah.Waterland@Sun.COM * If pkgloc doesn't exist make sure it gets removed after creating
608*9781SMoriah.Waterland@Sun.COM * it if this is a preinstall check. All dryrun and preinstallation
609*9781SMoriah.Waterland@Sun.COM * checks must not modify the file system.
610*9781SMoriah.Waterland@Sun.COM */
611*9781SMoriah.Waterland@Sun.COM
612*9781SMoriah.Waterland@Sun.COM if (access(pkgloc, F_OK) != 0) {
613*9781SMoriah.Waterland@Sun.COM nonExistentPkgloc = B_TRUE;
614*9781SMoriah.Waterland@Sun.COM }
615*9781SMoriah.Waterland@Sun.COM
616*9781SMoriah.Waterland@Sun.COM if (mkpath(pkgloc)) {
617*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
618*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", pkgloc);
619*9781SMoriah.Waterland@Sun.COM } else {
620*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), pkgloc);
621*9781SMoriah.Waterland@Sun.COM }
622*9781SMoriah.Waterland@Sun.COM return (99);
623*9781SMoriah.Waterland@Sun.COM }
624*9781SMoriah.Waterland@Sun.COM
625*9781SMoriah.Waterland@Sun.COM if (mkpath(pkgbin)) {
626*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
627*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", pkgbin);
628*9781SMoriah.Waterland@Sun.COM } else {
629*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), pkgbin);
630*9781SMoriah.Waterland@Sun.COM }
631*9781SMoriah.Waterland@Sun.COM return (99);
632*9781SMoriah.Waterland@Sun.COM }
633*9781SMoriah.Waterland@Sun.COM
634*9781SMoriah.Waterland@Sun.COM if (mkpath(pkgsav)) {
635*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
636*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", pkgsav);
637*9781SMoriah.Waterland@Sun.COM } else {
638*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), pkgsav);
639*9781SMoriah.Waterland@Sun.COM }
640*9781SMoriah.Waterland@Sun.COM return (99);
641*9781SMoriah.Waterland@Sun.COM }
642*9781SMoriah.Waterland@Sun.COM
643*9781SMoriah.Waterland@Sun.COM if (!is_spool_create() && mkpath(saveSpoolInstallDir)) {
644*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
645*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckdirs=%s\n", pkgsav);
646*9781SMoriah.Waterland@Sun.COM } else {
647*9781SMoriah.Waterland@Sun.COM progerr(gettext(MSG_MKPKGDIR), pkgsav);
648*9781SMoriah.Waterland@Sun.COM }
649*9781SMoriah.Waterland@Sun.COM return (99);
650*9781SMoriah.Waterland@Sun.COM }
651*9781SMoriah.Waterland@Sun.COM
652*9781SMoriah.Waterland@Sun.COM if (preinstallCheck && nonExistentPkgloc) {
653*9781SMoriah.Waterland@Sun.COM rrmdir(pkgloc);
654*9781SMoriah.Waterland@Sun.COM }
655*9781SMoriah.Waterland@Sun.COM
656*9781SMoriah.Waterland@Sun.COM return (0);
657*9781SMoriah.Waterland@Sun.COM }
658*9781SMoriah.Waterland@Sun.COM
659*9781SMoriah.Waterland@Sun.COM /*
660*9781SMoriah.Waterland@Sun.COM * Return value: int
661*9781SMoriah.Waterland@Sun.COM * 0 - success
662*9781SMoriah.Waterland@Sun.COM * 1 - end of file
663*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
664*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
665*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
666*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
667*9781SMoriah.Waterland@Sun.COM */
668*9781SMoriah.Waterland@Sun.COM
669*9781SMoriah.Waterland@Sun.COM int
ckconflct(void)670*9781SMoriah.Waterland@Sun.COM ckconflct(void)
671*9781SMoriah.Waterland@Sun.COM {
672*9781SMoriah.Waterland@Sun.COM int i, n, count, has_a_rogue = 0;
673*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT];
674*9781SMoriah.Waterland@Sun.COM
675*9781SMoriah.Waterland@Sun.COM if (ADM(conflict, "nochange")) {
676*9781SMoriah.Waterland@Sun.COM nocnflct++;
677*9781SMoriah.Waterland@Sun.COM return (0);
678*9781SMoriah.Waterland@Sun.COM }
679*9781SMoriah.Waterland@Sun.COM
680*9781SMoriah.Waterland@Sun.COM if (ADM(conflict, "nocheck")) {
681*9781SMoriah.Waterland@Sun.COM return (0);
682*9781SMoriah.Waterland@Sun.COM }
683*9781SMoriah.Waterland@Sun.COM
684*9781SMoriah.Waterland@Sun.COM if (zoneName == (char *)NULL) {
685*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKCONFL_GZ));
686*9781SMoriah.Waterland@Sun.COM } else {
687*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKCONFL_LZ), zoneName);
688*9781SMoriah.Waterland@Sun.COM }
689*9781SMoriah.Waterland@Sun.COM
690*9781SMoriah.Waterland@Sun.COM count = 0;
691*9781SMoriah.Waterland@Sun.COM for (i = 0; extlist[i]; i++) {
692*9781SMoriah.Waterland@Sun.COM struct cfent *ept;
693*9781SMoriah.Waterland@Sun.COM struct mergstat *mstat;
694*9781SMoriah.Waterland@Sun.COM
695*9781SMoriah.Waterland@Sun.COM if (extlist[i]->cf_ent.ftype == 'i') {
696*9781SMoriah.Waterland@Sun.COM continue;
697*9781SMoriah.Waterland@Sun.COM }
698*9781SMoriah.Waterland@Sun.COM
699*9781SMoriah.Waterland@Sun.COM ept = &(extlist[i]->cf_ent);
700*9781SMoriah.Waterland@Sun.COM mstat = &(extlist[i]->mstat);
701*9781SMoriah.Waterland@Sun.COM
702*9781SMoriah.Waterland@Sun.COM if (is_remote_fs(ept->path, &(extlist[i]->fsys_value)) &&
703*9781SMoriah.Waterland@Sun.COM !is_fs_writeable(ept->path,
704*9781SMoriah.Waterland@Sun.COM &(extlist[i]->fsys_value))) {
705*9781SMoriah.Waterland@Sun.COM continue;
706*9781SMoriah.Waterland@Sun.COM }
707*9781SMoriah.Waterland@Sun.COM
708*9781SMoriah.Waterland@Sun.COM /*
709*9781SMoriah.Waterland@Sun.COM * If no other package claims it or it's from a continuation
710*9781SMoriah.Waterland@Sun.COM * file, skip it.
711*9781SMoriah.Waterland@Sun.COM */
712*9781SMoriah.Waterland@Sun.COM if (!mstat->shared || mstat->preloaded) {
713*9781SMoriah.Waterland@Sun.COM continue;
714*9781SMoriah.Waterland@Sun.COM }
715*9781SMoriah.Waterland@Sun.COM
716*9781SMoriah.Waterland@Sun.COM if (ept->ftype == 'e') {
717*9781SMoriah.Waterland@Sun.COM continue;
718*9781SMoriah.Waterland@Sun.COM }
719*9781SMoriah.Waterland@Sun.COM
720*9781SMoriah.Waterland@Sun.COM if (mstat->rogue) {
721*9781SMoriah.Waterland@Sun.COM has_a_rogue = 1;
722*9781SMoriah.Waterland@Sun.COM }
723*9781SMoriah.Waterland@Sun.COM
724*9781SMoriah.Waterland@Sun.COM if (mstat->contchg) {
725*9781SMoriah.Waterland@Sun.COM if (!count++) {
726*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
727*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_CONFLICT));
728*9781SMoriah.Waterland@Sun.COM }
729*9781SMoriah.Waterland@Sun.COM } else if ((echoGetFlag() == B_TRUE) &&
730*9781SMoriah.Waterland@Sun.COM ((count % DISPSIZ) == 0)) {
731*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CONTDISP));
732*9781SMoriah.Waterland@Sun.COM (void) getc(stdin);
733*9781SMoriah.Waterland@Sun.COM }
734*9781SMoriah.Waterland@Sun.COM /*
735*9781SMoriah.Waterland@Sun.COM * NOTE : The leading "!" in this string forces
736*9781SMoriah.Waterland@Sun.COM * puttext() to print leading white space.
737*9781SMoriah.Waterland@Sun.COM */
738*9781SMoriah.Waterland@Sun.COM
739*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
740*9781SMoriah.Waterland@Sun.COM ptext(stderr, "!%s %s",
741*9781SMoriah.Waterland@Sun.COM (mstat->rogue) ? "*" : " ", ept->path);
742*9781SMoriah.Waterland@Sun.COM } else {
743*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout,
744*9781SMoriah.Waterland@Sun.COM "conflict-contents=%s\n", ept->path);
745*9781SMoriah.Waterland@Sun.COM }
746*9781SMoriah.Waterland@Sun.COM } else if (mstat->attrchg) {
747*9781SMoriah.Waterland@Sun.COM if (!count++) {
748*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
749*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_CONFLICT));
750*9781SMoriah.Waterland@Sun.COM }
751*9781SMoriah.Waterland@Sun.COM } else if ((echoGetFlag() == B_TRUE) &&
752*9781SMoriah.Waterland@Sun.COM ((count % DISPSIZ) == 0)) {
753*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CONTDISP));
754*9781SMoriah.Waterland@Sun.COM (void) getc(stdin);
755*9781SMoriah.Waterland@Sun.COM }
756*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
757*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_ATTRONLY),
758*9781SMoriah.Waterland@Sun.COM (mstat->rogue) ? "*" : " ", ept->path);
759*9781SMoriah.Waterland@Sun.COM } else {
760*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout,
761*9781SMoriah.Waterland@Sun.COM "conflict-attributes=%s\n", ept->path);
762*9781SMoriah.Waterland@Sun.COM }
763*9781SMoriah.Waterland@Sun.COM }
764*9781SMoriah.Waterland@Sun.COM }
765*9781SMoriah.Waterland@Sun.COM
766*9781SMoriah.Waterland@Sun.COM if (count) {
767*9781SMoriah.Waterland@Sun.COM if (has_a_rogue) {
768*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
769*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_ROGUE));
770*9781SMoriah.Waterland@Sun.COM }
771*9781SMoriah.Waterland@Sun.COM }
772*9781SMoriah.Waterland@Sun.COM
773*9781SMoriah.Waterland@Sun.COM msgtext = gettext(ERR_CNFFAILED);
774*9781SMoriah.Waterland@Sun.COM
775*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
776*9781SMoriah.Waterland@Sun.COM return (4);
777*9781SMoriah.Waterland@Sun.COM }
778*9781SMoriah.Waterland@Sun.COM
779*9781SMoriah.Waterland@Sun.COM if (ADM(conflict, "quit")) {
780*9781SMoriah.Waterland@Sun.COM return (4);
781*9781SMoriah.Waterland@Sun.COM }
782*9781SMoriah.Waterland@Sun.COM
783*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
784*9781SMoriah.Waterland@Sun.COM return (5);
785*9781SMoriah.Waterland@Sun.COM }
786*9781SMoriah.Waterland@Sun.COM
787*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
788*9781SMoriah.Waterland@Sun.COM
789*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_CONFLICT),
790*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONFLICT))) {
791*9781SMoriah.Waterland@Sun.COM return (n);
792*9781SMoriah.Waterland@Sun.COM }
793*9781SMoriah.Waterland@Sun.COM
794*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
795*9781SMoriah.Waterland@Sun.COM ckquit = 0;
796*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
797*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
798*9781SMoriah.Waterland@Sun.COM
799*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_CONT),
800*9781SMoriah.Waterland@Sun.COM ask_cont)) {
801*9781SMoriah.Waterland@Sun.COM return (n);
802*9781SMoriah.Waterland@Sun.COM }
803*9781SMoriah.Waterland@Sun.COM
804*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
805*9781SMoriah.Waterland@Sun.COM return (3);
806*9781SMoriah.Waterland@Sun.COM }
807*9781SMoriah.Waterland@Sun.COM ckquit = 1;
808*9781SMoriah.Waterland@Sun.COM nocnflct++;
809*9781SMoriah.Waterland@Sun.COM rprcflag++;
810*9781SMoriah.Waterland@Sun.COM }
811*9781SMoriah.Waterland@Sun.COM }
812*9781SMoriah.Waterland@Sun.COM return (0);
813*9781SMoriah.Waterland@Sun.COM }
814*9781SMoriah.Waterland@Sun.COM
815*9781SMoriah.Waterland@Sun.COM /*
816*9781SMoriah.Waterland@Sun.COM * Return value: int
817*9781SMoriah.Waterland@Sun.COM * 0 - success
818*9781SMoriah.Waterland@Sun.COM * 1 - end of file
819*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
820*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
821*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
822*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
823*9781SMoriah.Waterland@Sun.COM */
824*9781SMoriah.Waterland@Sun.COM
825*9781SMoriah.Waterland@Sun.COM int
cksetuid(void)826*9781SMoriah.Waterland@Sun.COM cksetuid(void)
827*9781SMoriah.Waterland@Sun.COM {
828*9781SMoriah.Waterland@Sun.COM int i, n, count, overwriting = 0;
829*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT];
830*9781SMoriah.Waterland@Sun.COM
831*9781SMoriah.Waterland@Sun.COM /* See if the administrative defaults already resolve this check. */
832*9781SMoriah.Waterland@Sun.COM if (ADM(setuid, "nocheck")) {
833*9781SMoriah.Waterland@Sun.COM return (0);
834*9781SMoriah.Waterland@Sun.COM }
835*9781SMoriah.Waterland@Sun.COM
836*9781SMoriah.Waterland@Sun.COM if (ADM(setuid, "nochange")) {
837*9781SMoriah.Waterland@Sun.COM nosetuid++; /* Do not install processes as setuid/gid. */
838*9781SMoriah.Waterland@Sun.COM return (0);
839*9781SMoriah.Waterland@Sun.COM }
840*9781SMoriah.Waterland@Sun.COM
841*9781SMoriah.Waterland@Sun.COM /* The administrative defaults require review of the package. */
842*9781SMoriah.Waterland@Sun.COM
843*9781SMoriah.Waterland@Sun.COM if (zoneName == (char *)NULL) {
844*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKUID_GZ));
845*9781SMoriah.Waterland@Sun.COM } else {
846*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CKUID_LZ), zoneName);
847*9781SMoriah.Waterland@Sun.COM }
848*9781SMoriah.Waterland@Sun.COM
849*9781SMoriah.Waterland@Sun.COM count = 0;
850*9781SMoriah.Waterland@Sun.COM for (i = 0; extlist[i]; i++) {
851*9781SMoriah.Waterland@Sun.COM int overwr;
852*9781SMoriah.Waterland@Sun.COM struct mergstat *mstat = &(extlist[i]->mstat);
853*9781SMoriah.Waterland@Sun.COM
854*9781SMoriah.Waterland@Sun.COM /*
855*9781SMoriah.Waterland@Sun.COM * Provide the administrator with info as to whether there is
856*9781SMoriah.Waterland@Sun.COM * already a setuid process in place. This is only necessary
857*9781SMoriah.Waterland@Sun.COM * to help the administrator decide whether or not to lay
858*9781SMoriah.Waterland@Sun.COM * down the process, it doesn't have anything to do with the
859*9781SMoriah.Waterland@Sun.COM * administrative defaults.
860*9781SMoriah.Waterland@Sun.COM */
861*9781SMoriah.Waterland@Sun.COM if (mstat->osetuid || mstat->osetgid) {
862*9781SMoriah.Waterland@Sun.COM overwr = 1;
863*9781SMoriah.Waterland@Sun.COM overwriting = 1;
864*9781SMoriah.Waterland@Sun.COM } else
865*9781SMoriah.Waterland@Sun.COM overwr = 0;
866*9781SMoriah.Waterland@Sun.COM
867*9781SMoriah.Waterland@Sun.COM if (mstat->setuid || mstat->setgid) {
868*9781SMoriah.Waterland@Sun.COM if (!count++) {
869*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
870*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_SETUID));
871*9781SMoriah.Waterland@Sun.COM }
872*9781SMoriah.Waterland@Sun.COM } else if ((echoGetFlag() == B_TRUE) &&
873*9781SMoriah.Waterland@Sun.COM ((count % DISPSIZ) == 0)) {
874*9781SMoriah.Waterland@Sun.COM echo(gettext(MSG_CONTDISP));
875*9781SMoriah.Waterland@Sun.COM (void) getc(stdin);
876*9781SMoriah.Waterland@Sun.COM }
877*9781SMoriah.Waterland@Sun.COM /*
878*9781SMoriah.Waterland@Sun.COM * NOTE : The leading "!" in these strings forces
879*9781SMoriah.Waterland@Sun.COM * puttext() to print leading white space.
880*9781SMoriah.Waterland@Sun.COM */
881*9781SMoriah.Waterland@Sun.COM
882*9781SMoriah.Waterland@Sun.COM if (mstat->setuid && mstat->setgid) {
883*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
884*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(
885*9781SMoriah.Waterland@Sun.COM "!%s %s <setuid %s setgid %s>"),
886*9781SMoriah.Waterland@Sun.COM (overwr) ? "*" : " ",
887*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
888*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.owner,
889*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.group);
890*9781SMoriah.Waterland@Sun.COM } else {
891*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "setuid=%s:%s\n",
892*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
893*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.owner);
894*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "setgid=%s:%s\n",
895*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
896*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.group);
897*9781SMoriah.Waterland@Sun.COM }
898*9781SMoriah.Waterland@Sun.COM } else if (mstat->setuid) {
899*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
900*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(
901*9781SMoriah.Waterland@Sun.COM "!%s %s <setuid %s>"),
902*9781SMoriah.Waterland@Sun.COM (overwr) ? "*" : " ",
903*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
904*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.owner);
905*9781SMoriah.Waterland@Sun.COM } else {
906*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "setuid=%s:%s\n",
907*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
908*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.owner);
909*9781SMoriah.Waterland@Sun.COM }
910*9781SMoriah.Waterland@Sun.COM } else if (mstat->setgid) {
911*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
912*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(
913*9781SMoriah.Waterland@Sun.COM "!%s%s <setgid %s>"),
914*9781SMoriah.Waterland@Sun.COM (overwr) ? "*" : " ",
915*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
916*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.group);
917*9781SMoriah.Waterland@Sun.COM } else {
918*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "setgid=%s:%s\n",
919*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.path,
920*9781SMoriah.Waterland@Sun.COM extlist[i]->cf_ent.ainfo.group);
921*9781SMoriah.Waterland@Sun.COM }
922*9781SMoriah.Waterland@Sun.COM }
923*9781SMoriah.Waterland@Sun.COM }
924*9781SMoriah.Waterland@Sun.COM }
925*9781SMoriah.Waterland@Sun.COM
926*9781SMoriah.Waterland@Sun.COM if (count) {
927*9781SMoriah.Waterland@Sun.COM if (overwriting) {
928*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
929*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_OVERWR));
930*9781SMoriah.Waterland@Sun.COM } else {
931*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout,
932*9781SMoriah.Waterland@Sun.COM "setuid-overwrite=true\n");
933*9781SMoriah.Waterland@Sun.COM }
934*9781SMoriah.Waterland@Sun.COM }
935*9781SMoriah.Waterland@Sun.COM
936*9781SMoriah.Waterland@Sun.COM msgtext = gettext(MSG_UIDFND);
937*9781SMoriah.Waterland@Sun.COM
938*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
939*9781SMoriah.Waterland@Sun.COM return (4);
940*9781SMoriah.Waterland@Sun.COM }
941*9781SMoriah.Waterland@Sun.COM
942*9781SMoriah.Waterland@Sun.COM if (ADM(setuid, "quit")) {
943*9781SMoriah.Waterland@Sun.COM return (4);
944*9781SMoriah.Waterland@Sun.COM }
945*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
946*9781SMoriah.Waterland@Sun.COM return (5);
947*9781SMoriah.Waterland@Sun.COM }
948*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
949*9781SMoriah.Waterland@Sun.COM
950*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_SETUID),
951*9781SMoriah.Waterland@Sun.COM gettext(ASK_SETUID))) {
952*9781SMoriah.Waterland@Sun.COM return (n);
953*9781SMoriah.Waterland@Sun.COM }
954*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
955*9781SMoriah.Waterland@Sun.COM ckquit = 0;
956*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
957*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
958*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_CONT),
959*9781SMoriah.Waterland@Sun.COM ask_cont)) {
960*9781SMoriah.Waterland@Sun.COM return (n);
961*9781SMoriah.Waterland@Sun.COM }
962*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
963*9781SMoriah.Waterland@Sun.COM return (3);
964*9781SMoriah.Waterland@Sun.COM }
965*9781SMoriah.Waterland@Sun.COM ckquit = 1;
966*9781SMoriah.Waterland@Sun.COM nosetuid++;
967*9781SMoriah.Waterland@Sun.COM rprcflag++;
968*9781SMoriah.Waterland@Sun.COM }
969*9781SMoriah.Waterland@Sun.COM }
970*9781SMoriah.Waterland@Sun.COM
971*9781SMoriah.Waterland@Sun.COM return (0);
972*9781SMoriah.Waterland@Sun.COM }
973*9781SMoriah.Waterland@Sun.COM
974*9781SMoriah.Waterland@Sun.COM /*
975*9781SMoriah.Waterland@Sun.COM * Return value: int
976*9781SMoriah.Waterland@Sun.COM * 0 - success
977*9781SMoriah.Waterland@Sun.COM * 1 - end of file
978*9781SMoriah.Waterland@Sun.COM * 2 - undefined error
979*9781SMoriah.Waterland@Sun.COM * 3 - answer was not "y"/was "q"
980*9781SMoriah.Waterland@Sun.COM * 4 - quit action taken
981*9781SMoriah.Waterland@Sun.COM * 5 - interactive mode required
982*9781SMoriah.Waterland@Sun.COM */
983*9781SMoriah.Waterland@Sun.COM
984*9781SMoriah.Waterland@Sun.COM int
ckpriv(void)985*9781SMoriah.Waterland@Sun.COM ckpriv(void)
986*9781SMoriah.Waterland@Sun.COM {
987*9781SMoriah.Waterland@Sun.COM struct dirent *dp;
988*9781SMoriah.Waterland@Sun.COM DIR *dirfp;
989*9781SMoriah.Waterland@Sun.COM int n, found;
990*9781SMoriah.Waterland@Sun.COM char ans[MAX_INPUT], path[PATH_MAX];
991*9781SMoriah.Waterland@Sun.COM
992*9781SMoriah.Waterland@Sun.COM if (ADM(action, "nocheck")) {
993*9781SMoriah.Waterland@Sun.COM return (0);
994*9781SMoriah.Waterland@Sun.COM }
995*9781SMoriah.Waterland@Sun.COM
996*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/install", instdir);
997*9781SMoriah.Waterland@Sun.COM if ((dirfp = opendir(path)) == NULL) {
998*9781SMoriah.Waterland@Sun.COM return (0);
999*9781SMoriah.Waterland@Sun.COM }
1000*9781SMoriah.Waterland@Sun.COM
1001*9781SMoriah.Waterland@Sun.COM found = 0;
1002*9781SMoriah.Waterland@Sun.COM while ((dp = readdir(dirfp)) != NULL) {
1003*9781SMoriah.Waterland@Sun.COM if (strcmp(dp->d_name, "preinstall") == 0 ||
1004*9781SMoriah.Waterland@Sun.COM strcmp(dp->d_name, "postinstall") == 0 ||
1005*9781SMoriah.Waterland@Sun.COM strncmp(dp->d_name, "i.", 2) == 0) {
1006*9781SMoriah.Waterland@Sun.COM found++;
1007*9781SMoriah.Waterland@Sun.COM break;
1008*9781SMoriah.Waterland@Sun.COM }
1009*9781SMoriah.Waterland@Sun.COM }
1010*9781SMoriah.Waterland@Sun.COM (void) closedir(dirfp);
1011*9781SMoriah.Waterland@Sun.COM
1012*9781SMoriah.Waterland@Sun.COM if (found) {
1013*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
1014*9781SMoriah.Waterland@Sun.COM ptext(stderr, gettext(MSG_PRIV));
1015*9781SMoriah.Waterland@Sun.COM msgtext = gettext(MSG_SCRFND);
1016*9781SMoriah.Waterland@Sun.COM }
1017*9781SMoriah.Waterland@Sun.COM (void) snprintf(ask_cont, sizeof (ask_cont),
1018*9781SMoriah.Waterland@Sun.COM gettext(ASK_CONT), pkginst);
1019*9781SMoriah.Waterland@Sun.COM
1020*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_TRUE) {
1021*9781SMoriah.Waterland@Sun.COM return (4);
1022*9781SMoriah.Waterland@Sun.COM }
1023*9781SMoriah.Waterland@Sun.COM
1024*9781SMoriah.Waterland@Sun.COM if (ADM(action, "quit")) {
1025*9781SMoriah.Waterland@Sun.COM return (4);
1026*9781SMoriah.Waterland@Sun.COM }
1027*9781SMoriah.Waterland@Sun.COM
1028*9781SMoriah.Waterland@Sun.COM if (echoGetFlag() == B_FALSE) {
1029*9781SMoriah.Waterland@Sun.COM return (5);
1030*9781SMoriah.Waterland@Sun.COM }
1031*9781SMoriah.Waterland@Sun.COM
1032*9781SMoriah.Waterland@Sun.COM msgtext = NULL;
1033*9781SMoriah.Waterland@Sun.COM
1034*9781SMoriah.Waterland@Sun.COM ckquit = 0;
1035*9781SMoriah.Waterland@Sun.COM if (n = ckyorn(ans, NULL, NULL, gettext(HLP_PRIV),
1036*9781SMoriah.Waterland@Sun.COM ask_cont)) {
1037*9781SMoriah.Waterland@Sun.COM return (n);
1038*9781SMoriah.Waterland@Sun.COM }
1039*9781SMoriah.Waterland@Sun.COM
1040*9781SMoriah.Waterland@Sun.COM if (strchr("yY", *ans) == NULL) {
1041*9781SMoriah.Waterland@Sun.COM return (3);
1042*9781SMoriah.Waterland@Sun.COM }
1043*9781SMoriah.Waterland@Sun.COM ckquit = 1;
1044*9781SMoriah.Waterland@Sun.COM }
1045*9781SMoriah.Waterland@Sun.COM
1046*9781SMoriah.Waterland@Sun.COM return (0);
1047*9781SMoriah.Waterland@Sun.COM }
1048*9781SMoriah.Waterland@Sun.COM
1049*9781SMoriah.Waterland@Sun.COM /*
1050*9781SMoriah.Waterland@Sun.COM * Return value: int
1051*9781SMoriah.Waterland@Sun.COM * 0 - success
1052*9781SMoriah.Waterland@Sun.COM * 99 - failure
1053*9781SMoriah.Waterland@Sun.COM */
1054*9781SMoriah.Waterland@Sun.COM
1055*9781SMoriah.Waterland@Sun.COM int
ckpkgfiles(void)1056*9781SMoriah.Waterland@Sun.COM ckpkgfiles(void)
1057*9781SMoriah.Waterland@Sun.COM {
1058*9781SMoriah.Waterland@Sun.COM register int i;
1059*9781SMoriah.Waterland@Sun.COM struct cfent *ept;
1060*9781SMoriah.Waterland@Sun.COM int errflg;
1061*9781SMoriah.Waterland@Sun.COM char source[PATH_MAX];
1062*9781SMoriah.Waterland@Sun.COM
1063*9781SMoriah.Waterland@Sun.COM errflg = 0;
1064*9781SMoriah.Waterland@Sun.COM for (i = 0; extlist[i]; i++) {
1065*9781SMoriah.Waterland@Sun.COM ept = &(extlist[i]->cf_ent);
1066*9781SMoriah.Waterland@Sun.COM if (ept->ftype != 'i') {
1067*9781SMoriah.Waterland@Sun.COM continue;
1068*9781SMoriah.Waterland@Sun.COM }
1069*9781SMoriah.Waterland@Sun.COM
1070*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.local) {
1071*9781SMoriah.Waterland@Sun.COM (void) snprintf(source, sizeof (source),
1072*9781SMoriah.Waterland@Sun.COM "%s/%s", instdir, ept->ainfo.local);
1073*9781SMoriah.Waterland@Sun.COM } else if (strcmp(ept->path, PKGINFO) == 0) {
1074*9781SMoriah.Waterland@Sun.COM (void) snprintf(source, sizeof (source),
1075*9781SMoriah.Waterland@Sun.COM "%s/%s", instdir, ept->path);
1076*9781SMoriah.Waterland@Sun.COM } else {
1077*9781SMoriah.Waterland@Sun.COM (void) snprintf(source, sizeof (source),
1078*9781SMoriah.Waterland@Sun.COM "%s/install/%s", instdir, ept->path);
1079*9781SMoriah.Waterland@Sun.COM }
1080*9781SMoriah.Waterland@Sun.COM if (cverify(0, &ept->ftype, source, &ept->cinfo, 1)) {
1081*9781SMoriah.Waterland@Sun.COM errflg++;
1082*9781SMoriah.Waterland@Sun.COM if (preinstallCheck == B_FALSE) {
1083*9781SMoriah.Waterland@Sun.COM progerr(gettext(ERR_BADFILE), source);
1084*9781SMoriah.Waterland@Sun.COM logerr(getErrbufAddr());
1085*9781SMoriah.Waterland@Sun.COM } else {
1086*9781SMoriah.Waterland@Sun.COM (void) fprintf(stdout, "ckpkgfilebad=%s",
1087*9781SMoriah.Waterland@Sun.COM source);
1088*9781SMoriah.Waterland@Sun.COM }
1089*9781SMoriah.Waterland@Sun.COM }
1090*9781SMoriah.Waterland@Sun.COM }
1091*9781SMoriah.Waterland@Sun.COM
1092*9781SMoriah.Waterland@Sun.COM if (errflg) {
1093*9781SMoriah.Waterland@Sun.COM return (99);
1094*9781SMoriah.Waterland@Sun.COM } else {
1095*9781SMoriah.Waterland@Sun.COM return (0);
1096*9781SMoriah.Waterland@Sun.COM }
1097*9781SMoriah.Waterland@Sun.COM }
1098