/*
* 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 "lint.h"
#include "mtlib.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <nss_dbdefs.h>
#include <deflt.h>
#include <secdb.h>
#include <exec_attr.h>
#include <user_attr.h>
#include <auth_attr.h>
#include <prof_attr.h>
#include <getxby_door.h>
#include <nsswitch.h>
extern int _str2profattr(const char *, int, void *, char *, int);
static execattr_t *userprof(const char *, const char *, const char *, int);
char *_exec_wild_id(char *, const char *);
static void _free_execstr(execstr_t *);
/*
* Unsynchronized, but it affects only efficiency, not correctness
*/
static DEFINE_NSS_DB_ROOT(exec_root);
static DEFINE_NSS_GETENT(context);
void
{
p->name = NSS_DBNAM_EXECATTR;
}
void
{
p->name = NSS_DBNAM_EXECATTR;
p->flags |= NSS_USE_DEFAULT_CONFIG;
}
void
{
p->name = NSS_DBNAM_PROFATTR;
p->flags |= NSS_USE_DEFAULT_CONFIG;
}
/*
* Return values: 0 = success, 1 = parse error, 2 = erange ... The structure
* pointer passed in is a structure in the caller's space wherein the field
* pointers would be set to areas in the buffer if need be. instring and buffer
* should be separate areas.
* When we free execstr_t's, the first one is typically not allocated but
* the rest must be, including the strings. That is why we use _dup_execstr.
*/
int
{
char *newline;
return (NSS_STR_PARSE_ERANGE);
/* Terminate the buffer */
/* quick exit do not entry fill if not needed */
return (NSS_STR_PARSE_SUCCESS);
/*
* nscd may return multiple entries separated by newlines; we return
* one entry for each line.
* Ignore a trailing \n but parse the additional entries.
* The new arguments for recursion are chosen so that no copy takes
* place and such that lenstr < buflen.
*/
newline[0] = '\0';
int res;
if (res != 0)
return (res);
return (NSS_STR_PARSE_PARSE);
}
}
}
return (NSS_STR_PARSE_SUCCESS);
}
void
setexecattr(void)
{
}
void
endexecattr(void)
{
}
static execstr_t *
{
return (NSS_XbyY_FINI(&arg));
}
static execstr_t *
const char *type,
const char *id,
int search_flag,
char *buffer,
int buflen,
int *errnop)
{
int getby_flag;
#ifdef SI_SECPOLICY
#endif /* SI_SECPOLICY */
}
switch (getby_flag) {
case NSS_DBOP_EXECATTR_BYID:
&arg);
break;
case NSS_DBOP_EXECATTR_BYNAME:
{
goto out;
do {
/*
* search the exec_attr entry only in the scope
* that we find the profile in.
* if conf = NULL, search in local files only,
* as we were not able to read nsswitch.conf.
*/
if (mutex_lock(&_nsw_exec_lock) != 0)
goto out;
: lookups->service_name;
if (pres == NSS_SUCCESS) {
&arg);
if (pexec_root.s != NULL)
pexec_root.s,
&pexec_root);
}
&prof_root);
(void) mutex_unlock(&_nsw_exec_lock);
break;
}
break;
default:
break;
}
out:
/*
* If we can't find an entry for the current default policy
* fall back to the old "suser" policy. The nameservice is
* shared between different OS releases.
*/
if (!IS_SEARCH_ALL(search_flag) &&
goto retry_policy;
}
return (NSS_XbyY_FINI(&arg));
}
/*
* When we're in nscd, we'll concatenate all the entries and put them in
* different execattr_t's later in libc. New entries are concatenated by
* incrementing the buffer pointer saved in pe->head_exec. When look for
* duplicates, we search in the buffer from earlier calls.
*
* If we're not creating an entry to be returned over the nscd door, i.e.,
* the str2ent function isn't str2packent, we create a linked list of
* exec_attrs.
*/
extern int str2packent(const char *, int, void *, char *, int);
int
{
char *result;
int len;
char *str;
else
status = 0;
} else {
else
status = 0;
}
return (status);
}
/* Remove duplicate entries */
return (1);
}
len++;
}
return (1);
}
/*
* Converts id to a wildcard string. e.g.:
* For type = KV_ACTION: Dtfile;*;*;*;0 ---> *;*;*;*;*
*
* Returns NULL if id is already a wild-card.
*/
char *
{
return (NULL);
/*
* id = \*
*/
return (NULL);
else if (*(++pchar) == KV_WILDCHAR)
/*
*/
return (pchar);
/*
*/
return (id);
}
return (NULL);
}
static execstr_t *
{
return (NULL);
}
return (new_exec);
}
static void
{
}
}
/*
* At the end of function returning exec_attrs, we either return the
* head of list of exec_attrs or, in the case of nscd, we compute the
* full list and return that.
*/
void
{
char *result;
if (res == NSS_SUCCESS) {
}
} else {
}
return;
}
/*
* Compute the proper resultlen value from difference between
* buffer and result. Reset the buflen value and make sure
* that the final newline is stripped.
*/
}
if (res != NSS_SUCCESS)
}
getexecattr(void)
{
int err = 0;
}
{
int err = 0;
return (NULL);
}
setexecattr();
if (IS_GET_ONE(search_flag)) {
head = getexecattr();
} else if (IS_GET_ALL(search_flag)) {
head = getexecattr();
};
} else {
}
endexecattr();
return (head);
}
type,
id,
&exec,
buf,
&err);
}
int search_flag)
{
int err = 0;
return (NULL);
}
setuserattr();
/* avoid malloc by calling _getuserattr directly */
return (head);
}
if (IS_GET_ONE(search_flag)) {
} else if (IS_GET_ALL(search_flag)) {
}
if ((new =
} else {
}
}
}
} else {
}
enduserattr();
} else {
}
return (head);
}
/*
* Return the matched execattr from the list.
* A match is defined as when all of the three parameters
* match, but if a parameter is NULL or if a parameter is matched
* to a field with value NULL, it is considered to have matched.
*/
const char *id)
{
/* We have a match */
break;
}
}
return (execp);
}
void
{
}
}
typedef struct call {
const char *type;
const char *id;
int sflag;
} call;
typedef struct result {
} result;
/*ARGSUSED*/
static int
{
if (IS_GET_ONE(c->sflag)) {
return (1);
} else if (IS_GET_ALL(c->sflag)) {
} else {
}
}
}
return (0);
}
static execattr_t *
int search_flag)
{
/*
* Check if specified username is valid user
*/
return (NULL);
}
}
static execattr_t *
{
} else {
}
}
}
return (j_exec);
}
/*
* The getexecuser/getexecprof can be called with a search_flag
* GET_ONE or GET_ALL. The underlying NSS routines return execstr_ts
* and we need to convert them to execattr_ts. The NSS interface
* really allows only one result and so we need to save them.
* We use this in _doexeclist and at the end of the function we
* need to run _exec_cleanup.
* When we convert the execstr_ts to execattr_ts, we need to free the
* intermediate execstr_ts.
* The list of execstr_ts is partially allocated but partially pointing
* to the stack or to (a part of) another buffer. When we convert we
* free all memory except if they match the original result pointer;
* in that case, both the execstr_t and the strings point to memory
* allocated in another way.
*/
{
return (NULL);
}
return (NULL);
}
} else {
}
return (newexec);
}
#ifdef DEBUG
void
{
printf("attr=\n");
}
} else {
printf("NULL\n");
}
}
#endif /* DEBUG */