/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* System includes
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <utime.h>
#include <locale.h>
#include <libintl.h>
#include <pkglocs.h>
#include <errno.h>
#include <fcntl.h>
/*
* consolidation pkg command library includes
*/
#include <pkglib.h>
/*
* local pkg command library includes
*/
#include "libadm.h"
#include "libinst.h"
#include "install.h"
#include "messages.h"
#include "pkginstall.h"
/*
* forward declarations
*/
char *a_file);
/*
* Name: cppath
* Description: copy a path object (install new file on system)
* Arguments:
* - a_cntrl - determine how the destination file mode is set:
* |= MODE_0666 - force mode to 0666
* |= MODE_SET - mode is a_mode (no mask SET?ID bits)
* |= MODE_SRC - mode from source file (mask SET?ID bits)
* |= DIR_DISPLAY - display "%s <implied directory>" if directory created
* - a_srcPath - path to source to copy
* - a_dstPath - path to copy source to
* - a_mode - mode to set a_dstpath to (mode controlled by a_ctrl)
* Returns: int
* == 0 - success
* != 0 - failure
*/
int
{
int dstFd;
int len;
int srcFd;
long status;
/* entry debugging info */
/* open source file for reading */
if (srcFd < 0) {
return (1);
}
/* obtain file status of source file */
return (1);
}
/*
* Determine the permissions mode for the destination:
* - if MODE_SET is specified:
* --> use a_mode (do not mask off any portion)
* --> If a_mode is unknown (? in the pkgmap), then the file gets
* --> installed with the default 0644 mode
* - if MODE_SRC is specified:
* --> use the mode of the source (srcStatbuf.st_mode) but mask off all
* --> non-access mode bits (remove SET?UID bits)
* - otherwise:
* --> use 0666
*/
}
} else {
a_mode = 0666;
}
/*
* Get fd of newly created destination file or, if this
* is an overwrite, a temporary file (linknam).
*/
if (dstFd < 0) {
return (1);
}
/*
* source and target files are open: copy data
*/
if (status != 0) {
if (linknam) {
}
return (1);
}
/*
* If this is an overwrite, rename temp over original
*/
/* output log message if busy else program error */
} else {
}
/* open the log file and append log entry */
"%s/textbusy", get_PKGADM());
"textbusy");
} else {
} else {
}
}
}
/* set access/modification times for target */
return (1);
}
/* success! */
return (0);
}
/*
* This function creates all of the directory components of the specified path.
*/
static int
{
char *pt;
int found = 0;
/* continue if not at path separator or at start of path */
continue;
}
/* at '/' - terminate path at current entry */
*pt = '\0';
/* continue if path element exists */
*pt = '/';
continue;
}
/* create directory in path */
*pt = '/';
return (1);
}
/* display 'implied directory created' message */
if (a_ctrl & DIR_DISPLAY) {
}
found++;
*pt = '/';
}
return (!found);
}
/*
* Name: write_file
* Description: creates a new destination file if the file does not already
* exist; otherwise, creates a temporary file and places a
* pointer to the temporary file name in 'r_linknam'.
* Arguments: r_linknam - pointer to (char*) where name of temporary file
* created is returned
* a_ctrl - determine if the destination file name is displayed:
* |= DIR_DISPLAY - display "%s <implied directory>"
* if directory created
* a_mode - permissions mode to set a_file to
* a_file - name of destination file to open
* Returns: int
* success - file descriptor of the file it opened.
* failure - returns -1
*/
static int
{
int len;
/* entry debugging */
/* reset pointer to returned 'temporary file name' */
/*
* If we are overwriting an existing file, arrange to replace
* it transparently.
*/
/*
* link the file to be copied to a temporary name in case
* script currently being executed
*/
"%sXXXXXX", a_file);
}
} else {
"./%sXXXXXX", a_file);
"XXXXXX");
}
}
/* create and open temporary file */
if (fd == -1) {
return (-1);
}
/* remember name of temporary file */
/* make sure temporary file has correct mode */
}
return (fd);
}
/*
* We are not overwriting an existing file, create a new one directly.
*/
if (fd == -1) {
}
}
if (fd == -1) {
}
return (fd);
}