getexecattr.c revision cb5caa98562cf06753163f558cbcfe30b8f4673a
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <string.h>
#include <exec_attr.h>
#include "nisplus_common.h"
#include "nisplus_tables.h"
/* externs from libnsl */
extern int _doexeclist(nss_XbyY_args_t *);
extern char *_exec_wild_id(char *, const char *);
#define POLICY_LEN 128
typedef struct __exec_nisplus_args {
int check_policy;
#ifdef DEBUG
static void
{
}
}
}
}
}
}
}
}
#endif /* DEBUG */
static nss_status_t
{
int parsestat;
#ifdef DEBUG
#endif /* DEBUG */
/* passing one obj */
if (parsestat != NSS_STR_PARSE_SUCCESS)
goto fail;
/*
* If caller is nscd's switch engine, the data
* will be in argp->buf.buffer. nscd does not
* support GET_ALL at this time so return
* success from here.
*/
return (NSS_SUCCESS);
}
/*
* If the data is in be->buffer it needs
* to be marshalled.
*/
goto fail;
}
if (parsestat == NSS_STR_PARSE_SUCCESS) {
}
}
if (_doexeclist(argp) == 0)
return (NSS_UNAVAIL);
return (NSS_SUCCESS);
}
fail:
}
if (parsestat == NSS_STR_PARSE_ERANGE) {
/* We won't find this otherwise, anyway */
return (NSS_NOTFOUND);
} else if (parsestat == NSS_STR_PARSE_PARSE) {
return (NSS_NOTFOUND);
}
return (NSS_UNAVAIL);
}
/*
* check_match: returns 1 if - matching entry found and no more entries needed,
* entry cannot be found because of error;
* returns 0 if - no matching entry found,
* matching entry found and next match needed.
*/
/*ARGSUSED*/
static int
{
char *val;
#ifdef DEBUG
#endif /* DEBUG */
/*
* found one bad entry. try the next one.
*/
return (0);
}
/*
* NSS_DBOP_EXECATTR_BYNAME searched for name, NSS_DBOP_EXECATTR_BYID
* searched for id and NSS_DBOP_EXECATTR_BYNAMEID searched for name
* and id in _exec_nisplus_lookup already.
* If we're talking to pre-Solaris9 nisplus servers, check policy,
* as policy was not a searchable column then.
*/
/*
* check policy; it was not a searchable column in old servers.
*/
return (0);
}
}
if (type) {
/*
* check type
*/
return (0);
}
}
switch (res) {
case NSS_SUCCESS:
break;
case NSS_UNAVAIL:
status = 1;
break;
default:
status = 0;
break;
}
return (status);
}
static nss_status_t
int getby_flag)
{
char policy_key[POLICY_LEN];
nis_result *r = NULL;
eargs.check_policy = 0;
#ifdef DEBUG
#endif /* DEBUG */
switch (getby_flag) {
case NSS_DBOP_EXECATTR_BYNAME:
break;
case NSS_DBOP_EXECATTR_BYID:
break;
break;
default:
return (NSS_NOTFOUND);
}
return (NSS_NOTFOUND);
/*
* Try using policy as part of search key. If that fails,
* (it will, in case of pre-Solaris9 nis server where policy
* was not searchable), try again without using policy.
*/
return (NSS_NOTFOUND);
do {
(void *)&eargs);
if ((eargs.check_policy == 0) &&
nis_freeresult(r);
else
} else {
if (r != NULL)
nis_freeresult(r);
key[0] = '\0';
break;
}
} while (key[0]);
return (res);
}
/*
* If search for exact match for id failed, get_wild checks if we have
* a wild-card entry for that id.
*/
static nss_status_t
{
if (res == NSS_SUCCESS)
break;
}
if (old_id)
return (res);
}
static nss_status_t
{
#ifdef DEBUG
#endif /* DEBUG */
return (res);
}
static nss_status_t
{
#ifdef DEBUG
#endif /* DEBUG */
if (res != NSS_SUCCESS)
return (res);
}
static nss_status_t
{
#ifdef DEBUG
#endif /* DEBUG */
if (res != NSS_SUCCESS)
return (res);
}
/*
* Returns NSS_STR_PARSE_{SUCCESS, ERANGE, PARSE}
*/
/*ARGSUSED*/
static int
{
/*
* If we got more than one nis_object, we just ignore object(s) except
* the first. Although it should never have happened.
*
* ASSUMPTION: All the columns in the NIS+ tables are null terminated.
*/
return (NSS_STR_PARSE_PARSE);
}
/* profile name */
/* exec type */
/* policy */
/* reserved field 1 */
/* reserved field 2 */
/* unique id */
/* key-value pairs of attributes */
return (NSS_STR_PARSE_PARSE);
/* exclude trailing null from length */
} else {
return (NSS_STR_PARSE_ERANGE);
}
#ifdef DEBUG
#endif /* DEBUG */
return (NSS_STR_PARSE_SUCCESS);
}
static nisplus_backend_op_t execattr_ops[] = {
};
/*ARGSUSED*/
_nss_nisplus_exec_attr_constr(const char *dummy1,
const char *dummy2,
const char *dummy3,
const char *dummy4,
const char *dummy5,
const char *dummy6,
const char *dummy7)
{
return (_nss_nisplus_constr(execattr_ops,
sizeof (execattr_ops)/sizeof (execattr_ops[0]),
}