11676Sjpk /*
21676Sjpk * CDDL HEADER START
31676Sjpk *
41676Sjpk * The contents of this file are subject to the terms of the
51676Sjpk * Common Development and Distribution License (the "License").
61676Sjpk * You may not use this file except in compliance with the License.
71676Sjpk *
81676Sjpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91676Sjpk * or http://www.opensolaris.org/os/licensing.
101676Sjpk * See the License for the specific language governing permissions
111676Sjpk * and limitations under the License.
121676Sjpk *
131676Sjpk * When distributing Covered Code, include this CDDL HEADER in each
141676Sjpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151676Sjpk * If applicable, add the following below this CDDL HEADER, with the
161676Sjpk * fields enclosed by brackets "[]" replaced with your own identifying
171676Sjpk * information: Portions Copyright [yyyy] [name of copyright owner]
181676Sjpk *
191676Sjpk * CDDL HEADER END
201676Sjpk */
211676Sjpk /*
221676Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
231676Sjpk * Use is subject to license terms.
241676Sjpk */
251676Sjpk
261676Sjpk #pragma ident "%Z%%M% %I% %E% SMI"
271676Sjpk
281676Sjpk #include "files_common.h"
291676Sjpk #include <sys/tsol/tndb.h>
301676Sjpk #include <string.h>
311676Sjpk
321676Sjpk /*
331676Sjpk * files/tsol_gettpent.c --
341676Sjpk * "files" backend for nsswitch "tnrhtp" database
351676Sjpk */
361676Sjpk static int
check_name(nss_XbyY_args_t * args,const char * line,int linelen)37*2830Sdjl check_name(nss_XbyY_args_t *args, const char *line, int linelen)
381676Sjpk {
39*2830Sdjl const char *limit, *linep, *keyp;
40*2830Sdjl
41*2830Sdjl linep = line;
42*2830Sdjl limit = line + linelen;
43*2830Sdjl keyp = args->key.name;
441676Sjpk
45*2830Sdjl /* compare template name, ':' is the seperator */
46*2830Sdjl while (*keyp && linep < limit && *linep != ':' && *keyp == *linep) {
47*2830Sdjl keyp++;
48*2830Sdjl linep++;
49*2830Sdjl }
50*2830Sdjl if (*keyp == '\0' && linep < limit && *linep == ':')
511676Sjpk return (1);
521676Sjpk
531676Sjpk return (0);
541676Sjpk }
551676Sjpk
561676Sjpk static nss_status_t
getbyname(be,a)571676Sjpk getbyname(be, a)
581676Sjpk files_backend_ptr_t be;
591676Sjpk void *a;
601676Sjpk {
611676Sjpk nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
621676Sjpk
63*2830Sdjl if (argp->key.name == NULL)
64*2830Sdjl return (NSS_NOTFOUND);
65*2830Sdjl
661676Sjpk return (_nss_files_XY_all(be, argp, 1, argp->key.name, check_name));
671676Sjpk }
681676Sjpk
691676Sjpk static files_backend_op_t tsol_tp_ops[] = {
701676Sjpk _nss_files_destr,
711676Sjpk _nss_files_endent,
721676Sjpk _nss_files_setent,
731676Sjpk _nss_files_getent_netdb,
741676Sjpk getbyname
751676Sjpk };
761676Sjpk nss_backend_t *
77*2830Sdjl /* LINTED E_FUNC_ARG_UNUSED */
_nss_files_tnrhtp_constr(dummy1,dummy2,dummy3)781676Sjpk _nss_files_tnrhtp_constr(dummy1, dummy2, dummy3)
791676Sjpk const char *dummy1, *dummy2, *dummy3;
801676Sjpk {
811676Sjpk return (_nss_files_constr(tsol_tp_ops,
821676Sjpk sizeof (tsol_tp_ops) / sizeof (tsol_tp_ops[0]),
831676Sjpk "/etc/security/tsol/tnrhtp",
841676Sjpk NSS_LINELEN_TSOL_TP,
851676Sjpk NULL));
861676Sjpk }
87