reqexec.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 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 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h> /* creat() declaration */
#include <pwd.h>
#include <grp.h>
#include <locale.h>
#include <libintl.h>
#include <pkglib.h>
#include "install.h"
#include "libadm.h"
#include "libinst.h"
#include "pkginstall.h"
#include "messages.h"
extern int pkgverbose;
static int fd;
static int respfile_defined = 0;
static int respfile_ro = 0; /* read only resp file */
/*
* This informs the calling routine if a read-only response file has been
* provided on the command line.
*/
int
rdonly_respfile(void)
{
return (respfile_ro);
}
int
is_a_respfile(void)
{
return (respfile_defined);
}
/*
* This function creates a working copy of the checkinstall script.
* This is needed in situations where the packages parent directories modes
* are set too restrictively, i.e. 700.
*
* Returns: A pointer to the location of the copied checkinstall
* script or NULL
*/
char *
dup_chkinstall(char *script)
{
char *dstpath;
int r;
static char *tmpname = "checkinstallXXXXXX";
/* determine length for destination script path */
/* allocate storage to hold destination script path */
return ((char *)NULL);
}
/* create destination script path */
return (NULL);
}
/* make copy of script */
if (r != 0) {
return (NULL);
}
/* Make the copy of the script readable by all */
return (NULL);
}
return (dstpath);
}
/*
* This function creates a temporary working copy of a read-only response
* file. It changes the resppath pointer to point to the working copy.
*/
static int
dup_respfile(void)
{
int r;
return (99);
}
/* Copy the contents of the user's response file to the working copy. */
if (r != 0) {
return (99);
}
/*
* Make it writable by the non-privileged installation user-id,
* but readable by the world.
*/
return (99);
}
respfile_ro = 0;
return (0);
}
/*
* This function establishes the response file passed on the command line if
* it's called with a valid string. If called with NULL, it checks to see if
* there's a response file already. If there isn't, it creates a temporary.
*/
int
{
/* A temporary response file needs to be constructed. */
return (99);
}
} else {
/* OK, we're being passed a response file or directory. */
} else {
}
}
return (0);
}
/* This exposes the working response file. */
char *
get_respfile(void)
{
return (resppath);
}
/*
* Execute the request script if present assuming the response file
* isn't read only.
*/
int
{
char *req_user;
/*
* determine which alternative user to execute the request script as
* if the default user "install" is not defined.
*/
if (enable_root_user == B_TRUE) {
/* use the root user */
} else if (non_abi_scripts != 0) {
/* non-compliant package user */
} else {
/* standard non-privileged user */
}
/*
* If we can't get to the the script or the response file, skip this.
*/
return (0);
/* No interact means no interact. */
if (echoGetFlag() == B_FALSE) {
return (5);
}
/* If there's no response file, create one. */
if (!respfile_defined)
return (99);
/* Clear out the old response file (if there is one). */
return (99);
}
/*
* Create a zero length response file which is only writable
* by the non-privileged installation user-id, but is readable
* by the world
*/
return (99);
}
}
int
{
/*
* If we're up against a read-only response file from the command
* line. Create a working copy.
*/
if (respfile_ro) {
if (dup_respfile())
return (99);
/* Make sure we can get to it. */
return (7);
}
}
/* If there's no response file, create a fresh one. */
else if (!respfile_defined) {
return (99);
/*
* create a zero length response file which is only writable
* by the non-priveledged installation user-id, but is readable
* by the world
*/
if (fd < 0) {
return (99);
}
}
}
static int
{
char *gname;
char *tmp_script;
char *uname;
int retcode = 0;
/*
* Determine which user to run the request script as:
* - if CHK_USER is a valid user, run the script as CHK_USER
* - otherwise, if alt_user is a valid user, run the script
* -- as alt_user
* - otherwise, output an error message and return failure
*/
} else {
return (1);
}
/*
* Determine which group to run the request script as:
* - If CHK_GRP is a valid group, run the script as CHK_GRP
* - otherwise, assume group "1" user "other"
*/
} else {
}
/*
* Copy the checkinstall script to tmpdir in case parent directories
* are restrictive, i.e. 700. Only do this for non updates, i.e.
* package installs and not patch package installs.
*/
if (update) {
/* Use the original checkinstall script */
}
if (pkgverbose)
else
return (retcode);
}