/*
* 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 2009 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 <stdlib.h>
#include <unistd.h>
#include <utime.h>
#include <grp.h>
#include <pwd.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include "pkgstrct.h"
#include "pkglib.h"
#include "pkglibmsgs.h"
#include "pkglocale.h"
/* checksum disable switch */
/* attribute disable flag */
static int disable_attributes = 0;
/* non-ABI symlinks supported */
static int nonabi_symlinks;
/*
* forward declarations
*/
/* union used to generate checksum */
typedef union hilo {
struct part {
} hl;
} CHECKSUM_T;
/*PRINTFLIKE1*/
static void
{
char *pt;
int n;
theErrBuf[0] = '\0';
} else {
*pt++ = '\n';
*pt = '\0';
} else {
}
}
}
/*
* Name: cverify
* Description: This function verifies and (if fix > 0) fixes the contents
* of the file at the path provided
* Arguments: fix - 0 - do not fix entries, 1 - fix entries
* ftype - single character "type" the entry is supposed to be
* path - path to file
* cinfo - content info structure representing the contents
* the entry is supposed to contain
* allow_checksum - determine if checksumming should be disabled:
* == 0 - do not perform checksum ever - override enable_checksum.
* != 0 - use the default checksum flag "enable_checksum" to
* determine if checksumming should be done.
* NOTE: modification and creation times can be repaired; the contents
* of the file cannot be corrected if the checksum indicates that
* the contents are not correct - VE_CONT will be returned in this
* case.
* Possible return values:
* - 0 = successful
* - VE_EXIST = path name does not exist
* - VE_FTYPE = path file type is not recognized, is not supported,
* or is not what was expected
* directory is not what was expected
* chown failed
*/
int
int allow_checksum)
{
unsigned long mycksum;
int cksumerr;
retcode = 0;
return (VE_EXIST);
}
/* -1 requires modtimes to be the same */
/* 0 reports modtime failure */
/* 1 fixes modtimes */
if (fix > 0) {
/* reset times on the file */
}
} else if (fix < 0) {
/* modtimes must be the same */
}
}
}
}
if (!retcode) {
}
}
cksumerr = 0;
/*
* see if checksumming should be done: if checksumming is allowed,
* and checksumming is enabled, then checksum the file.
*/
/* return if no need to compute checksum */
if ((allow_checksum == 0) || (enable_checksum == 0)) {
return (retcode);
}
/* compute checksum */
/* set value if not set or if checksum cannot be computed */
return (retcode);
}
/* report / return error if checksums mismatch or there is an error */
if (!retcode) {
}
if (!cksumerr) {
}
}
return (retcode);
}
/*
* Name: compute_checksum
* Description: generate checksum for specified file
* Arguments: r_cksumerr (int *) [RO, *RW]
* - pointer to integer that is set on return to:
* == 0 - no error occurred
* != 0 - error occurred
* a_path (char *) [RO, *RO]
* - pointer to string representing path to file to
* generate checksum of
* Returns: unsigned long - results:
* - If *r_cksumerr == 0, checksum of specified file
* - If *r_cksumerr != 0, undefined
*/
unsigned long
{
int fd;
int notyet = 0;
int nread;
/* reset error flag */
*r_cksumerr = 0;
*r_cksumerr = 1;
return (0);
}
*r_cksumerr = 1;
return (0);
}
/* initialize checksum value */
lg = 0;
/*
* Read CHUNK bytes off the file at a time; Read size of long bytes
* from memory at a time and process them.
* If last read, then read remnant bytes and process individually.
*/
errno = 0;
uchar_t *s;
p++;
}
s = (uchar_t *)p;
/* leftover bytes less than four in number */
while (notyet--)
}
/* wind up */
/* compute checksum components */
/* return final checksum value */
}
/*
* Remove the thing that's currently in place so we can put down the package
* object. If we're replacing a directory with a directory, leave it alone.
* Returns 1 if all OK and 0 if failed.
*/
static int
{
if (is_a_dir) { /* if there's a directory there already ... */
/* ... and this isn't, ... */
retcode = 0;
}
}
} else {
retcode = 0; /* It didn't work. */
}
}
}
return (retcode);
}
/*
* Name: averify
* Description: This function verifies and (if fix > 0) fixes the attributes
* of the file at the path provided.
* Arguments: fix - 0 - do not fix entries, 1 - fix entries
* ftype - single character "type" the entry is supposed to be
* path - path to file
* ainfo - attribute info structure representing the attributes
* the entry is supposed to be
* NOTE: attributes are links and permissions
* Possible return values:
* - 0 = successful
* - VE_EXIST = path name does not exist
* - VE_FTYPE = path file type is not recognized, is not supported,
* or is not what was expected
* directory is not what was expected
* chown failed
*/
int
{
int n;
int setval;
int dochown;
int retcode;
int statError = 0;
char myftype;
char *cd;
char *c;
retcode = 0;
if (get_disable_attribute_check()) {
return (0);
}
if (*ftype == 'l') {
}
/* Get copy of the current working directory */
return (VE_FAIL);
}
/*
* Change to the directory in which the hard
* link is to be created.
*/
if (c) {
/* bugid 4247895 */
else
*c = NULL;
return (VE_FAIL);
}
}
if (fix) {
/*
* Don't want to do a hard link to a
* directory.
*/
return (VE_FAIL);
}
/* Now do the link. */
return (VE_FAIL);
return (VE_FAIL);
}
retcode = 0;
} else {
/* Go back to previous working directory */
return (VE_CONT);
}
}
/* Go back to previous working directory */
return (VE_CONT);
}
return (retcode);
}
retcode = 0;
/* If we are to process symlinks the old way then we follow the link */
if (nonABI_symlinks()) {
myftype = '?';
statError++;
}
/* If not then we inspect the target of the link */
} else {
myftype = '?';
statError++;
}
}
if (!statError) {
/* determining actual type of existing object */
case S_IFLNK:
myftype = 's';
break;
case S_IFIFO:
myftype = 'p';
break;
case S_IFCHR:
myftype = 'c';
break;
case S_IFDIR:
myftype = 'd';
targ_is_dir = 1;
break;
case S_IFBLK:
myftype = 'b';
break;
case S_IFREG:
case 0:
myftype = 'f';
break;
case S_IFDOOR:
myftype = 'D';
break;
default:
return (VE_FTYPE);
}
}
if (setval) {
/*
* Check to make sure that a package or an installf that uses
* wild cards '?' to assume the ftype of an object on the
* system is not assuming a door ftype. Doors are not supported
* but should be ignored.
*/
if (myftype == 'D') {
return (VE_FTYPE);
} else {
}
}
/* make sure that symbolic link is correct */
if (n < 0) {
buf[n] = '\0';
}
/*
* Since a sym link target exists, insert it
* into the ainfo structure
*/
buf[n] = '\0';
}
}
if (retcode) {
/* The path doesn't exist or is different than it should be. */
if (fix) {
/*
* Clear the way for the write. If it won't clear,
* there's nothing we can do.
*/
return (VE_FAIL);
char *pt, *p;
/* Try to make it the easy way */
/*
* Failing that, walk through the
* parent directories creating
* whatever is needed.
*/
do {
*pt = '\0';
if (access(p, 0) &&
break;
if (pt)
*pt++ = '/';
} while (pt);
free(p);
}
return (VE_FAIL);
}
} else if (*ftype == 's') {
return (VE_FAIL);
}
} else if (*ftype == 'c') {
int wilddevno = 0;
/*
* The next three if's support 2.4 and older
* packages that use "?" as device numbers.
* This should be considered for removal by
* release 2.7 or so.
*/
wilddevno = 1;
}
wilddevno = 1;
}
if (wilddevno) {
wilddevno = 0;
}
return (VE_FAIL);
}
} else if (*ftype == 'b') {
int wilddevno = 0;
/*
* The next three if's support 2.4 and older
* packages that use "?" as device numbers.
* This should be considered for removal by
* release 2.7 or so.
*/
wilddevno = 1;
}
wilddevno = 1;
}
if (wilddevno) {
wilddevno = 0;
}
return (VE_FAIL);
}
} else if (*ftype == 'p') {
return (VE_FAIL);
}
} else
return (retcode);
} else
return (retcode);
}
if (*ftype == 's')
return (0); /* don't check anything else */
if (*ftype == 'i')
return (0); /* don't check anything else */
retcode = 0;
/* check major & minor */
}
}
/* compare specified mode w/ actual mode excluding sticky bit */
if (fix) {
} else {
if (!retcode)
}
}
dochown = 0;
/* get group entry for specified group */
if (grp)
else {
if (!retcode)
}
if (!retcode)
if (fix) {
/* save specified GID */
dochown++;
} else {
"(null)");
} else {
}
if (!retcode)
}
}
/* get password entry for specified owner */
if (pwd)
else {
if (!retcode)
}
/* UID does not exist in password file */
if (!retcode)
/* get owner name for actual UID */
if (fix) {
dochown++;
} else {
else
if (!retcode)
}
}
} else {
if (dochown) {
/* pcfs doesn't support file ownership */
}
}
}
return (retcode);
}
/*
* This is a special fast verify which basically checks the attributes
* and then, if all is OK, checks the size and mod time using the same
* stat and statvfs structures.
*/
int
{
int retval;
/* return success if attribute checks are disabled */
if (get_disable_attribute_check()) {
return (0);
}
}
/* pcfs doesn't support modification times */
}
}
}
}
return (retval);
}
/*
* This function determines whether or not non-ABI symlinks are supported.
*/
int
nonABI_symlinks(void)
{
return (nonabi_symlinks);
}
void
set_nonABI_symlinks(void)
{
nonabi_symlinks = 1;
}
/*
* Disable attribute checking. Only disable attribute checking if files
* are guaranteed to exist in the FS.
*/
void
disable_attribute_check(void)
{
disable_attributes = 1;
}
/*
* This function determines whether or not to do attribute checking.
* Returns: 0 - Do attribute checking
* !0 - Don't do attribute checking
*/
int
{
return (disable_attributes);
}
/*
* This function returns the address of the "global" error buffer that
* is populated by the various functions in this module.
*/
char *
getErrbufAddr(void)
{
return (theErrBuf);
}
/*
* This function returns the size of the buffer returned by getErrbufAddr()
*/
int
getErrbufSize(void)
{
return (sizeof (theErrBuf));
}
/*
* This function returns the current global "error string"
*/
char *
getErrstr(void)
{
return (theErrStr);
}
/*
* This function sets the global "error string"
*/
void
{
}
/*
* This function enables checksumming
*/
void
checksum_on(void)
{
enable_checksum = 1;
}
/*
* This function disables checksumming
*/
void
checksum_off(void)
{
enable_checksum = 0;
}