10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2830Sdjl  * Common Development and Distribution License (the "License").
6*2830Sdjl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2830Sdjl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <stdlib.h>
290Sstevel@tonic-gate #include <string.h>
300Sstevel@tonic-gate #include <sys/types.h>
310Sstevel@tonic-gate #include <exec_attr.h>
320Sstevel@tonic-gate #include <rpcsvc/ypclnt.h>
330Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
340Sstevel@tonic-gate #include "nis_common.h"
350Sstevel@tonic-gate 
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /* extern from nis_common.c */
380Sstevel@tonic-gate extern void massage_netdb(const char **, int *);
390Sstevel@tonic-gate /* externs from libnsl */
400Sstevel@tonic-gate extern int _doexeclist(nss_XbyY_args_t *);
410Sstevel@tonic-gate extern char *_exec_wild_id(char *, const char *);
420Sstevel@tonic-gate extern void _exec_cleanup(nss_status_t, nss_XbyY_args_t *);
43*2830Sdjl extern char *_strtok_escape(char *, char *, char **);
440Sstevel@tonic-gate 
450Sstevel@tonic-gate typedef struct __exec_nis_args {
460Sstevel@tonic-gate 	int		*yp_status;
470Sstevel@tonic-gate 	nss_XbyY_args_t	*argp;
480Sstevel@tonic-gate } _exec_nis_args;
490Sstevel@tonic-gate 
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * check_match: returns 1 if -  matching entry found and no more entries needed,
530Sstevel@tonic-gate  *				or, entry cannot be found because of error;
540Sstevel@tonic-gate  *		returns 0 if -  no matching entry found, or,
550Sstevel@tonic-gate  *				matching entry found and next match needed.
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate static int
580Sstevel@tonic-gate check_match(nss_XbyY_args_t *argp, int check_policy)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate 	execstr_t	*exec = (execstr_t *)(argp->returnval);
610Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
620Sstevel@tonic-gate 	const char	*name = _priv_exec->name;
630Sstevel@tonic-gate 	const char	*type = _priv_exec->type;
640Sstevel@tonic-gate 	const char	*id = _priv_exec->id;
650Sstevel@tonic-gate 	const char	*policy = _priv_exec->policy;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate 	if (name && id) {
680Sstevel@tonic-gate 		/*
690Sstevel@tonic-gate 		 * NSS_DBOP_EXECATTR_BYNAMEID searched for name and id in
700Sstevel@tonic-gate 		 * _exec_nis_lookup already.
710Sstevel@tonic-gate 		 * If we're talking to pre-Solaris9 nis servers, check policy,
720Sstevel@tonic-gate 		 * as policy was not a searchable column then.
730Sstevel@tonic-gate 		 */
740Sstevel@tonic-gate 		if ((check_policy && policy &&
750Sstevel@tonic-gate 		    (strcmp(policy, exec->policy) != 0)) ||
760Sstevel@tonic-gate 		    (type && (strcmp(type, exec->type) != 0))) {
770Sstevel@tonic-gate 			return (0);
780Sstevel@tonic-gate 		}
790Sstevel@tonic-gate 	} else if ((policy && exec->policy &&
800Sstevel@tonic-gate 	    (strcmp(policy, exec->policy) != 0)) ||
810Sstevel@tonic-gate 	    (name && exec->name && (strcmp(name, exec->name) != 0)) ||
820Sstevel@tonic-gate 	    (type && exec->type && (strcmp(type, exec->type) != 0)) ||
830Sstevel@tonic-gate 	    (id && exec->id && (strcmp(id, exec->id) != 0))) {
840Sstevel@tonic-gate 		return (0);
850Sstevel@tonic-gate 	}
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	return (1);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate 
90*2830Sdjl /*
91*2830Sdjl  * check_match_strbuf: set up the data needed by check_match()
92*2830Sdjl  * and call it to match exec_attr data in strbuf and argp->key.attrp
93*2830Sdjl  */
94*2830Sdjl static int
95*2830Sdjl check_match_strbuf(nss_XbyY_args_t *argp, char *strbuf, int check_policy)
96*2830Sdjl {
97*2830Sdjl 	char		*last = NULL;
98*2830Sdjl 	char		*sep = KV_TOKEN_DELIMIT;
99*2830Sdjl 	execstr_t	exec;
100*2830Sdjl 	execstr_t	*execp = &exec;
101*2830Sdjl 	void		*sp;
102*2830Sdjl 	int		rc;
103*2830Sdjl 
104*2830Sdjl 	/*
105*2830Sdjl 	 * Remove newline that yp_match puts at the
106*2830Sdjl 	 * end of the entry it retrieves from the map.
107*2830Sdjl 	 */
108*2830Sdjl 	if (strbuf[argp->returnlen] == '\n') {
109*2830Sdjl 		strbuf[argp->returnlen] = '\0';
110*2830Sdjl 	}
111*2830Sdjl 
112*2830Sdjl 	execp->name = _strtok_escape(strbuf, sep, &last);
113*2830Sdjl 	execp->policy = _strtok_escape(NULL, sep, &last);
114*2830Sdjl 	execp->type = _strtok_escape(NULL, sep, &last);
115*2830Sdjl 	execp->res1 = _strtok_escape(NULL, sep, &last);
116*2830Sdjl 	execp->res2 = _strtok_escape(NULL, sep, &last);
117*2830Sdjl 	execp->id = _strtok_escape(NULL, sep, &last);
118*2830Sdjl 
119*2830Sdjl 	sp = argp->returnval;
120*2830Sdjl 	argp->returnval = execp;
121*2830Sdjl 	rc = check_match(argp, check_policy);
122*2830Sdjl 	argp->returnval = sp;
123*2830Sdjl 	free(strbuf);
124*2830Sdjl 
125*2830Sdjl 	return (rc);
126*2830Sdjl }
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate static  nss_status_t
1290Sstevel@tonic-gate _exec_nis_parse(const char *instr,
1300Sstevel@tonic-gate     int instr_len,
1310Sstevel@tonic-gate     nss_XbyY_args_t *argp,
1320Sstevel@tonic-gate     int check_policy)
1330Sstevel@tonic-gate {
1340Sstevel@tonic-gate 	int		parse_stat;
1350Sstevel@tonic-gate 	nss_status_t	res;
1360Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
137*2830Sdjl 	char		*strbuf;
138*2830Sdjl 	int		check_matched;
1390Sstevel@tonic-gate 
140*2830Sdjl 	argp->returnval = NULL;
141*2830Sdjl 	argp->returnlen = 0;
1420Sstevel@tonic-gate 	parse_stat = (*argp->str2ent)(instr, instr_len, argp->buf.result,
1430Sstevel@tonic-gate 	    argp->buf.buffer, argp->buf.buflen);
1440Sstevel@tonic-gate 	switch (parse_stat) {
1450Sstevel@tonic-gate 	case NSS_STR_PARSE_SUCCESS:
146*2830Sdjl 		argp->returnlen = instr_len;
147*2830Sdjl 		/* if exec_attr file format requested */
148*2830Sdjl 		if (argp->buf.result == NULL) {
149*2830Sdjl 			argp->returnval = argp->buf.buffer;
150*2830Sdjl 			if ((strbuf = strdup(instr)) == NULL)
151*2830Sdjl 				res = NSS_UNAVAIL;
152*2830Sdjl 			check_matched = check_match_strbuf(argp,
153*2830Sdjl 				strbuf, check_policy);
154*2830Sdjl 		} else {
155*2830Sdjl 			argp->returnval = argp->buf.result;
156*2830Sdjl 			check_matched = check_match(argp, check_policy);
157*2830Sdjl 		}
158*2830Sdjl 		if (check_matched) {
1590Sstevel@tonic-gate 			res = NSS_SUCCESS;
1600Sstevel@tonic-gate 			if (_priv_exec->search_flag == GET_ALL) {
1610Sstevel@tonic-gate 				if (_doexeclist(argp) == 0) {
1620Sstevel@tonic-gate 					res = NSS_UNAVAIL;
1630Sstevel@tonic-gate 				}
1640Sstevel@tonic-gate 			}
1650Sstevel@tonic-gate 		} else {
1660Sstevel@tonic-gate 			res = NSS_NOTFOUND;
1670Sstevel@tonic-gate 		}
1680Sstevel@tonic-gate 		break;
1690Sstevel@tonic-gate 	case NSS_STR_PARSE_ERANGE:
1700Sstevel@tonic-gate 		argp->erange = 1;
1710Sstevel@tonic-gate 		res = NSS_NOTFOUND;
1720Sstevel@tonic-gate 		break;
1730Sstevel@tonic-gate 	default:
1740Sstevel@tonic-gate 		res = NSS_UNAVAIL;
1750Sstevel@tonic-gate 		break;
1760Sstevel@tonic-gate 	}
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate 	return (res);
1790Sstevel@tonic-gate }
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate /*
1820Sstevel@tonic-gate  * This is the callback for yp_all. It returns 0 to indicate that it wants to
1830Sstevel@tonic-gate  * be called again for further key-value pairs, or returns non-zero to stop the
1840Sstevel@tonic-gate  * flow of key-value pairs. If it returns a non-zero value, it is not called
1850Sstevel@tonic-gate  * again. The functional value of yp_all is then 0.
1860Sstevel@tonic-gate  */
187*2830Sdjl /*ARGSUSED*/
1880Sstevel@tonic-gate static int
1890Sstevel@tonic-gate _exec_nis_cb(int instatus,
1900Sstevel@tonic-gate     char *inkey,
1910Sstevel@tonic-gate     int inkeylen,
1920Sstevel@tonic-gate     char *inval,
1930Sstevel@tonic-gate     int invallen,
1940Sstevel@tonic-gate     void *indata)
1950Sstevel@tonic-gate {
1960Sstevel@tonic-gate 	int		check_policy = 1; /* always check policy for yp_all */
1970Sstevel@tonic-gate 	int		stop_cb;
1980Sstevel@tonic-gate 	const char	*filter;
1990Sstevel@tonic-gate 	nss_status_t	res;
2000Sstevel@tonic-gate 	_exec_nis_args	*eargp = (_exec_nis_args *)indata;
2010Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = eargp->argp;
2020Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 	if (instatus != YP_TRUE) {
2050Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_YPERR;
2060Sstevel@tonic-gate 		return (0);	/* yp_all may decide otherwise... */
2070Sstevel@tonic-gate 	}
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate 	filter = (_priv_exec->name) ? _priv_exec->name : _priv_exec->id;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 	/*
2120Sstevel@tonic-gate 	 * yp_all does not null terminate the entry it retrieves from the
2130Sstevel@tonic-gate 	 * map, unlike yp_match. so we do it explicitly here.
2140Sstevel@tonic-gate 	 */
2150Sstevel@tonic-gate 	inval[invallen] = '\0';
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate 	/*
2180Sstevel@tonic-gate 	 * Optimization:  if the entry doesn't contain the filter string then
2190Sstevel@tonic-gate 	 * it can't be the entry we want, so don't bother looking more closely
2200Sstevel@tonic-gate 	 * at it.
2210Sstevel@tonic-gate 	 */
2220Sstevel@tonic-gate 	if ((_priv_exec->policy &&
2230Sstevel@tonic-gate 	    (strstr(inval, _priv_exec->policy) == NULL)) ||
2240Sstevel@tonic-gate 	    (strstr(inval, filter) == NULL)) {
2250Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_KEY;
2260Sstevel@tonic-gate 		return (0);
2270Sstevel@tonic-gate 	}
2280Sstevel@tonic-gate 
2290Sstevel@tonic-gate 	res = _exec_nis_parse(inval, invallen, argp, check_policy);
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 	switch (res) {
2320Sstevel@tonic-gate 	case NSS_SUCCESS:
2330Sstevel@tonic-gate 		*(eargp->yp_status) = 0;
2340Sstevel@tonic-gate 		stop_cb = (_priv_exec->search_flag == GET_ONE);
2350Sstevel@tonic-gate 		break;
2360Sstevel@tonic-gate 	case NSS_UNAVAIL:
2370Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_KEY;
2380Sstevel@tonic-gate 		stop_cb = 1;
2390Sstevel@tonic-gate 		break;
2400Sstevel@tonic-gate 	default:
2410Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_YPERR;
2420Sstevel@tonic-gate 		stop_cb = 0;
2430Sstevel@tonic-gate 		break;
2440Sstevel@tonic-gate 	}
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate 	return (stop_cb);
2470Sstevel@tonic-gate }
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate static nss_status_t
2500Sstevel@tonic-gate _exec_nis_lookup(nis_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
2510Sstevel@tonic-gate {
2520Sstevel@tonic-gate 	int		ypstatus;
2530Sstevel@tonic-gate 	nss_status_t	res = NSS_SUCCESS;
2540Sstevel@tonic-gate 	nss_status_t	ypres;
2550Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate 	if (getby_flag == NSS_DBOP_EXECATTR_BYNAMEID) {
2580Sstevel@tonic-gate 		int		check_policy = 0;
2590Sstevel@tonic-gate 		int		vallen;
2600Sstevel@tonic-gate 		char		*val;
2610Sstevel@tonic-gate 		char		key[MAX_INPUT];
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate 		/*
2640Sstevel@tonic-gate 		 * Try using policy as part of search key. If that fails,
2650Sstevel@tonic-gate 		 * (it will, in case of pre-Solaris9 nis server where policy
2660Sstevel@tonic-gate 		 * was not searchable), try again without using policy.
2670Sstevel@tonic-gate 		 */
2680Sstevel@tonic-gate 		if (snprintf(key, MAX_INPUT, "%s%s%s%s%s", _priv_exec->name,
2690Sstevel@tonic-gate 		    KV_TOKEN_DELIMIT, _priv_exec->policy, KV_TOKEN_DELIMIT,
2700Sstevel@tonic-gate 		    _priv_exec->id) >= MAX_INPUT)
2710Sstevel@tonic-gate 			return (NSS_NOTFOUND);
2720Sstevel@tonic-gate 		do {
2730Sstevel@tonic-gate 			ypres = _nss_nis_ypmatch(be->domain, NIS_MAP_EXECATTR,
2740Sstevel@tonic-gate 			    key, &val, &vallen, &ypstatus);
2750Sstevel@tonic-gate 			if ((check_policy == 0) && (ypstatus == YPERR_KEY)) {
2760Sstevel@tonic-gate 				(void) snprintf(key, MAX_INPUT, "%s%s%s",
2770Sstevel@tonic-gate 				    _priv_exec->name, KV_TOKEN_DELIMIT,
2780Sstevel@tonic-gate 				    _priv_exec->id);
2790Sstevel@tonic-gate 				check_policy = 1;
2800Sstevel@tonic-gate 				continue;
2810Sstevel@tonic-gate 			} else if (ypres != NSS_SUCCESS) {
2820Sstevel@tonic-gate 				res = ypres;
2830Sstevel@tonic-gate 				break;
2840Sstevel@tonic-gate 			} else {
2850Sstevel@tonic-gate 				massage_netdb((const char **)&val, &vallen);
2860Sstevel@tonic-gate 				res = _exec_nis_parse((const char *)val,
2870Sstevel@tonic-gate 				    vallen, argp, check_policy);
2880Sstevel@tonic-gate 				break;
2890Sstevel@tonic-gate 			}
2900Sstevel@tonic-gate 		} while (res == NSS_SUCCESS);
2910Sstevel@tonic-gate 	} else {
2920Sstevel@tonic-gate 		int			ypstat = YPERR_YPERR;
2930Sstevel@tonic-gate 		struct ypall_callback	cback;
2940Sstevel@tonic-gate 		_exec_nis_args		eargs;
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 		eargs.yp_status = &ypstat;
2970Sstevel@tonic-gate 		eargs.argp = argp;
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate 		cback.foreach = _exec_nis_cb;
3000Sstevel@tonic-gate 		cback.data = (void *)&eargs;
3010Sstevel@tonic-gate 
3020Sstevel@tonic-gate 		/*
3030Sstevel@tonic-gate 		 * Instead of calling yp_all() doing hard lookup, we use
3040Sstevel@tonic-gate 		 * the alternative function, __yp_all_cflookup(), to
3050Sstevel@tonic-gate 		 * perform soft lookup when binding to nis servers with
3060Sstevel@tonic-gate 		 * time-out control. Other than that, these two functions
3070Sstevel@tonic-gate 		 * do exactly the same thing.
3080Sstevel@tonic-gate 		 */
3090Sstevel@tonic-gate 		ypstatus = __yp_all_cflookup((char *)(be->domain),
3100Sstevel@tonic-gate 			(char *)(be->enum_map), &cback, 0);
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate 		/*
3130Sstevel@tonic-gate 		 * For GET_ALL, check if we found anything at all.
3140Sstevel@tonic-gate 		 */
3150Sstevel@tonic-gate 		if (_priv_exec->head_exec != NULL)
3160Sstevel@tonic-gate 			return (NSS_SUCCESS);
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate 		switch (ypstat) {
3190Sstevel@tonic-gate 		case 0:
3200Sstevel@tonic-gate 			res = NSS_SUCCESS;
3210Sstevel@tonic-gate 			break;
3220Sstevel@tonic-gate 		case YPERR_BUSY:
3230Sstevel@tonic-gate 			res = NSS_TRYAGAIN;
3240Sstevel@tonic-gate 			break;
3250Sstevel@tonic-gate 		default:
3260Sstevel@tonic-gate 			res = NSS_UNAVAIL;
3270Sstevel@tonic-gate 			break;
3280Sstevel@tonic-gate 		}
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate 	}
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 	return (res);
3330Sstevel@tonic-gate }
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate /*
3360Sstevel@tonic-gate  * If search for exact match for id failed, get_wild checks if we have
3370Sstevel@tonic-gate  * a wild-card entry for that id.
3380Sstevel@tonic-gate  */
3390Sstevel@tonic-gate static  nss_status_t
3400Sstevel@tonic-gate get_wild(nis_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
3410Sstevel@tonic-gate {
3420Sstevel@tonic-gate 	char		*orig_id = NULL;
3430Sstevel@tonic-gate 	char		*old_id = NULL;
3440Sstevel@tonic-gate 	char		*wild_id = NULL;
3450Sstevel@tonic-gate 	nss_status_t	res = NSS_NOTFOUND;
3460Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate 	orig_id = strdup(_priv_exec->id);
3490Sstevel@tonic-gate 	old_id = strdup(_priv_exec->id);
3500Sstevel@tonic-gate 	wild_id = old_id;
3510Sstevel@tonic-gate 	while ((wild_id = _exec_wild_id(wild_id, _priv_exec->type)) != NULL) {
3520Sstevel@tonic-gate 		_priv_exec->id = wild_id;
3530Sstevel@tonic-gate 		res = _exec_nis_lookup(be, argp, getby_flag);
3540Sstevel@tonic-gate 		if (res == NSS_SUCCESS)
3550Sstevel@tonic-gate 			break;
3560Sstevel@tonic-gate 	}
3570Sstevel@tonic-gate 	_priv_exec->id = orig_id;
3580Sstevel@tonic-gate 	if (old_id)
3590Sstevel@tonic-gate 		free(old_id);
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate 	return (res);
3620Sstevel@tonic-gate }
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate static  nss_status_t
3660Sstevel@tonic-gate getbynam(nis_backend_ptr_t be, void *a)
3670Sstevel@tonic-gate {
3680Sstevel@tonic-gate 	nss_status_t	res;
3690Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYNAME);
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate 	_exec_cleanup(res, argp);
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate 	return (res);
3760Sstevel@tonic-gate }
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate static  nss_status_t
3790Sstevel@tonic-gate getbyid(nis_backend_ptr_t be, void *a)
3800Sstevel@tonic-gate {
3810Sstevel@tonic-gate 	nss_status_t	res;
3820Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
383*2830Sdjl 	/*LINTED*/
3840Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYID);
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate 	if (res != NSS_SUCCESS)
3890Sstevel@tonic-gate 		res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYID);
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 	_exec_cleanup(res, argp);
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 	return (res);
3940Sstevel@tonic-gate }
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate static  nss_status_t
3980Sstevel@tonic-gate getbynameid(nis_backend_ptr_t be, void *a)
3990Sstevel@tonic-gate {
4000Sstevel@tonic-gate 	nss_status_t	res;
4010Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
402*2830Sdjl 	/*LINTED*/
4030Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
4060Sstevel@tonic-gate 
4070Sstevel@tonic-gate 	if (res != NSS_SUCCESS)
4080Sstevel@tonic-gate 		res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate 	_exec_cleanup(res, argp);
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate 	return (res);
4130Sstevel@tonic-gate }
4140Sstevel@tonic-gate 
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate static nis_backend_op_t execattr_ops[] = {
4170Sstevel@tonic-gate 	_nss_nis_destr,
4180Sstevel@tonic-gate 	_nss_nis_endent,
4190Sstevel@tonic-gate 	_nss_nis_setent,
4200Sstevel@tonic-gate 	_nss_nis_getent_netdb,
4210Sstevel@tonic-gate 	getbynam,
4220Sstevel@tonic-gate 	getbyid,
4230Sstevel@tonic-gate 	getbynameid
4240Sstevel@tonic-gate };
4250Sstevel@tonic-gate 
426*2830Sdjl /*ARGSUSED*/
4270Sstevel@tonic-gate nss_backend_t *
4280Sstevel@tonic-gate _nss_nis_exec_attr_constr(const char *dummy1,
4290Sstevel@tonic-gate     const char *dummy2,
4300Sstevel@tonic-gate     const char *dummy3,
4310Sstevel@tonic-gate     const char *dummy4,
4320Sstevel@tonic-gate     const char *dummy5,
4330Sstevel@tonic-gate     const char *dummy6,
4340Sstevel@tonic-gate     const char *dummy7)
4350Sstevel@tonic-gate {
4360Sstevel@tonic-gate 	return (_nss_nis_constr(execattr_ops,
4370Sstevel@tonic-gate 		sizeof (execattr_ops)/sizeof (execattr_ops[0]),
4380Sstevel@tonic-gate 		NIS_MAP_EXECATTR));
4390Sstevel@tonic-gate }
440