/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include <locale.h>
#include <pwd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <nss_dbdefs.h>
#include <zone.h>
#include <bsm/devalloc.h>
#include "allocate.h"
#if !defined(TEXT_DOMAIN)
#endif
extern void audit_allocate_argv(int, int, char *[]);
extern int audit_allocate_record(int);
int system_labeled = 0;
static int windowing = 0;
static void
{
if (system_labeled) {
"[-F] device|-g dev-type");
"[-F] device|-c dev-class|-g dev-type");
"[-a [-w]] -l|-n|-u [device]");
"[-a [-w]] [-l|-n|-u] -c dev-class");
switch (func) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
"%s\n%s\n%s\n%s\n%s\n%s\n",
use[5]);
}
} else {
"[-s] [-U uname] [-F] device|-g dev-type");
"[-s] [-U uid] -l|-n|-u [device]");
"[-s] [-U uid] [-l|-n|-u] -c dev-class");
switch (func) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
}
}
exit(1);
}
void
{
char *msg;
switch (error) {
case ALLOCUERR:
break;
case CHOWNERR:
break;
case CLEANERR:
break;
case CNTDEXECERR:
"Can't exec device-clean program for specified device.");
break;
case CNTFRCERR:
break;
case DACACCERR:
"Can't access DAC file for the device specified.");
break;
case DAOFFERR:
"Device allocation feature is not activated "
"on this system.");
break;
case DAUTHERR:
break;
case DEFATTRSERR:
"device type.");
break;
case DEVLKERR:
"try later.");
break;
case DEVLONGERR:
break;
case DEVNALLOCERR:
break;
case DEVNAMEERR:
break;
case DEVSTATEERR:
break;
case DEVZONEERR:
"device is allocated.");
break;
case DSPMISSERR:
"Device special file(s) missing for specified device.");
break;
case LABELRNGERR:
"Operation inconsistent with device's label range.");
break;
case LOGINDEVPERMERR:
break;
case NODAERR:
break;
case NODMAPERR:
break;
case PREALLOCERR:
break;
case SETACLERR:
break;
case UAUTHERR:
"User lacks authorization required for this operation.");
break;
case ZONEERR:
break;
default:
break;
}
if (windowing) {
} else {
}
}
NULL, /* for LC_ALL */
NULL, /* for LC_COLLATE */
NULL, /* for LC_CTYPE */
NULL, /* for LC_MESSAGES */
NULL, /* for LC_NUMERIC */
NULL, /* for LC_TIME */
NULL, /* for LANG */
};
static char *
{
return (*env);
}
return (NULL);
}
int
{
char *zname;
#ifdef DEBUG
#endif
(void) textdomain(TEXT_DOMAIN);
/* test hook: see also mkdevalloc.c and devfsadm.c */
if (!system_labeled) {
if (system_labeled) {
"forcing system label on for testing...\n");
}
}
/*
* get all enviroment variables
* which affect on internationalization.
*/
else
name++;
func = 0;
func = 1;
func = 2;
else
usage(-1);
if (system_labeled) {
/*
* allocate, deallocate, list_devices run in
* global zone only.
*/
if (zoneid != GLOBAL_ZONEID)
/*
* check if device allocation is activated.
*/
if (da_is_on() == 0) {
gettext("Turn device allocation on"),
gettext(" to use this feature.\n"));
}
}
if (func == 0) { /* allocate */
switch (c) {
case 'g':
break;
case 's':
break;
case 'w':
if (system_labeled) {
windowing = 1;
} else {
}
break;
case 'z':
if (system_labeled) {
} else {
}
break;
case 'F':
break;
case 'U':
break;
case '?':
default :
}
}
/*
* allocate(1) must be supplied with one device argument
*/
}
}
switch (c) {
case 'c':
break;
case 'g':
if (system_labeled) {
} else {
}
break;
case 's':
break;
case 'w':
if (system_labeled) {
windowing = 1;
} else {
}
break;
case 'z':
if (system_labeled) {
} else {
}
break;
case 'F':
break;
case 'I':
break;
case '?':
default :
}
}
/*
* deallocate(1) must be supplied with one device
* argument unless the '-I' argument is supplied
*/
}
}
switch (c) {
case 'a':
if (system_labeled) {
/*
* list auths, cleaning programs,
* labels.
*/
} else {
}
break;
case 'c':
break;
case 'd':
if (system_labeled) {
/*
* List devalloc_defaults
* This cannot used with anything other
* than -s.
*/
} else {
}
break;
case 'l':
break;
case 'n':
break;
case 's':
break;
case 'u':
break;
case 'w':
if (system_labeled) {
} else {
}
break;
case 'z':
if (system_labeled) {
} else {
}
break;
case 'U':
break;
case '?':
default :
}
}
if (system_labeled) {
}
}
/*
* list_devices(1) takes an optional device argument.
*/
}
}
NULL) {
exit(1);
}
exit(1);
}
} else {
/*
* caller's uid is the default if no user specified.
*/
}
/*
* global zone is the default if no zonename specified.
*/
} else {
exit(1);
}
}
if (func == 0)
else if (func == 1)
else if (func == 2)
(void) audit_allocate_record(error);
if (error) {
}
return (0);
}
/*
*/
static int
{
int child_status;
/* Fork a child */
case -1: /* FAILURE */
return (-1);
break;
case 0: /* CHILD */
/* If exec failed, send message to stderr */
return (-1);
default: /* PARENT */
/* Wait for child to exit */
return (0);
return (-1);
if (WIFEXITED(child_status))
return (WEXITSTATUS(child_status));
if (WIFSIGNALED(child_status))
return (WTERMSIG(child_status));
return (0);
}
}