check.c revision 5c51f1241dbbdf2656d0e10011981411ed0c9673
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <utmpx.h>
#include <dirent.h>
#include <locale.h>
#include <libintl.h>
#include <pkgstrct.h>
#include <pkglocs.h>
#include "install.h"
#include <pkglib.h>
#include "libadm.h"
#include "libinst.h"
#include "pkginstall.h"
extern char saveSpoolInstallDir[];
static char ask_cont[100];
#define MSG_RUNLEVEL "\\nThe current run-level of this machine is <%s>, " \
"which is not a run-level suggested for installation " \
"of this package. Suggested run-levels (in order of " \
"preference) include:"
#define HLP_RUNLEVEL "If this package is not installed in a run-level " \
"which has been suggested, it is possible that the " \
"package may not install or operate properly. If " \
"you wish to follow the run-level suggestions, " \
"answer 'n' to stop installation of the package."
#define MSG_STATECHG "\\nTo change states, execute\\n\\tshutdown -y " \
"-i%s -g0\\nafter exiting the installation process. " \
"Please note that after changing states you " \
"may have to mount appropriate filesystem(s) " \
"in order to install this package."
#define ASK_CONFLICT "Do you want to install these conflicting files"
#define MSG_CONFLICT "\\nThe following files are already installed on the " \
"system and are being used by another package:"
#define MSG_ROGUE "\\n* - conflict with a file which does not " \
"belong to any package."
#define HLP_CONFLICT "If you choose to install conflicting files, the " \
"their access permissions changed. If you choose " \
"not to install these files, installation will " \
"proceed but these specific files will not be " \
"installed. Note that sane operation of the " \
"software being installed may require these files " \
"be installed; thus choosing to not to do so may " \
"cause inapropriate operation. If you wish to stop " \
"installation of this package, enter 'q' to quit."
#define ASK_SETUID "Do you want to install these as setuid/setgid files"
#define MSG_SETUID "\\nThe following files are being installed with " \
#define MSG_OVERWR "\\n* - overwriting a file which is also " \
#define HLP_SETUID "The package being installed appears to contain " \
"processes which will have their effective user or " \
"group ids set upon execution. History has shown " \
"that these types of processes can be a source of " \
"security problems on your system. If you choose " \
"not to install these as setuid files, installation " \
"will proceed but these specific files will be " \
"setgid permissions reset. Note that sane " \
"operation of the software being installed may " \
"require that these files be installed with setuid " \
"or setgid permissions as delivered; thus choosing " \
"to install them as regular files may cause " \
"inapropriate operation. If you wish to stop " \
"installation of this package, enter 'q' to quit."
#define MSG_PARTINST "\\nThe installation of this package was previously " \
"terminated and installation was never successfully " \
"completed."
#define MSG_PARTREM "\\nThe removal of this package was terminated at " \
"some point in time, and package removal was only " \
"partially completed."
#define HLP_PARTIAL "Installation of partially installed packages is " \
"normally allowable, but some packages providers " \
"may suggest that a partially installed package be " \
"completely removed before re-attempting " \
"installation. Check the documentation provided " \
"with this package, and then answer 'y' if you feel " \
"it is advisable to continue the installation process."
#define HLP_SPACE "It appears that there is not enough free space on " \
"your system in which to install this package. It " \
"is possible that one or more filesystems are not " \
"properly mounted. Neither installation of the " \
"package nor its operation can be guaranteed under " \
"these conditions. If you choose to disregard this " \
"warning, enter 'y' to continue the installation " \
"process."
#define HLP_DEPEND "The package being installed has indicated a " \
"dependency on the existence (or non-existence) " \
"of another software package. If this dependency is " \
"not met before continuing, the package may not " \
"install or operate properly. If you wish to " \
"disregard this dependency, answer 'y' to continue " \
"the installation process."
#define MSG_PRIV "\\nThis package contains scripts which will be " \
"executed with super-user permission during the " \
"process of installing this package."
#define HLP_PRIV "During the installation of this package, certain " \
"scripts provided with the package will execute with " \
"super-user permission. These scripts may modify or " \
"otherwise change your system without your " \
"knowledge. If you are certain of the origin and " \
"trustworthiness of the package being installed, " \
"answer 'y' to continue the installation process."
#define ASK_CONT "Do you want to continue with the installation of <%s>"
#define HLP_CONT "If you choose 'y', installation of this package " \
"will continue. If you want to stop installation " \
"of this package, choose 'n'."
#define MSG_MKPKGDIR "unable to make packaging directory <%s>"
#define MSG_CKCONFL_GZ "## Checking for conflicts with packages already " \
"installed."
#define MSG_CKCONFL_LZ "## Checking for conflicts with packages already " \
"installed in zone <%s>."
#define MSG_CKDEPEND_GZ "## Verifying package dependencies."
#define MSG_CKDEPEND_LZ "## Verifying package dependencies in zone <%s>."
#define MSG_CKSPACE_GZ "## Verifying disk space requirements."
#define MSG_CKSPACE_LZ "## Verifying disk space requirements in zone <%s>."
#define MSG_CKUID_GZ "## Checking for setuid/setgid programs."
#define MSG_CKUID_LZ "## Checking for setuid/setgid programs in zone <%s>."
#define MSG_SCRFND "Package scripts were found."
#define MSG_UIDFND "Setuid/setgid processes detected."
#define MSG_ATTRONLY "!%s %s <attribute change only>"
#define MSG_CONTDISP "[Hit <RETURN> to continue display]"
#define ERR_NO_RUNST "unable to determine current run-state"
#define ERR_DEPFAILED "Dependency checking failed."
#define ERR_SPCFAILED "Space checking failed."
#define ERR_CNFFAILED "Conflict checking failed."
#define ERR_BADFILE "packaging file <%s> is corrupt"
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
* If "preinstallcheck" is set to B_TRUE:
* 8 - partial install detected
* 9 - partial removal detected
*/
int
ckpartial(void)
{
int n;
return (0);
}
if (preinstallCheck == B_TRUE) {
return (8); /* partial install detected */
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
}
if (preinstallCheck == B_TRUE) {
return (9); /* partial removal detected */
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
}
return (0);
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
* 99 - fatal error
*/
int
ckrunlevel(void)
{
int n;
char *uxstate;
return (0);
}
return (0);
}
return (99);
}
/*
* this cryptic code is trying to pull the run level
* out of the utmpx entry...the level starts in column
* 11 - looks like "run-level %c"
*/
return (0); /* no list is no list */
}
do {
return (0);
}
if (preinstallCheck == B_FALSE) {
} else {
}
do {
if (preinstallCheck == B_FALSE) {
} else {
}
if (preinstallCheck == B_TRUE) {
}
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
ask_cont)) {
return (n);
}
ckquit = 1;
return (0);
} else {
if (preinstallCheck == B_FALSE) {
}
return (3);
}
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
*/
int
ckdepend(void)
{
int n;
return (0);
}
return (0); /* no dependency file provided by package */
}
} else {
}
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
}
return (0);
}
void
cksetZoneName(char *a_zoneName)
{
}
void
{
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
*/
int
ckspace(void)
{
int n;
return (0);
}
} else {
}
} else {
}
if (n) {
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
if (n != 0) {
return (n);
}
return (3);
}
ckquit = 1;
}
return (0);
}
void
ckdirs(void)
{
if (mkpath(get_PKGADM())) {
if (preinstallCheck == B_TRUE) {
} else {
}
quit(99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
quit(99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
quit(99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
quit(99);
}
if (mkpath(get_PKGLOC())) {
if (preinstallCheck == B_TRUE) {
} else {
}
quit(99);
}
}
/*
* Return value: int
* 0 - success
* 99 - failure
*/
int
ckpkgdirs(void)
{
/*
* If pkgloc doesn't exist make sure it gets removed after creating
* it if this is a preinstall check. All dryrun and preinstallation
* checks must not modify the file system.
*/
}
if (preinstallCheck == B_TRUE) {
} else {
}
return (99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
return (99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
return (99);
}
if (preinstallCheck == B_TRUE) {
} else {
}
return (99);
}
if (preinstallCheck && nonExistentPkgloc) {
}
return (0);
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
*/
int
ckconflct(void)
{
int i, n, count, has_a_rogue = 0;
nocnflct++;
return (0);
}
return (0);
}
} else {
}
count = 0;
for (i = 0; extlist[i]; i++) {
continue;
}
&(extlist[i]->fsys_value))) {
continue;
}
/*
* If no other package claims it or it's from a continuation
* file, skip it.
*/
continue;
}
continue;
}
has_a_rogue = 1;
}
if (!count++) {
if (preinstallCheck == B_FALSE) {
}
} else if ((echoGetFlag() == B_TRUE) &&
}
/*
* NOTE : The leading "!" in this string forces
* puttext() to print leading white space.
*/
if (preinstallCheck == B_FALSE) {
} else {
}
if (!count++) {
if (preinstallCheck == B_FALSE) {
}
} else if ((echoGetFlag() == B_TRUE) &&
}
if (preinstallCheck == B_FALSE) {
} else {
}
}
}
if (count) {
if (has_a_rogue) {
if (preinstallCheck == B_FALSE) {
}
}
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
gettext(ASK_CONFLICT))) {
return (n);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
nocnflct++;
rprcflag++;
}
}
return (0);
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
*/
int
cksetuid(void)
{
int i, n, count, overwriting = 0;
/* See if the administrative defaults already resolve this check. */
return (0);
}
return (0);
}
/* The administrative defaults require review of the package. */
} else {
}
count = 0;
for (i = 0; extlist[i]; i++) {
int overwr;
/*
* Provide the administrator with info as to whether there is
* already a setuid process in place. This is only necessary
* to help the administrator decide whether or not to lay
* down the process, it doesn't have anything to do with the
* administrative defaults.
*/
overwr = 1;
overwriting = 1;
} else
overwr = 0;
if (!count++) {
if (preinstallCheck == B_FALSE) {
}
} else if ((echoGetFlag() == B_TRUE) &&
}
/*
* NOTE : The leading "!" in these strings forces
* puttext() to print leading white space.
*/
if (preinstallCheck == B_FALSE) {
"!%s %s <setuid %s setgid %s>"),
} else {
}
if (preinstallCheck == B_FALSE) {
"!%s %s <setuid %s>"),
} else {
}
if (preinstallCheck == B_FALSE) {
"!%s%s <setgid %s>"),
} else {
}
}
}
}
if (count) {
if (overwriting) {
if (preinstallCheck == B_FALSE) {
} else {
"setuid-overwrite=true\n");
}
}
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
gettext(ASK_SETUID))) {
return (n);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
nosetuid++;
rprcflag++;
}
}
return (0);
}
/*
* Return value: int
* 0 - success
* 1 - end of file
* 2 - undefined error
* 3 - answer was not "y"/was "q"
* 4 - quit action taken
* 5 - interactive mode required
*/
int
ckpriv(void)
{
int n, found;
return (0);
}
return (0);
}
found = 0;
found++;
break;
}
}
if (found) {
if (preinstallCheck == B_FALSE) {
}
if (preinstallCheck == B_TRUE) {
return (4);
}
return (4);
}
if (echoGetFlag() == B_FALSE) {
return (5);
}
ckquit = 0;
ask_cont)) {
return (n);
}
return (3);
}
ckquit = 1;
}
return (0);
}
/*
* Return value: int
* 0 - success
* 99 - failure
*/
int
ckpkgfiles(void)
{
register int i;
int errflg;
errflg = 0;
for (i = 0; extlist[i]; i++) {
continue;
}
} else {
}
errflg++;
if (preinstallCheck == B_FALSE) {
logerr(getErrbufAddr());
} else {
source);
}
}
}
if (errflg) {
return (99);
} else {
return (0);
}
}