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 /*
22b86d8771SCasper H.S. Dik * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23*d1e6ffe2SRobert Mustacchi * Copyright (c) 2017, Joyent, Inc.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <stdlib.h>
277c478bd9Sstevel@tonic-gate #include "files_common.h"
287c478bd9Sstevel@tonic-gate #include <time.h>
297c478bd9Sstevel@tonic-gate #include <exec_attr.h>
307c478bd9Sstevel@tonic-gate #include <strings.h>
317c478bd9Sstevel@tonic-gate #include <sys/stat.h>
327c478bd9Sstevel@tonic-gate #include <sys/mman.h>
337c478bd9Sstevel@tonic-gate #include <ctype.h>
347c478bd9Sstevel@tonic-gate #include <synch.h>
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <sys/uio.h>
377c478bd9Sstevel@tonic-gate #include <unistd.h>
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate * files/getexecattr.c -- "files" backend for nsswitch "exec_attr" database
417c478bd9Sstevel@tonic-gate *
427c478bd9Sstevel@tonic-gate * _execattr_files_read_line and _execattr_files_XY_all code based on
437c478bd9Sstevel@tonic-gate * nss_files_read_line and nss_files_XY_all respectively, from files_common.c
447c478bd9Sstevel@tonic-gate */
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate /* externs from libnsl */
487c478bd9Sstevel@tonic-gate extern int _doexeclist(nss_XbyY_args_t *);
497c478bd9Sstevel@tonic-gate extern int _readbufline(char *, int, char *, int, int *);
507c478bd9Sstevel@tonic-gate extern char *_exec_wild_id(char *, const char *);
517c478bd9Sstevel@tonic-gate extern void _exec_cleanup(nss_status_t, nss_XbyY_args_t *);
527c478bd9Sstevel@tonic-gate
53*d1e6ffe2SRobert Mustacchi /*
54*d1e6ffe2SRobert Mustacchi * _exec_files_XY_all wants to cache data from the attribute file.
55*d1e6ffe2SRobert Mustacchi */
56*d1e6ffe2SRobert Mustacchi static char *exec_f_buf;
57*d1e6ffe2SRobert Mustacchi static time_t exec_read_time;
58*d1e6ffe2SRobert Mustacchi
59*d1e6ffe2SRobert Mustacchi void
getexecattr_fini(void)60*d1e6ffe2SRobert Mustacchi getexecattr_fini(void)
61*d1e6ffe2SRobert Mustacchi {
62*d1e6ffe2SRobert Mustacchi free(exec_f_buf);
63*d1e6ffe2SRobert Mustacchi exec_f_buf = NULL;
64*d1e6ffe2SRobert Mustacchi }
65*d1e6ffe2SRobert Mustacchi
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate * check_match: returns 1 if matching entry found, else returns 0.
697c478bd9Sstevel@tonic-gate */
707c478bd9Sstevel@tonic-gate static int
check_match(nss_XbyY_args_t * argp,const char * line,int linelen)71cb5caa98Sdjl check_match(nss_XbyY_args_t *argp, const char *line, int linelen)
727c478bd9Sstevel@tonic-gate {
73cb5caa98Sdjl const char *limit, *linep, *keyp;
747c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
75cb5caa98Sdjl const char *exec_field[6];
76cb5caa98Sdjl int i;
77cb5caa98Sdjl
78cb5caa98Sdjl exec_field[0] = _priv_exec->name; /* name */
79cb5caa98Sdjl exec_field[1] = _priv_exec->policy; /* policy */
80cb5caa98Sdjl exec_field[2] = _priv_exec->type; /* type */
81cb5caa98Sdjl exec_field[3] = NULL; /* res1 */
82cb5caa98Sdjl exec_field[4] = NULL; /* res2 */
83cb5caa98Sdjl exec_field[5] = _priv_exec->id; /* id */
84cb5caa98Sdjl /* No need to check attr field */
85cb5caa98Sdjl
86cb5caa98Sdjl linep = line;
87cb5caa98Sdjl limit = line + linelen;
88cb5caa98Sdjl
89cb5caa98Sdjl for (i = 0; i < 6; i++) {
90cb5caa98Sdjl keyp = exec_field[i];
91cb5caa98Sdjl if (keyp) {
92cb5caa98Sdjl /* compare field */
93cb5caa98Sdjl while (*keyp && linep < limit &&
9401ef659dSJoep Vesseur *linep != ':' && *keyp == *linep) {
95cb5caa98Sdjl keyp++;
96cb5caa98Sdjl linep++;
97cb5caa98Sdjl }
98cb5caa98Sdjl if (*keyp || linep == limit || *linep != ':')
99cb5caa98Sdjl return (0);
100cb5caa98Sdjl } else {
101cb5caa98Sdjl /* skip field */
102cb5caa98Sdjl while (linep < limit && *linep != ':')
103cb5caa98Sdjl linep++;
104cb5caa98Sdjl }
105cb5caa98Sdjl linep++;
1067c478bd9Sstevel@tonic-gate }
1077c478bd9Sstevel@tonic-gate return (1);
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate static nss_status_t
_exec_files_XY_all(files_backend_ptr_t be,nss_XbyY_args_t * argp,int getby_flag)1127c478bd9Sstevel@tonic-gate _exec_files_XY_all(files_backend_ptr_t be,
1137c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp,
1147c478bd9Sstevel@tonic-gate int getby_flag)
1157c478bd9Sstevel@tonic-gate {
1167c478bd9Sstevel@tonic-gate int parse_stat = 0;
1177c478bd9Sstevel@tonic-gate int lastlen = 0;
1187c478bd9Sstevel@tonic-gate int exec_fd = 0;
1197c478bd9Sstevel@tonic-gate int f_size = 0;
1207c478bd9Sstevel@tonic-gate time_t f_time = 0;
1217c478bd9Sstevel@tonic-gate char *first;
1227c478bd9Sstevel@tonic-gate char *last;
1237c478bd9Sstevel@tonic-gate struct stat f_stat;
1247c478bd9Sstevel@tonic-gate nss_status_t res = NSS_NOTFOUND;
1257c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
1267c478bd9Sstevel@tonic-gate static rwlock_t exec_lock;
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate if (((be->buf == NULL) &&
1297c478bd9Sstevel@tonic-gate ((be->buf = (char *)calloc(1, be->minbuf)) == NULL)) ||
1307c478bd9Sstevel@tonic-gate (be->filename == NULL) ||
1317c478bd9Sstevel@tonic-gate (rw_rdlock(&exec_lock) != 0)) {
1327c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate * check the size and the time stamp on the file
1377c478bd9Sstevel@tonic-gate */
1387c478bd9Sstevel@tonic-gate if (stat(be->filename, &f_stat) != 0) {
1397c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1407c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1417c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate
1447c478bd9Sstevel@tonic-gate f_size = f_stat.st_size;
1457c478bd9Sstevel@tonic-gate f_time = f_stat.st_mtime;
1467c478bd9Sstevel@tonic-gate
147*d1e6ffe2SRobert Mustacchi while (f_time > exec_read_time || exec_f_buf == NULL) {
1487c478bd9Sstevel@tonic-gate /*
149b86d8771SCasper H.S. Dik * file has been modified since we last read it
150b86d8771SCasper H.S. Dik * or we never read it or memory allocation
151b86d8771SCasper H.S. Dik * failed before.
1527c478bd9Sstevel@tonic-gate * read it into the buffer with rw lock.
1537c478bd9Sstevel@tonic-gate */
1547c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1557c478bd9Sstevel@tonic-gate if (rw_wrlock(&exec_lock) != 0) {
1567c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1577c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1587c478bd9Sstevel@tonic-gate }
159004388ebScasper if ((be->f = fopen(be->filename, "rF")) == 0) {
1607c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1617c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1627c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1637c478bd9Sstevel@tonic-gate }
164004388ebScasper exec_fd = fileno(be->f);
165*d1e6ffe2SRobert Mustacchi if (exec_f_buf != NULL)
166*d1e6ffe2SRobert Mustacchi free(exec_f_buf);
167*d1e6ffe2SRobert Mustacchi if ((exec_f_buf = malloc(f_size)) == NULL) {
1687c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1697c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1707c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1717c478bd9Sstevel@tonic-gate }
172*d1e6ffe2SRobert Mustacchi if (read(exec_fd, exec_f_buf, f_size) < f_size) {
173*d1e6ffe2SRobert Mustacchi free(exec_f_buf);
174*d1e6ffe2SRobert Mustacchi exec_f_buf = NULL;
1757c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1767c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1777c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1787c478bd9Sstevel@tonic-gate }
179*d1e6ffe2SRobert Mustacchi exec_read_time = f_time;
1807c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1817c478bd9Sstevel@tonic-gate /*
1827c478bd9Sstevel@tonic-gate * verify that the file did not change after
1837c478bd9Sstevel@tonic-gate * we read it.
1847c478bd9Sstevel@tonic-gate */
1857c478bd9Sstevel@tonic-gate if (rw_rdlock(&exec_lock) != 0) {
186*d1e6ffe2SRobert Mustacchi free(exec_f_buf);
187*d1e6ffe2SRobert Mustacchi exec_f_buf = NULL;
1887c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1897c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1907c478bd9Sstevel@tonic-gate }
1917c478bd9Sstevel@tonic-gate if (stat(be->filename, &f_stat) != 0) {
192*d1e6ffe2SRobert Mustacchi free(exec_f_buf);
193*d1e6ffe2SRobert Mustacchi exec_f_buf = NULL;
1947c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
1957c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
1967c478bd9Sstevel@tonic-gate return (NSS_UNAVAIL);
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate f_size = f_stat.st_size;
1997c478bd9Sstevel@tonic-gate f_time = f_stat.st_mtime;
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate res = NSS_NOTFOUND;
203cb5caa98Sdjl /*CONSTCOND*/
2047c478bd9Sstevel@tonic-gate while (1) {
2057c478bd9Sstevel@tonic-gate int linelen = 0;
2067c478bd9Sstevel@tonic-gate char *instr = be->buf;
2077c478bd9Sstevel@tonic-gate
208*d1e6ffe2SRobert Mustacchi linelen = _readbufline(exec_f_buf, f_size, instr, be->minbuf,
2097c478bd9Sstevel@tonic-gate &lastlen);
2107c478bd9Sstevel@tonic-gate if (linelen < 0) {
2117c478bd9Sstevel@tonic-gate /* End of file */
2127c478bd9Sstevel@tonic-gate break;
2137c478bd9Sstevel@tonic-gate }
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate * If the entry doesn't contain the filter string then
2177c478bd9Sstevel@tonic-gate * it can't be the entry we want, so don't bother looking
2187c478bd9Sstevel@tonic-gate * more closely at it.
2197c478bd9Sstevel@tonic-gate */
2207c478bd9Sstevel@tonic-gate switch (getby_flag) {
2217c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYNAME:
2227c478bd9Sstevel@tonic-gate if (strstr(instr, _priv_exec->name) == NULL)
2237c478bd9Sstevel@tonic-gate continue;
2247c478bd9Sstevel@tonic-gate break;
2257c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYID:
2267c478bd9Sstevel@tonic-gate if (strstr(instr, _priv_exec->id) == NULL)
2277c478bd9Sstevel@tonic-gate continue;
2287c478bd9Sstevel@tonic-gate break;
2297c478bd9Sstevel@tonic-gate case NSS_DBOP_EXECATTR_BYNAMEID:
2307c478bd9Sstevel@tonic-gate if ((strstr(instr, _priv_exec->name) == NULL) ||
2317c478bd9Sstevel@tonic-gate (strstr(instr, _priv_exec->id) == NULL))
2327c478bd9Sstevel@tonic-gate continue;
2337c478bd9Sstevel@tonic-gate break;
2347c478bd9Sstevel@tonic-gate default:
2357c478bd9Sstevel@tonic-gate break;
2367c478bd9Sstevel@tonic-gate }
23701ef659dSJoep Vesseur if (((_priv_exec->policy != NULL) &&
23801ef659dSJoep Vesseur (strstr(instr, _priv_exec->policy) == NULL)) ||
2397c478bd9Sstevel@tonic-gate ((_priv_exec->type != NULL) &&
2407c478bd9Sstevel@tonic-gate (strstr(instr, _priv_exec->type) == NULL)))
2417c478bd9Sstevel@tonic-gate continue;
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate /*
2447c478bd9Sstevel@tonic-gate * Get rid of white spaces, comments etc.
2457c478bd9Sstevel@tonic-gate */
2467c478bd9Sstevel@tonic-gate if ((last = strchr(instr, '#')) == NULL)
2477c478bd9Sstevel@tonic-gate last = instr + linelen;
2487c478bd9Sstevel@tonic-gate *last-- = '\0'; /* Nuke '\n' or #comment */
2497c478bd9Sstevel@tonic-gate /*
2507c478bd9Sstevel@tonic-gate * Skip leading whitespace. Normally there isn't any,
2517c478bd9Sstevel@tonic-gate * so it's not worth calling strspn().
2527c478bd9Sstevel@tonic-gate */
2537c478bd9Sstevel@tonic-gate for (first = instr; isspace(*first); first++)
2547c478bd9Sstevel@tonic-gate ;
2557c478bd9Sstevel@tonic-gate if (*first == '\0')
2567c478bd9Sstevel@tonic-gate continue;
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate * Found something non-blank on the line. Skip back
2597c478bd9Sstevel@tonic-gate * over any trailing whitespace; since we know there's
2607c478bd9Sstevel@tonic-gate * non-whitespace earlier in the line, checking for
2617c478bd9Sstevel@tonic-gate * termination is easy.
2627c478bd9Sstevel@tonic-gate */
2637c478bd9Sstevel@tonic-gate while (isspace(*last))
2647c478bd9Sstevel@tonic-gate --last;
2657c478bd9Sstevel@tonic-gate linelen = last - first + 1;
2667c478bd9Sstevel@tonic-gate if (first != instr)
2677c478bd9Sstevel@tonic-gate instr = first;
2687c478bd9Sstevel@tonic-gate
269cb5caa98Sdjl /* Check the entry */
2707c478bd9Sstevel@tonic-gate argp->returnval = NULL;
271cb5caa98Sdjl argp->returnlen = 0;
272cb5caa98Sdjl if (check_match(argp, instr, linelen) == 0)
273cb5caa98Sdjl continue;
274cb5caa98Sdjl
275cb5caa98Sdjl /* Marshall the data */
2767c478bd9Sstevel@tonic-gate parse_stat = (*argp->str2ent)(instr, linelen, argp->buf.result,
2777c478bd9Sstevel@tonic-gate argp->buf.buffer, argp->buf.buflen);
2787c478bd9Sstevel@tonic-gate if (parse_stat == NSS_STR_PARSE_SUCCESS) {
279cb5caa98Sdjl argp->returnval = (argp->buf.result != NULL)?
28001ef659dSJoep Vesseur argp->buf.result : argp->buf.buffer;
281cb5caa98Sdjl argp->returnlen = linelen;
282cb5caa98Sdjl res = NSS_SUCCESS;
28301ef659dSJoep Vesseur if (IS_GET_ONE(_priv_exec->search_flag)) {
284cb5caa98Sdjl break;
285cb5caa98Sdjl } else if (_doexeclist(argp) == 0) {
286cb5caa98Sdjl res = NSS_UNAVAIL;
287cb5caa98Sdjl break;
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate } else if (parse_stat == NSS_STR_PARSE_ERANGE) {
2907c478bd9Sstevel@tonic-gate argp->erange = 1;
2917c478bd9Sstevel@tonic-gate break;
2927c478bd9Sstevel@tonic-gate } /* else if (parse_stat == NSS_STR_PARSE_PARSE) don't care ! */
2937c478bd9Sstevel@tonic-gate }
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate (void) _nss_files_endent(be, 0);
2967c478bd9Sstevel@tonic-gate (void) rw_unlock(&exec_lock);
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate return (res);
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate
3027c478bd9Sstevel@tonic-gate /*
3037c478bd9Sstevel@tonic-gate * If search for exact match for id failed, get_wild checks if we have
3047c478bd9Sstevel@tonic-gate * a wild-card entry for that id.
3057c478bd9Sstevel@tonic-gate */
3067c478bd9Sstevel@tonic-gate static nss_status_t
get_wild(files_backend_ptr_t be,nss_XbyY_args_t * argp,int getby_flag)3077c478bd9Sstevel@tonic-gate get_wild(files_backend_ptr_t be, nss_XbyY_args_t *argp, int getby_flag)
3087c478bd9Sstevel@tonic-gate {
309cb5caa98Sdjl const char *orig_id = NULL;
3107c478bd9Sstevel@tonic-gate char *old_id = NULL;
3117c478bd9Sstevel@tonic-gate char *wild_id = NULL;
3127c478bd9Sstevel@tonic-gate nss_status_t res = NSS_NOTFOUND;
3137c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
3147c478bd9Sstevel@tonic-gate
315cb5caa98Sdjl orig_id = _priv_exec->id;
3167c478bd9Sstevel@tonic-gate old_id = strdup(_priv_exec->id);
3177c478bd9Sstevel@tonic-gate wild_id = old_id;
3187c478bd9Sstevel@tonic-gate while ((wild_id = _exec_wild_id(wild_id, _priv_exec->type)) != NULL) {
3197c478bd9Sstevel@tonic-gate _priv_exec->id = wild_id;
3207c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, getby_flag);
3217c478bd9Sstevel@tonic-gate if (res == NSS_SUCCESS)
3227c478bd9Sstevel@tonic-gate break;
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate _priv_exec->id = orig_id;
3257c478bd9Sstevel@tonic-gate if (old_id)
3267c478bd9Sstevel@tonic-gate free(old_id);
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate return (res);
3297c478bd9Sstevel@tonic-gate }
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate static nss_status_t
getbynam(files_backend_ptr_t be,void * a)3337c478bd9Sstevel@tonic-gate getbynam(files_backend_ptr_t be, void *a)
3347c478bd9Sstevel@tonic-gate {
3357c478bd9Sstevel@tonic-gate nss_status_t res;
3367c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
3377c478bd9Sstevel@tonic-gate
3387c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYNAME);
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gate return (res);
3437c478bd9Sstevel@tonic-gate }
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gate static nss_status_t
getbyid(files_backend_ptr_t be,void * a)3477c478bd9Sstevel@tonic-gate getbyid(files_backend_ptr_t be, void *a)
3487c478bd9Sstevel@tonic-gate {
3497c478bd9Sstevel@tonic-gate nss_status_t res;
3507c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
351cb5caa98Sdjl /*LINTED*/
3527c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
3537c478bd9Sstevel@tonic-gate
3547c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYID);
3557c478bd9Sstevel@tonic-gate
3567c478bd9Sstevel@tonic-gate if (res != NSS_SUCCESS)
3577c478bd9Sstevel@tonic-gate res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYID);
3587c478bd9Sstevel@tonic-gate
3597c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3607c478bd9Sstevel@tonic-gate
3617c478bd9Sstevel@tonic-gate return (res);
3627c478bd9Sstevel@tonic-gate }
3637c478bd9Sstevel@tonic-gate
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate static nss_status_t
getbynameid(files_backend_ptr_t be,void * a)3667c478bd9Sstevel@tonic-gate getbynameid(files_backend_ptr_t be, void *a)
3677c478bd9Sstevel@tonic-gate {
3687c478bd9Sstevel@tonic-gate nss_status_t res;
3697c478bd9Sstevel@tonic-gate nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
370cb5caa98Sdjl /*LINTED*/
3717c478bd9Sstevel@tonic-gate _priv_execattr *_priv_exec = (_priv_execattr *)(argp->key.attrp);
3727c478bd9Sstevel@tonic-gate
3737c478bd9Sstevel@tonic-gate res = _exec_files_XY_all(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate if (res != NSS_SUCCESS)
3767c478bd9Sstevel@tonic-gate res = get_wild(be, argp, NSS_DBOP_EXECATTR_BYNAMEID);
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate _exec_cleanup(res, argp);
3797c478bd9Sstevel@tonic-gate
3807c478bd9Sstevel@tonic-gate return (res);
3817c478bd9Sstevel@tonic-gate }
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate
3847c478bd9Sstevel@tonic-gate static files_backend_op_t execattr_ops[] = {
3857c478bd9Sstevel@tonic-gate _nss_files_destr,
3867c478bd9Sstevel@tonic-gate _nss_files_endent,
3877c478bd9Sstevel@tonic-gate _nss_files_setent,
3887c478bd9Sstevel@tonic-gate _nss_files_getent_netdb,
3897c478bd9Sstevel@tonic-gate getbynam,
3907c478bd9Sstevel@tonic-gate getbyid,
3917c478bd9Sstevel@tonic-gate getbynameid
3927c478bd9Sstevel@tonic-gate };
3937c478bd9Sstevel@tonic-gate
394cb5caa98Sdjl /*ARGSUSED*/
3957c478bd9Sstevel@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)3967c478bd9Sstevel@tonic-gate _nss_files_exec_attr_constr(const char *dummy1,
3977c478bd9Sstevel@tonic-gate const char *dummy2,
3987c478bd9Sstevel@tonic-gate const char *dummy3,
3997c478bd9Sstevel@tonic-gate const char *dummy4,
4007c478bd9Sstevel@tonic-gate const char *dummy5,
4017c478bd9Sstevel@tonic-gate const char *dummy6,
4027c478bd9Sstevel@tonic-gate const char *dummy7)
4037c478bd9Sstevel@tonic-gate {
4047c478bd9Sstevel@tonic-gate return (_nss_files_constr(execattr_ops,
40501ef659dSJoep Vesseur sizeof (execattr_ops)/sizeof (execattr_ops[0]),
40601ef659dSJoep Vesseur EXECATTR_FILENAME, NSS_LINELEN_EXECATTR, NULL));
4077c478bd9Sstevel@tonic-gate }
408