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
52830Sdjl  * Common Development and Distribution License (the "License").
62830Sdjl  * 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*3610Ssdussud  * Copyright 2007 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 *);
432830Sdjl 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 
902830Sdjl /*
912830Sdjl  * check_match_strbuf: set up the data needed by check_match()
922830Sdjl  * and call it to match exec_attr data in strbuf and argp->key.attrp
932830Sdjl  */
942830Sdjl static int
952830Sdjl check_match_strbuf(nss_XbyY_args_t *argp, char *strbuf, int check_policy)
962830Sdjl {
972830Sdjl 	char		*last = NULL;
982830Sdjl 	char		*sep = KV_TOKEN_DELIMIT;
992830Sdjl 	execstr_t	exec;
1002830Sdjl 	execstr_t	*execp = &exec;
1012830Sdjl 	void		*sp;
1022830Sdjl 	int		rc;
1032830Sdjl 
1042830Sdjl 	/*
1052830Sdjl 	 * Remove newline that yp_match puts at the
1062830Sdjl 	 * end of the entry it retrieves from the map.
1072830Sdjl 	 */
1082830Sdjl 	if (strbuf[argp->returnlen] == '\n') {
1092830Sdjl 		strbuf[argp->returnlen] = '\0';
1102830Sdjl 	}
1112830Sdjl 
1122830Sdjl 	execp->name = _strtok_escape(strbuf, sep, &last);
1132830Sdjl 	execp->policy = _strtok_escape(NULL, sep, &last);
1142830Sdjl 	execp->type = _strtok_escape(NULL, sep, &last);
1152830Sdjl 	execp->res1 = _strtok_escape(NULL, sep, &last);
1162830Sdjl 	execp->res2 = _strtok_escape(NULL, sep, &last);
1172830Sdjl 	execp->id = _strtok_escape(NULL, sep, &last);
1182830Sdjl 
1192830Sdjl 	sp = argp->returnval;
1202830Sdjl 	argp->returnval = execp;
1212830Sdjl 	rc = check_match(argp, check_policy);
1222830Sdjl 	argp->returnval = sp;
1232830Sdjl 	free(strbuf);
1242830Sdjl 
1252830Sdjl 	return (rc);
1262830Sdjl }
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);
1372830Sdjl 	char		*strbuf;
1382830Sdjl 	int		check_matched;
1390Sstevel@tonic-gate 
1402830Sdjl 	argp->returnval = NULL;
1412830Sdjl 	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:
1462830Sdjl 		argp->returnlen = instr_len;
1472830Sdjl 		/* if exec_attr file format requested */
1482830Sdjl 		if (argp->buf.result == NULL) {
1492830Sdjl 			argp->returnval = argp->buf.buffer;
1502830Sdjl 			if ((strbuf = strdup(instr)) == NULL)
1512830Sdjl 				res = NSS_UNAVAIL;
1522830Sdjl 			check_matched = check_match_strbuf(argp,
1532830Sdjl 				strbuf, check_policy);
1542830Sdjl 		} else {
1552830Sdjl 			argp->returnval = argp->buf.result;
1562830Sdjl 			check_matched = check_match(argp, check_policy);
1572830Sdjl 		}
1582830Sdjl 		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  */
1872830Sdjl /*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) {
205*3610Ssdussud 		/*
206*3610Ssdussud 		 * If we have no more data to look at, we want to
207*3610Ssdussud 		 * keep yp_status from previous key/value pair
208*3610Ssdussud 		 * that we processed.
209*3610Ssdussud 		 * If this is the 1st time we enter this callback,
210*3610Ssdussud 		 * yp_status is already set to YPERR_YPERR
211*3610Ssdussud 		 * (see _exec_nis_lookup() for when this callback
212*3610Ssdussud 		 * and arguments are set initially).
213*3610Ssdussud 		 */
214*3610Ssdussud 		if (instatus != YP_NOMORE) {
215*3610Ssdussud 			*(eargp->yp_status) = YPERR_YPERR;
216*3610Ssdussud 		}
2170Sstevel@tonic-gate 		return (0);	/* yp_all may decide otherwise... */
2180Sstevel@tonic-gate 	}
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate 	filter = (_priv_exec->name) ? _priv_exec->name : _priv_exec->id;
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate 	/*
2230Sstevel@tonic-gate 	 * yp_all does not null terminate the entry it retrieves from the
2240Sstevel@tonic-gate 	 * map, unlike yp_match. so we do it explicitly here.
2250Sstevel@tonic-gate 	 */
2260Sstevel@tonic-gate 	inval[invallen] = '\0';
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate 	/*
2290Sstevel@tonic-gate 	 * Optimization:  if the entry doesn't contain the filter string then
2300Sstevel@tonic-gate 	 * it can't be the entry we want, so don't bother looking more closely
2310Sstevel@tonic-gate 	 * at it.
2320Sstevel@tonic-gate 	 */
2330Sstevel@tonic-gate 	if ((_priv_exec->policy &&
2340Sstevel@tonic-gate 	    (strstr(inval, _priv_exec->policy) == NULL)) ||
2350Sstevel@tonic-gate 	    (strstr(inval, filter) == NULL)) {
2360Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_KEY;
2370Sstevel@tonic-gate 		return (0);
2380Sstevel@tonic-gate 	}
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate 	res = _exec_nis_parse(inval, invallen, argp, check_policy);
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate 	switch (res) {
2430Sstevel@tonic-gate 	case NSS_SUCCESS:
2440Sstevel@tonic-gate 		*(eargp->yp_status) = 0;
2450Sstevel@tonic-gate 		stop_cb = (_priv_exec->search_flag == GET_ONE);
2460Sstevel@tonic-gate 		break;
2470Sstevel@tonic-gate 	case NSS_UNAVAIL:
2480Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_KEY;
2490Sstevel@tonic-gate 		stop_cb = 1;
2500Sstevel@tonic-gate 		break;
2510Sstevel@tonic-gate 	default:
2520Sstevel@tonic-gate 		*(eargp->yp_status) = YPERR_YPERR;
2530Sstevel@tonic-gate 		stop_cb = 0;
2540Sstevel@tonic-gate 		break;
2550Sstevel@tonic-gate 	}
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate 	return (stop_cb);
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate static nss_status_t
2610Sstevel@tonic-gate _exec_nis_lookup(nis_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
2620Sstevel@tonic-gate {
2630Sstevel@tonic-gate 	int		ypstatus;
2640Sstevel@tonic-gate 	nss_status_t	res = NSS_SUCCESS;
2650Sstevel@tonic-gate 	nss_status_t	ypres;
2660Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate 	if (getby_flag == NSS_DBOP_EXECATTR_BYNAMEID) {
2690Sstevel@tonic-gate 		int		check_policy = 0;
2700Sstevel@tonic-gate 		int		vallen;
2710Sstevel@tonic-gate 		char		*val;
2720Sstevel@tonic-gate 		char		key[MAX_INPUT];
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate 		/*
2750Sstevel@tonic-gate 		 * Try using policy as part of search key. If that fails,
2760Sstevel@tonic-gate 		 * (it will, in case of pre-Solaris9 nis server where policy
2770Sstevel@tonic-gate 		 * was not searchable), try again without using policy.
2780Sstevel@tonic-gate 		 */
2790Sstevel@tonic-gate 		if (snprintf(key, MAX_INPUT, "%s%s%s%s%s", _priv_exec->name,
2800Sstevel@tonic-gate 		    KV_TOKEN_DELIMIT, _priv_exec->policy, KV_TOKEN_DELIMIT,
2810Sstevel@tonic-gate 		    _priv_exec->id) >= MAX_INPUT)
2820Sstevel@tonic-gate 			return (NSS_NOTFOUND);
2830Sstevel@tonic-gate 		do {
2840Sstevel@tonic-gate 			ypres = _nss_nis_ypmatch(be->domain, NIS_MAP_EXECATTR,
2850Sstevel@tonic-gate 			    key, &val, &vallen, &ypstatus);
2860Sstevel@tonic-gate 			if ((check_policy == 0) && (ypstatus == YPERR_KEY)) {
2870Sstevel@tonic-gate 				(void) snprintf(key, MAX_INPUT, "%s%s%s",
2880Sstevel@tonic-gate 				    _priv_exec->name, KV_TOKEN_DELIMIT,
2890Sstevel@tonic-gate 				    _priv_exec->id);
2900Sstevel@tonic-gate 				check_policy = 1;
2910Sstevel@tonic-gate 				continue;
2920Sstevel@tonic-gate 			} else if (ypres != NSS_SUCCESS) {
2930Sstevel@tonic-gate 				res = ypres;
2940Sstevel@tonic-gate 				break;
2950Sstevel@tonic-gate 			} else {
2963176Smichen 				char *val_save = val;
2973176Smichen 
2980Sstevel@tonic-gate 				massage_netdb((const char **)&val, &vallen);
2990Sstevel@tonic-gate 				res = _exec_nis_parse((const char *)val,
3000Sstevel@tonic-gate 				    vallen, argp, check_policy);
3013176Smichen 				free(val_save);
3020Sstevel@tonic-gate 				break;
3030Sstevel@tonic-gate 			}
3040Sstevel@tonic-gate 		} while (res == NSS_SUCCESS);
3050Sstevel@tonic-gate 	} else {
3060Sstevel@tonic-gate 		int			ypstat = YPERR_YPERR;
3070Sstevel@tonic-gate 		struct ypall_callback	cback;
3080Sstevel@tonic-gate 		_exec_nis_args		eargs;
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 		eargs.yp_status = &ypstat;
3110Sstevel@tonic-gate 		eargs.argp = argp;
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate 		cback.foreach = _exec_nis_cb;
3140Sstevel@tonic-gate 		cback.data = (void *)&eargs;
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate 		/*
3170Sstevel@tonic-gate 		 * Instead of calling yp_all() doing hard lookup, we use
3180Sstevel@tonic-gate 		 * the alternative function, __yp_all_cflookup(), to
3190Sstevel@tonic-gate 		 * perform soft lookup when binding to nis servers with
3200Sstevel@tonic-gate 		 * time-out control. Other than that, these two functions
3210Sstevel@tonic-gate 		 * do exactly the same thing.
3220Sstevel@tonic-gate 		 */
3230Sstevel@tonic-gate 		ypstatus = __yp_all_cflookup((char *)(be->domain),
3240Sstevel@tonic-gate 			(char *)(be->enum_map), &cback, 0);
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate 		/*
3270Sstevel@tonic-gate 		 * For GET_ALL, check if we found anything at all.
3280Sstevel@tonic-gate 		 */
3290Sstevel@tonic-gate 		if (_priv_exec->head_exec != NULL)
3300Sstevel@tonic-gate 			return (NSS_SUCCESS);
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 		switch (ypstat) {
3330Sstevel@tonic-gate 		case 0:
3340Sstevel@tonic-gate 			res = NSS_SUCCESS;
3350Sstevel@tonic-gate 			break;
3360Sstevel@tonic-gate 		case YPERR_BUSY:
3370Sstevel@tonic-gate 			res = NSS_TRYAGAIN;
3380Sstevel@tonic-gate 			break;
339*3610Ssdussud 		case YPERR_KEY:
340*3610Ssdussud 			/*
341*3610Ssdussud 			 * If no such key, return NSS_NOTFOUND
342*3610Ssdussud 			 * as this looks more relevant; it will
343*3610Ssdussud 			 * also help libnsl to try with another
344*3610Ssdussud 			 * policy (see _getexecprof()).
345*3610Ssdussud 			 */
346*3610Ssdussud 			res = NSS_NOTFOUND;
347*3610Ssdussud 			break;
3480Sstevel@tonic-gate 		default:
3490Sstevel@tonic-gate 			res = NSS_UNAVAIL;
3500Sstevel@tonic-gate 			break;
3510Sstevel@tonic-gate 		}
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate 	}
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate 	return (res);
3560Sstevel@tonic-gate }
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate /*
3590Sstevel@tonic-gate  * If search for exact match for id failed, get_wild checks if we have
3600Sstevel@tonic-gate  * a wild-card entry for that id.
3610Sstevel@tonic-gate  */
3620Sstevel@tonic-gate static  nss_status_t
3630Sstevel@tonic-gate get_wild(nis_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
3640Sstevel@tonic-gate {
3653176Smichen 	const char	*orig_id;
3660Sstevel@tonic-gate 	char		*old_id = NULL;
3670Sstevel@tonic-gate 	char		*wild_id = NULL;
3680Sstevel@tonic-gate 	nss_status_t	res = NSS_NOTFOUND;
3690Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
3700Sstevel@tonic-gate 
3713176Smichen 	orig_id = _priv_exec->id;
3720Sstevel@tonic-gate 	old_id = strdup(_priv_exec->id);
3730Sstevel@tonic-gate 	wild_id = old_id;
3740Sstevel@tonic-gate 	while ((wild_id = _exec_wild_id(wild_id, _priv_exec->type)) != NULL) {
3750Sstevel@tonic-gate 		_priv_exec->id = wild_id;
3760Sstevel@tonic-gate 		res = _exec_nis_lookup(be, argp, getby_flag);
3770Sstevel@tonic-gate 		if (res == NSS_SUCCESS)
3780Sstevel@tonic-gate 			break;
3790Sstevel@tonic-gate 	}
3800Sstevel@tonic-gate 	_priv_exec->id = orig_id;
3810Sstevel@tonic-gate 	if (old_id)
3820Sstevel@tonic-gate 		free(old_id);
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate 	return (res);
3850Sstevel@tonic-gate }
3860Sstevel@tonic-gate 
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate static  nss_status_t
3890Sstevel@tonic-gate getbynam(nis_backend_ptr_t be, void *a)
3900Sstevel@tonic-gate {
3910Sstevel@tonic-gate 	nss_status_t	res;
3920Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYNAME);
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate 	_exec_cleanup(res, argp);
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate 	return (res);
3990Sstevel@tonic-gate }
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate static  nss_status_t
4020Sstevel@tonic-gate getbyid(nis_backend_ptr_t be, void *a)
4030Sstevel@tonic-gate {
4040Sstevel@tonic-gate 	nss_status_t	res;
4050Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
4062830Sdjl 	/*LINTED*/
4070Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
4080Sstevel@tonic-gate 
4090Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYID);
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate 	if (res != NSS_SUCCESS)
4120Sstevel@tonic-gate 		res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYID);
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate 	_exec_cleanup(res, argp);
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate 	return (res);
4170Sstevel@tonic-gate }
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate static  nss_status_t
4210Sstevel@tonic-gate getbynameid(nis_backend_ptr_t be, void *a)
4220Sstevel@tonic-gate {
4230Sstevel@tonic-gate 	nss_status_t	res;
4240Sstevel@tonic-gate 	nss_XbyY_args_t	*argp = (nss_XbyY_args_t *)a;
4252830Sdjl 	/*LINTED*/
4260Sstevel@tonic-gate 	_priv_execattr	*_priv_exec = (_priv_execattr *)(argp->key.attrp);
4270Sstevel@tonic-gate 
4280Sstevel@tonic-gate 	res = _exec_nis_lookup(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
4290Sstevel@tonic-gate 
4300Sstevel@tonic-gate 	if (res != NSS_SUCCESS)
4310Sstevel@tonic-gate 		res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate 	_exec_cleanup(res, argp);
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate 	return (res);
4360Sstevel@tonic-gate }
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate static nis_backend_op_t execattr_ops[] = {
4400Sstevel@tonic-gate 	_nss_nis_destr,
4410Sstevel@tonic-gate 	_nss_nis_endent,
4420Sstevel@tonic-gate 	_nss_nis_setent,
4430Sstevel@tonic-gate 	_nss_nis_getent_netdb,
4440Sstevel@tonic-gate 	getbynam,
4450Sstevel@tonic-gate 	getbyid,
4460Sstevel@tonic-gate 	getbynameid
4470Sstevel@tonic-gate };
4480Sstevel@tonic-gate 
4492830Sdjl /*ARGSUSED*/
4500Sstevel@tonic-gate nss_backend_t *
4510Sstevel@tonic-gate _nss_nis_exec_attr_constr(const char *dummy1,
4520Sstevel@tonic-gate     const char *dummy2,
4530Sstevel@tonic-gate     const char *dummy3,
4540Sstevel@tonic-gate     const char *dummy4,
4550Sstevel@tonic-gate     const char *dummy5,
4560Sstevel@tonic-gate     const char *dummy6,
4570Sstevel@tonic-gate     const char *dummy7)
4580Sstevel@tonic-gate {
4590Sstevel@tonic-gate 	return (_nss_nis_constr(execattr_ops,
4600Sstevel@tonic-gate 		sizeof (execattr_ops)/sizeof (execattr_ops[0]),
4610Sstevel@tonic-gate 		NIS_MAP_EXECATTR));
4620Sstevel@tonic-gate }
463