/*
* 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 2015, Joyent, Inc.
*/
#include <sys/systeminfo.h>
#include <alloca.h>
#include <ctype.h>
#include <deflt.h>
#include <door.h>
#include <errno.h>
#include <grp.h>
#include <priv.h>
#include <pwd.h>
#include <regex.h>
#include <secdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <auth_attr.h>
#include <exec_attr.h>
#include <prof_attr.h>
#include <user_attr.h>
/*
* Remove the isaexec path of an executable if we can't find the
* executable at the first attempt.
*/
static void
init_isa_regex(void)
{
char *isalist;
long ret;
char *regexpr;
char *p;
/*
* Extract the isalist(5) for userland from the kernel.
*/
do {
if (ret == -1l) {
return;
}
} else
break;
return;
/* allocate room for the regex + (/())/[^/]*$ + needed \\. */
for (p = isalist; *p; p++) {
switch (*p) {
case '+':
case '|':
case '*':
case '[':
case ']':
case '{':
case '}':
case '\\':
default:
break;
case ' ':
case '\t':
break;
}
}
return;
}
static boolean_t
{
return (B_FALSE);
/*
* The first match includes the whole matched expression including the
* end of the string. The second match includes the "/" + "isa" and
* that is the part we need to remove.
*/
return (B_FALSE);
/* match[0].rm_eo == strlen(path) */
return (B_TRUE);
}
static int
{
return (ret);
}
/* ARGSUSED */
static void
{
if (doorfd != -1)
_exit(0);
}
static int
alldigits(const char *s)
{
int c;
if (*s == '\0')
return (0);
while ((c = *s++) != '\0') {
if (!isdigit(c)) {
return (0);
}
}
return (1);
}
static uid_t
{
if (alldigits(v))
return (atoi(v));
return ((uid_t)-1);
}
static uid_t
{
if (alldigits(v))
return (atoi(v));
return ((gid_t)-1);
}
static priv_set_t *
{
}
return (res);
}
/*ARGSUSED*/
static int
{
char *privs;
return (0);
/* get privs from this profile */
}
}
return (0);
}
/*
* This routine exists on failure and returns NULL if no granted privileges
* are set.
*/
static priv_set_t *
{
return (NULL);
res = priv_allocset();
return (NULL);
return (res);
}
static void
{
char *value;
/* Empty set signifies no forced privileges. */
GET_ONE);
}
return;
}
return;
}
}
static void
{
}
static void
{
char *value;
/*
* Initialize the pfexec_reply_t to a sane state.
*/
goto stdexec;
}
goto ret;
}
goto stdexec;
/* Found in execattr, so clearly we can use it */
/*
* If there's an error in parsing uid, gid, privs, then return
* failure.
*/
/*
* Remove LD_* variables in the kernel when the runtime linker might
* use them later on because the uids are equal.
*/
/* Now add the privilege sets */
}
}
/* If the real uid changes, we stop running under a profile shell */
ret:
return;
}
/* ARGSUSED */
static void
{
/* LINTED ALIGNMENT */
return;
}
case PFEXEC_EXEC_ATTRS:
break;
case PFEXEC_FORCED_PRIVS:
break;
case PFEXEC_USER_PRIVS:
break;
default:
break;
}
/*
* If the door_return(ptr, size, NULL, 0) fails, make sure we
* don't lose server threads.
*/
}
int
main(void)
{
info = getprivimplinfo();
exit(1);
if (fork() > 0)
_exit(0);
perror("doorfd");
exit(1);
}
/* LINTED CONSTCOND */
while (1)
return (0);
}