17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5004388ebScasper * Common Development and Distribution License (the "License").
6004388ebScasper * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*b86d8771SCasper H.S. Dik * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate */
247c478bd9Sstevel@tonic-gate
257c478bd9Sstevel@tonic-gate #include <stdlib.h>
267c478bd9Sstevel@tonic-gate #include "files_common.h"
277c478bd9Sstevel@tonic-gate #include <time.h>
287c478bd9Sstevel@tonic-gate #include <exec_attr.h>
297c478bd9Sstevel@tonic-gate #include <strings.h>
307c478bd9Sstevel@tonic-gate #include <sys/stat.h>
317c478bd9Sstevel@tonic-gate #include <sys/mman.h>
327c478bd9Sstevel@tonic-gate #include <ctype.h>
337c478bd9Sstevel@tonic-gate #include <synch.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <sys/uio.h>
367c478bd9Sstevel@tonic-gate #include <unistd.h>
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate * files/getexecattr.c -- "files" backend for nsswitch "exec_attr" database
407c478bd9Sstevel@tonic-gate *
417c478bd9Sstevel@tonic-gate * _execattr_files_read_line and _execattr_files_XY_all code based on
427c478bd9Sstevel@tonic-gate * nss_files_read_line and nss_files_XY_all respectively, from files_common.c
437c478bd9Sstevel@tonic-gate */
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate /* externs from libnsl */
477c478bd9Sstevel@tonic-gate extern int _doexeclist(nss_XbyY_args_t *);
487c478bd9Sstevel@tonic-gate extern int _readbufline(char *, int, char *, int, int *);
497c478bd9Sstevel@tonic-gate extern char *_exec_wild_id(char *, const char *);
507c478bd9Sstevel@tonic-gate extern void _exec_cleanup(nss_status_t, nss_XbyY_args_t *);
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate * check_match: returns 1 if matching entry found, else returns 0.
557c478bd9Sstevel@tonic-gate */
567c478bd9Sstevel@tonic-gate static int
check_match(nss_XbyY_args_t * argp,const char * line,int linelen)57cb5caa98Sdjl check_match(nss_XbyY_args_t *argp, const char *line, int linelen)
587c478bd9Sstevel@tonic-gate {
59cb5caa98Sdjl const char *limit, *linep, *keyp;
607c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
61cb5caa98Sdjl const char *exec_field[6];
62cb5caa98Sdjl int i;
637c478bd9Sstevel@tonic-gate
64cb5caa98Sdjl exec_field[0] = _priv_exec->name; /* name */
65cb5caa98Sdjl exec_field[1] = _priv_exec->policy; /* policy */
66cb5caa98Sdjl exec_field[2] = _priv_exec->type; /* type */
67cb5caa98Sdjl exec_field[3] = NULL; /* res1 */
68cb5caa98Sdjl exec_field[4] = NULL; /* res2 */
69cb5caa98Sdjl exec_field[5] = _priv_exec->id; /* id */
70cb5caa98Sdjl /* No need to check attr field */
71cb5caa98Sdjl
72cb5caa98Sdjl linep = line;
73cb5caa98Sdjl limit = line + linelen;
74cb5caa98Sdjl
75cb5caa98Sdjl for (i = 0; i < 6; i++) {
76cb5caa98Sdjl keyp = exec_field[i];
77cb5caa98Sdjl if (keyp) {
78cb5caa98Sdjl /* compare field */
79cb5caa98Sdjl while (*keyp && linep < limit &&
80cb5caa98Sdjl *linep != ':' && *keyp == *linep) {
81cb5caa98Sdjl keyp++;
82cb5caa98Sdjl linep++;
837c478bd9Sstevel@tonic-gate }
84cb5caa98Sdjl if (*keyp || linep == limit || *linep != ':')
85cb5caa98Sdjl return (0);
86cb5caa98Sdjl } else {
87cb5caa98Sdjl /* skip field */
88cb5caa98Sdjl while (linep < limit && *linep != ':')
89cb5caa98Sdjl linep++;
90cb5caa98Sdjl }
91cb5caa98Sdjl linep++;
92cb5caa98Sdjl }
937c478bd9Sstevel@tonic-gate return (1);
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate static nss_status_t
_exec_files_XY_all(files_backend_ptr_t be,nss_XbyY_args_t * argp,int getby_flag)987c478bd9Sstevel@tonic-gate _exec_files_XY_all(files_backend_ptr_t be,
997c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp,
1007c478bd9Sstevel@tonic-gate int getby_flag)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate int parse_stat = 0;
1037c478bd9Sstevel@tonic-gate int lastlen = 0;
1047c478bd9Sstevel@tonic-gate int exec_fd = 0;
1057c478bd9Sstevel@tonic-gate int f_size = 0;
1067c478bd9Sstevel@tonic-gate time_t f_time = 0;
1077c478bd9Sstevel@tonic-gate static time_t read_time = 0;
1087c478bd9Sstevel@tonic-gate char *first;
1097c478bd9Sstevel@tonic-gate char *last;
1107c478bd9Sstevel@tonic-gate static char *f_buf = NULL;
1117c478bd9Sstevel@tonic-gate struct stat f_stat;
1127c478bd9Sstevel@tonic-gate nss_status_t res = NSS_NOTFOUND;
1137c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
1147c478bd9Sstevel@tonic-gate static rwlock_t exec_lock;
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate if (((be->buf == NULL) &&
1177c478bd9Sstevel@tonic-gate ((be->buf = (char *)calloc(1, be->minbuf)) == NULL)) ||
1187c478bd9Sstevel@tonic-gate (be->filename == NULL) ||
1197c478bd9Sstevel@tonic-gate (rw_rdlock(&exec_lock) != 0)) {
1207c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate * check the size and the time stamp on the file
1257c478bd9Sstevel@tonic-gate */
1267c478bd9Sstevel@tonic-gate if (stat(be->filename, &f_stat) != 0) {
1277c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1287c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1297c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate f_size = f_stat.st_size;
1337c478bd9Sstevel@tonic-gate f_time = f_stat.st_mtime;
1347c478bd9Sstevel@tonic-gate
135*b86d8771SCasper H.S. Dik while (f_time > read_time || f_buf == NULL) {
1367c478bd9Sstevel@tonic-gate /*
137*b86d8771SCasper H.S. Dik * file has been modified since we last read it
138*b86d8771SCasper H.S. Dik * or we never read it or memory allocation
139*b86d8771SCasper H.S. Dik * failed before.
1407c478bd9Sstevel@tonic-gate * read it into the buffer with rw lock.
1417c478bd9Sstevel@tonic-gate */
1427c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1437c478bd9Sstevel@tonic-gate if (rw_wrlock(&exec_lock) != 0) {
1447c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1457c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1467c478bd9Sstevel@tonic-gate }
147004388ebScasper if ((be->f = fopen(be->filename, "rF")) == 0) {
1487c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1497c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1507c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1517c478bd9Sstevel@tonic-gate }
152004388ebScasper exec_fd = fileno(be->f);
1537c478bd9Sstevel@tonic-gate if (f_buf != NULL)
1547c478bd9Sstevel@tonic-gate free(f_buf);
1557c478bd9Sstevel@tonic-gate if ((f_buf = malloc(f_size)) == NULL) {
1567c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1577c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1587c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1597c478bd9Sstevel@tonic-gate }
1607c478bd9Sstevel@tonic-gate if (read(exec_fd, f_buf, f_size) < f_size) {
1617c478bd9Sstevel@tonic-gate free(f_buf);
1627c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1637c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1647c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate read_time = f_time;
1677c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate * verify that the file did not change after
1707c478bd9Sstevel@tonic-gate * we read it.
1717c478bd9Sstevel@tonic-gate */
1727c478bd9Sstevel@tonic-gate if (rw_rdlock(&exec_lock) != 0) {
1737c478bd9Sstevel@tonic-gate free(f_buf);
1747c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1757c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate if (stat(be->filename, &f_stat) != 0) {
1787c478bd9Sstevel@tonic-gate free(f_buf);
1797c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1807c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1817c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate f_size = f_stat.st_size;
1847c478bd9Sstevel@tonic-gate f_time = f_stat.st_mtime;
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate res = NSS_NOTFOUND;
188cb5caa98Sdjl /*CONSTCOND*/
1897c478bd9Sstevel@tonic-gate while (1) {
1907c478bd9Sstevel@tonic-gate int linelen = 0;
1917c478bd9Sstevel@tonic-gate char *instr = be->buf;
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate linelen = _readbufline(f_buf, f_size, instr, be->minbuf,
1947c478bd9Sstevel@tonic-gate &lastlen);
1957c478bd9Sstevel@tonic-gate if (linelen < 0) {
1967c478bd9Sstevel@tonic-gate /* End of file */
1977c478bd9Sstevel@tonic-gate break;
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate * If the entry doesn't contain the filter string then
2027c478bd9Sstevel@tonic-gate * it can't be the entry we want, so don't bother looking
2037c478bd9Sstevel@tonic-gate * more closely at it.
2047c478bd9Sstevel@tonic-gate */
2057c478bd9Sstevel@tonic-gate switch (getby_flag) {
2067c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYNAME:
2077c478bd9Sstevel@tonic-gate if (strstr(instr, _priv_exec->name) == NULL)
2087c478bd9Sstevel@tonic-gate continue;
2097c478bd9Sstevel@tonic-gate break;
2107c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYID:
2117c478bd9Sstevel@tonic-gate if (strstr(instr, _priv_exec->id) == NULL)
2127c478bd9Sstevel@tonic-gate continue;
2137c478bd9Sstevel@tonic-gate break;
2147c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYNAMEID:
2157c478bd9Sstevel@tonic-gate if ((strstr(instr, _priv_exec->name) == NULL) ||
2167c478bd9Sstevel@tonic-gate (strstr(instr, _priv_exec->id) == NULL))
2177c478bd9Sstevel@tonic-gate continue;
2187c478bd9Sstevel@tonic-gate break;
2197c478bd9Sstevel@tonic-gate default:
2207c478bd9Sstevel@tonic-gate break;
2217c478bd9Sstevel@tonic-gate }
22201ef659dSJoep Vesseur if (((_priv_exec->policy != NULL) &&
22301ef659dSJoep Vesseur (strstr(instr, _priv_exec->policy) == NULL)) ||
2247c478bd9Sstevel@tonic-gate ((_priv_exec->type != NULL) &&
2257c478bd9Sstevel@tonic-gate (strstr(instr, _priv_exec->type) == NULL)))
2267c478bd9Sstevel@tonic-gate continue;
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate /*
2297c478bd9Sstevel@tonic-gate * Get rid of white spaces, comments etc.
2307c478bd9Sstevel@tonic-gate */
2317c478bd9Sstevel@tonic-gate if ((last = strchr(instr, '#')) == NULL)
2327c478bd9Sstevel@tonic-gate last = instr + linelen;
2337c478bd9Sstevel@tonic-gate *last-- = '\0'; /* Nuke '\n' or #comment */
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate * Skip leading whitespace. Normally there isn't any,
2367c478bd9Sstevel@tonic-gate * so it's not worth calling strspn().
2377c478bd9Sstevel@tonic-gate */
2387c478bd9Sstevel@tonic-gate for (first = instr; isspace(*first); first++)
2397c478bd9Sstevel@tonic-gate ;
2407c478bd9Sstevel@tonic-gate if (*first == '\0')
2417c478bd9Sstevel@tonic-gate continue;
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate * Found something non-blank on the line. Skip back
2447c478bd9Sstevel@tonic-gate * over any trailing whitespace; since we know there's
2457c478bd9Sstevel@tonic-gate * non-whitespace earlier in the line, checking for
2467c478bd9Sstevel@tonic-gate * termination is easy.
2477c478bd9Sstevel@tonic-gate */
2487c478bd9Sstevel@tonic-gate while (isspace(*last))
2497c478bd9Sstevel@tonic-gate --last;
2507c478bd9Sstevel@tonic-gate linelen = last - first + 1;
2517c478bd9Sstevel@tonic-gate if (first != instr)
2527c478bd9Sstevel@tonic-gate instr = first;
2537c478bd9Sstevel@tonic-gate
254cb5caa98Sdjl /* Check the entry */
2557c478bd9Sstevel@tonic-gate argp->returnval = NULL;
256cb5caa98Sdjl argp->returnlen = 0;
257cb5caa98Sdjl if (check_match(argp, instr, linelen) == 0)
258cb5caa98Sdjl continue;
259cb5caa98Sdjl
260cb5caa98Sdjl /* Marshall the data */
2617c478bd9Sstevel@tonic-gate parse_stat = (*argp->str2ent)(instr, linelen, argp->buf.result,
2627c478bd9Sstevel@tonic-gate argp->buf.buffer, argp->buf.buflen);
2637c478bd9Sstevel@tonic-gate if (parse_stat == NSS_STR_PARSE_SUCCESS) {
264cb5caa98Sdjl argp->returnval = (argp->buf.result != NULL)?
265cb5caa98Sdjl argp->buf.result : argp->buf.buffer;
266cb5caa98Sdjl argp->returnlen = linelen;
2677c478bd9Sstevel@tonic-gate res = NSS_SUCCESS;
26801ef659dSJoep Vesseur if (IS_GET_ONE(_priv_exec->search_flag)) {
2697c478bd9Sstevel@tonic-gate break;
2707c478bd9Sstevel@tonic-gate } else if (_doexeclist(argp) == 0) {
2717c478bd9Sstevel@tonic-gate res = NSS_UNAVAIL;
2727c478bd9Sstevel@tonic-gate break;
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate } else if (parse_stat == NSS_STR_PARSE_ERANGE) {
2757c478bd9Sstevel@tonic-gate argp->erange = 1;
2767c478bd9Sstevel@tonic-gate break;
2777c478bd9Sstevel@tonic-gate } /* else if (parse_stat == NSS_STR_PARSE_PARSE) don't care ! */
2787c478bd9Sstevel@tonic-gate }
2797c478bd9Sstevel@tonic-gate
2807c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
2817c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gate return (res);
2847c478bd9Sstevel@tonic-gate }
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate /*
2887c478bd9Sstevel@tonic-gate * If search for exact match for id failed, get_wild checks if we have
2897c478bd9Sstevel@tonic-gate * a wild-card entry for that id.
2907c478bd9Sstevel@tonic-gate */
2917c478bd9Sstevel@tonic-gate static nss_status_t
get_wild(files_backend_ptr_t be,nss_XbyY_args_t * argp,int getby_flag)2927c478bd9Sstevel@tonic-gate get_wild(files_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
2937c478bd9Sstevel@tonic-gate {
294cb5caa98Sdjl const char *orig_id = NULL;
2957c478bd9Sstevel@tonic-gate char *old_id = NULL;
2967c478bd9Sstevel@tonic-gate char *wild_id = NULL;
2977c478bd9Sstevel@tonic-gate nss_status_t res = NSS_NOTFOUND;
2987c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
2997c478bd9Sstevel@tonic-gate
300cb5caa98Sdjl orig_id = _priv_exec->id;
3017c478bd9Sstevel@tonic-gate old_id = strdup(_priv_exec->id);
3027c478bd9Sstevel@tonic-gate wild_id = old_id;
3037c478bd9Sstevel@tonic-gate while ((wild_id = _exec_wild_id(wild_id, _priv_exec->type)) != NULL) {
3047c478bd9Sstevel@tonic-gate _priv_exec->id = wild_id;
3057c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, getby_flag);
3067c478bd9Sstevel@tonic-gate if (res == NSS_SUCCESS)
3077c478bd9Sstevel@tonic-gate break;
3087c478bd9Sstevel@tonic-gate }
3097c478bd9Sstevel@tonic-gate _priv_exec->id = orig_id;
3107c478bd9Sstevel@tonic-gate if (old_id)
3117c478bd9Sstevel@tonic-gate free(old_id);
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gate return (res);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate static nss_status_t
getbynam(files_backend_ptr_t be,void * a)3187c478bd9Sstevel@tonic-gate getbynam(files_backend_ptr_t be, void *a)
3197c478bd9Sstevel@tonic-gate {
3207c478bd9Sstevel@tonic-gate nss_status_t res;
3217c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYNAME);
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate return (res);
3287c478bd9Sstevel@tonic-gate }
3297c478bd9Sstevel@tonic-gate
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate static nss_status_t
getbyid(files_backend_ptr_t be,void * a)3327c478bd9Sstevel@tonic-gate getbyid(files_backend_ptr_t be, void *a)
3337c478bd9Sstevel@tonic-gate {
3347c478bd9Sstevel@tonic-gate nss_status_t res;
3357c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
336cb5caa98Sdjl /*LINTED*/
3377c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
3387c478bd9Sstevel@tonic-gate
3397c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYID);
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate if (res != NSS_SUCCESS)
3427c478bd9Sstevel@tonic-gate res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYID);
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gate return (res);
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate
3507c478bd9Sstevel@tonic-gate static nss_status_t
getbynameid(files_backend_ptr_t be,void * a)3517c478bd9Sstevel@tonic-gate getbynameid(files_backend_ptr_t be, void *a)
3527c478bd9Sstevel@tonic-gate {
3537c478bd9Sstevel@tonic-gate nss_status_t res;
3547c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
355cb5caa98Sdjl /*LINTED*/
3567c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
3577c478bd9Sstevel@tonic-gate
3587c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
3597c478bd9Sstevel@tonic-gate
3607c478bd9Sstevel@tonic-gate if (res != NSS_SUCCESS)
3617c478bd9Sstevel@tonic-gate res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate return (res);
3667c478bd9Sstevel@tonic-gate }
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate
3697c478bd9Sstevel@tonic-gate static files_backend_op_t execattr_ops[] = {
3707c478bd9Sstevel@tonic-gate _nss_files_destr,
3717c478bd9Sstevel@tonic-gate _nss_files_endent,
3727c478bd9Sstevel@tonic-gate _nss_files_setent,
3737c478bd9Sstevel@tonic-gate _nss_files_getent_netdb,
3747c478bd9Sstevel@tonic-gate getbynam,
3757c478bd9Sstevel@tonic-gate getbyid,
3767c478bd9Sstevel@tonic-gate getbynameid
3777c478bd9Sstevel@tonic-gate };
3787c478bd9Sstevel@tonic-gate
379cb5caa98Sdjl /*ARGSUSED*/
3807c478bd9Sstevel@tonic-gate nss_backend_t *
_nss_files_exec_attr_constr(const char * dummy1,const char * dummy2,const char * dummy3,const char * dummy4,const char * dummy5,const char * dummy6,const char * dummy7)3817c478bd9Sstevel@tonic-gate _nss_files_exec_attr_constr(const char *dummy1,
3827c478bd9Sstevel@tonic-gate const char *dummy2,
3837c478bd9Sstevel@tonic-gate const char *dummy3,
3847c478bd9Sstevel@tonic-gate const char *dummy4,
3857c478bd9Sstevel@tonic-gate const char *dummy5,
3867c478bd9Sstevel@tonic-gate const char *dummy6,
3877c478bd9Sstevel@tonic-gate const char *dummy7)
3887c478bd9Sstevel@tonic-gate {
3897c478bd9Sstevel@tonic-gate return (_nss_files_constr(execattr_ops,
3907c478bd9Sstevel@tonic-gate sizeof (execattr_ops)/sizeof (execattr_ops[0]),
39101ef659dSJoep Vesseur EXECATTR_FILENAME, NSS_LINELEN_EXECATTR, NULL));
3927c478bd9Sstevel@tonic-gate }
393