main.c revision af1222373b60d56d6b0e630911372d4162b7787b
/*
* 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.
*/
/* unix system includes */
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <locale.h>
#include <pkglib.h>
#include <pkgerr.h>
#include <keystore.h>
#include "pkgadm.h"
#include "pkgadm_msgs.h"
#include "libadm.h"
/* initial error message buffer size */
#define ERR_BUFSIZE 2048
/* Local Function Prototypes */
static void print_version();
/* holds subcommands and their definitions */
struct cmd {
char *c_name;
int (*c_func)(int, char **);
};
{ "dbstatus", get_dbstatus},
{ "lock", admin_lock},
{ "sync", sync_server},
/* last one must be all NULLs */
};
{ "addcert", addcert},
{ "listcert", listcert},
{ "removecert", removecert},
/* last one must be all NULLs */
};
/*
* Function: main
*
* Return: 0 - subprocessing successful
* scripts and reboot
* [other] - subprocessing-specific failure
*/
int
{
char cur_cmd;
int newargc;
char **newargv;
int i;
/* Should be defined by cc -D */
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
/* set the default text domain for messaging */
(void) textdomain(TEXT_DOMAIN);
if (getenv("PKGADM_VERBOSE")) {
}
/* Superficial check of the arguments. */
if (argc <= 1) {
return (1);
}
/* first, process any arguments that can appear before the subcommand */
switch (i) {
case 'v': /* verbose mode enabled */
break;
case 'V':
return (0);
case '?':
return (0);
}
}
/* OK, hand it off to the subcommand processors */
/* make subcommand the first option */
}
}
/* initialize security library */
sec_init();
/* OK, hand it off to the subcommand processors */
/* make subcommand the first option */
}
}
/* bad subcommand */
return (1);
}
/*
* Name: set_verbose
* Description: Turns on verbose output
* Scope: public
* Arguments: verbose = B_TRUE indicates verbose mode
* Returns: none
*/
void
{
}
/*
* Name: get_verbose
* Description: Returns whether or not to output verbose messages
* Scope: public
* Arguments: none
* Returns: B_TRUE - verbose messages should be output
*/
{
return (log_get_verbose());
}
/*
* Name: log_pkgerr
* Description: Outputs pkgerr messages to logging facility.
* Scope: public
* Arguments: type - the severity of the message
* err - error stack to dump to facility
* Returns: none
*/
void
{
int i;
for (i = 0; i < pkgerr_num(err); i++) {
}
}
/*
* Name: print_Version
* Desc: Prints Version of packaging tools
* Arguments: none
* Returns: none
*/
static void
{
/* ignore any and all arguments, print version only */
}
/*
* usage
*
* Outputs the usage string.
*
* Return:1
* Side effects: none
*/
static int
usage()
{
return (1);
}
/*
* get_dbstatus
*
* Return 'text' as the db status.
* Use the command line to determine if there is an alternate root.
*
* Return: 0 on success, nonzero on failure
* Side effects: none
*/
int
{
/* Either accept 1 argument or 3 arguments where the second is -R */
return (usage());
return (0);
}
/*
* sync
*
* Use the command line to determine if there is an alternate root.
*
* Return: 0 on success, nonzero on failure
* Flush the pkgserv's log.
*/
int
{
int c;
/*
* Options:
* -q: Tell pkgserv daemon to quit.
* -R: Alternate root specification.
* -D: Dryrun directory specification.
*
* -R and -D help pkgadm to locate IPC files used for communication
* with pkgserv daemon. They should not be used together, though
* nothing prevents you from doing so. If you use both at once
* then IPC files will be searched in $ROOTDIR/$DRYRUNDIR directory.
* So if you want to terminate dryrun pkgserv process, you should
* always use only -D option.
*/
switch (c) {
case 'D':
break;
case 'R':
break;
case 'q':
break;
default:
return (usage());
}
}
return (0);
/* Flush the log file */
(void) relslock();
return (0);
}
return (1);
}