/*
* 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 <alloca.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <nss_dbdefs.h>
#include <priv.h>
#include <pwd.h>
#include <rpc/auth_sys.h>
#include <secdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xpol.h>
static void
{
struct xpol_rule *n;
for (; r != NULL; r = n) {
n = r->xr_next;
switch (r->xr_args_type) {
case XPOL_PATH:
break;
}
priv_freeset(r->xr_privs);
free(r);
}
}
{
if (!xdr_xpol_rule(&xdrs, r)) {
xpol_rules_free(r);
return (NULL);
}
return (r);
}
void *
{
return (NULL);
return (NULL);
}
return (buf);
}
{
}
void
{
xdr_free(xdr_xpol_rule, (char *)r);
free(r);
}
static xpol_ctxt_t *
xpol_context_create(void)
{
}
int
{
int bytes;
int res = 0;
char *mem;
return (-1);
}
else
return (res);
}
void
{
return;
}
static int
{
else
return (0);
}
static int
{
struct xpol_rule *r;
return (-1);
if (r == NULL)
return (-1);
r->xr_privs = priv_allocset();
r->xr_args_type = XPOL_PATH;
priv_freeset(r->xr_privs);
free(r);
return (-1);
}
return (xpol_add_rule(ctxt, r));
}
static int
{
struct xpol_rule *r;
return (-1);
if (r == NULL)
return (-1);
r->xr_privs = priv_allocset();
free(r);
return (-1);
}
r->xr_args_type = XPOL_UIDS;
return (xpol_add_rule(ctxt, r));
}
static int
{
struct xpol_rule *r;
return (-1);
if (r == NULL)
return (-1);
r->xr_privs = priv_allocset();
free(r);
return (-1);
}
r->xr_args_type = XPOL_PORTS;
return (xpol_add_rule(ctxt, r));
}
/* port/proto or port1-port2/proto */
static char *
{
return (NULL);
*proto++ = '\0';
*type = IPPROTO_TCP;
*type = IPPROTO_UDP;
*type = IPPROTO_SCTP;
*type = -1;
else
return (NULL);
return (proto);
}
static uint_t
{
char *q = NULL;
if (q == n || *q != '\0') {
}
return (res);
}
static boolean_t
alldigits_or_range(const char *p)
{
for (; *p; p++) {
if (*p == '-' && !seendash) {
continue;
}
if (!isdigit(*p))
return (B_FALSE);
}
return (B_TRUE);
}
static int
{
int err = 0;
if (p != NULL)
*p++ = '\0';
if (p != NULL) {
return (-1);
}
}
if (err != 0) {
return (-1);
}
return (0);
}
extern struct servent *_switch_getservbyname_r(const char *, const char *,
struct servent *, char *, int);
/*
* We should add a way to return error message; also,
* it should make sure that there are no ambiguities
* in rules.
*/
static int
{
char *mstr;
char *p;
int type;
int res;
char b[NSS_BUFSIZ];
if (mstr[0] == '\0') {
/* No object description. */
return (-1);
/* Path, many privileges apply here */
/* Ports, two privileges are relevant. */
return (-1);
if (p == NULL)
return (-1);
if (!alldigits_or_range(mstr)) {
&_s, b, sizeof (b));
if (s == NULL)
return (-1);
return (-1);
}
} else {
/* Uids, one privilege is relevant. */
return (-1);
if (!alldigits_or_range(mstr)) {
p == NULL)
return (-1);
return (-1);
}
return (res);
}
/*
* xpol_parse_ruleset(const char *rule, xpol_ctxt **cres, priv_set_t **iset);
* Returns Inheritable set and the xpol context but one of them can be NULL.
* Multiple calls are allowed and the first call must set *ctxtp and *isetp
* to NULL or initialize them to proper values.
*/
int
{
char *q;
char *p;
for (q = rule; q && q[0] != '\0'; ) {
rule = q;
if (q == rule) {
q++;
p = strchr(q, '}');
return (-1);
*p = '\0';
return (-1);
if (q != NULL)
*q++ = '\0';
*ctxtp = xpol_context_create();
return (-1);
}
return (-1);
} else {
if (q != NULL)
q[-1] = '\0';
return (-1);
} else {
}
}
}
return (0);
}
/*
* Return privileges which should be restricted if the extended policy is
* enabled.
*/
static priv_set_t *
{
xpol_rule_t *r;
return (NULL);
return (rset);
return (rset);
}
/*
* Return privileges which should be restricted if the extended policy
* is enabled.
*/
{
return (NULL);
}
/*
* Return privileges which have extended policies defined for them.
*/
{
}