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