/*
* 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
*/
/*
*/
#include <sys/rctl_impl.h>
#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include <rctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <fcntl.h>
#include "utils.h"
#define DISABLE 0
/*
* Macros to produce a quoted string containing the value of a
* preprocessor macro. For example, if SIZE is defined to be 256,
* VAL2STR(SIZE) is "256". This is used to construct format
* strings for scanf-family functions below.
*/
#define QUOTE(x) #x
static const char USAGE[] =
"Usage:\trctladm -l\n"
"\trctladm -u\n"
"\trctladm -e actions -d actions rctl_name\n";
static void rctladm_enable(const char *, char *);
static void
usage()
{
}
static const char *syslog_priorities[] = {
"emerg", /* LOG_EMERG */
"alert", /* LOG_ALERT */
"crit", /* LOG_CRIT */
"err", /* LOG_ERR */
"warning", /* LOG_WARNING */
"notice", /* LOG_NOTICE */
"info", /* LOG_INFO */
"debug" /* LOG_DEBUG */
};
static int
{
uint_t i;
for (i = 0; i < LOG_HIGHEST + 1; i++) {
return (i);
}
/*NOTREACHED*/
}
/*ARGSUSED*/
static int
{
} else {
if (action & RCTL_GLOBAL_SYSLOG)
else
}
return (0);
}
static void
{
int fd;
/*
* Non-root users shouldn't update the configuration file.
*/
if (geteuid() != 0)
return;
(void) fputs(
"#\n"
"# rctladm.conf\n"
"#\n"
"# Parameters for resource controls configuration.\n"
"# Do NOT edit this file by hand -- use rctladm(1m) instead.\n"
"#\n",
fp);
}
static void
{
if (action[0] == '\0') {
line);
return;
}
}
static void
{
int fd;
char *action;
/*
* Non-root users shouldn't do this.
*/
if (geteuid() != 0)
/*
* Skip comment lines and empty lines.
*/
continue;
/*
* Look for "rctl_name=action;action;...;action, with
* optional whitespace on either side, terminated by a newline,
* and consuming the whole line.
*/
if (n == 1) {
CONFIGPATH, line);
continue;
}
RCTLCTL_GET) == -1) {
continue;
}
if (actions[0] == ';') {
CONFIGPATH, line);
continue;
}
}
}
if (line == 1)
}
static void
int log_level)
{
(action == RCTL_GLOBAL_SYSLOG)) {
op_failures++;
return;
}
if (enable) {
} else {
}
op_failures++;
}
}
static int
{
char *log_lvl_str;
/*
* Our syslog priority defaults to LOG_NOTICE.
*/
return (LOG_NOTICE);
return (rctladm_syslog_prio(log_lvl_str));
}
static void
{
/*
* Two valid values: "none" and "syslog[=level]".
*/
~RCTL_GLOBAL_ACTION_MASK, 0);
return;
}
}
static void
{
/*
* Two valid values: "all" and "syslog".
*/
~RCTL_GLOBAL_ACTION_MASK, 0);
return;
0);
return;
}
}
static void
{
if (flags & RCTL_GLOBAL_SYSLOG_NEVER)
(void) fprintf(f, "syslog=n/a ");
else if (action & RCTL_GLOBAL_SYSLOG)
(void) fprintf(f, "syslog=%-7s",
else
(void) fprintf(f, "syslog=off ");
if (flags & RCTL_GLOBAL_ACTION_MASK)
(void) fprintf(f, " [");
if (flags & RCTL_GLOBAL_NOBASIC)
(void) fprintf(f, " no-basic");
if (flags & RCTL_GLOBAL_LOWERABLE)
(void) fprintf(f, " lowerable");
if (flags & RCTL_GLOBAL_DENY_ALWAYS)
(void) fprintf(f, " deny");
if (flags & RCTL_GLOBAL_DENY_NEVER)
(void) fprintf(f, " no-deny");
if (flags & RCTL_GLOBAL_CPU_TIME)
(void) fprintf(f, " cpu-time");
if (flags & RCTL_GLOBAL_FILE_SIZE)
(void) fprintf(f, " file-size");
if (flags & RCTL_GLOBAL_SIGNAL_NEVER)
(void) fprintf(f, " no-signal");
if (flags & RCTL_GLOBAL_UNOBSERVABLE)
(void) fprintf(f, " no-obs");
if (flags & RCTL_GLOBAL_INFINITE)
(void) fprintf(f, " inf");
if (flags & RCTL_GLOBAL_SYSLOG_NEVER)
(void) fprintf(f, " no-syslog");
if (flags & RCTL_GLOBAL_SECONDS)
(void) fprintf(f, " seconds");
if (flags & RCTL_GLOBAL_BYTES)
(void) fprintf(f, " bytes");
if (flags & RCTL_GLOBAL_COUNT)
(void) fprintf(f, " count");
if (flags & RCTL_GLOBAL_ACTION_MASK)
(void) fprintf(f, " ]");
(void) fprintf(f, "\n");
}
/*ARGSUSED*/
static int
{
else
op_failures++;
} else {
}
return (0);
}
static void
{
return;
}
}
int
{
int c; /* options character */
char *action;
char *rctl;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'd':
dflg++;
break;
case 'e':
eflg++;
break;
case 'l':
lflg = 1;
break;
case 'u':
uflg = 1;
break;
case '?':
default:
usage();
}
}
if (uflg) {
return (E_SUCCESS);
}
usage();
}
usage();
}
usage();
}
}
"resource control names\n"));
usage();
}
if (eflg) {
} else if (dflg) {
} else {
usage();
}
}
}