cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The contents of this file are subject to the terms of the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Common Development and Distribution License (the "License").
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You may not use this file except in compliance with the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * See the License for the specific language governing permissions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and limitations under the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When distributing Covered Code, include this CDDL HEADER in each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * If applicable, add the following below this CDDL HEADER, with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * fields enclosed by brackets "[]" replaced with your own identifying
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * information: Portions Copyright [yyyy] [name of copyright owner]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER END
36e852a172cba914383d7341c988128b2c667fbdRaja Andra * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The _nsw_getoneconfig_v1() in this file parses the switch policy
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * configuration for a switch database, e.g.,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * hosts: nis [NOTFOUND=return] files
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * printers: user files nis
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Local routines
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *skip(char **, char);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *labelskip(char *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *spaceskip(char *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic int alldigits(char *);
36e852a172cba914383d7341c988128b2c667fbdRaja Andra * With the "lookup control" feature, the default criteria for NIS
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and any new services (e.g. ldap) will be:
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * [SUCCESS=return NOTFOUND=continue UNAVAIL=continue TRYAGAIN=forever]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * For backward compat, NIS via NIS server in DNS forwarding mode will be:
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * [SUCCESS=return NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * And also for backward compat, the default criteria for DNS will be:
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * [SUCCESS=return NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The BIND resolver normally will retry several times on server non-response.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * But now with the "lookup control" feature, we don't want the resolver doing
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * many retries, rather we want it to return control (reasonably) quickly back
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * to the switch engine. However, when TRYAGAIN=N or TRYAGAIN=forever is
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * not explicitly set by the admin in the conf file, we want the old "resolver
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * retry a few times" rather than no retries at all.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * For backward compat (pre "lookup control"), the dns default behavior is
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * soft lookup.
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic void
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic void
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* give the next non-alpha character */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *p = cur;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl while (islabel(*p))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (p);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* give the next non-space character */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *p = cur;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (p);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * terminate the *cur pointed string by null only if it is
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * followed by "key" surrounded by zero or more spaces and
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * return value is the same as the original *cur pointer and
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * *cur pointer is advanced to the first non {space, key} char
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * followed by the key. Otherwise, return NULL and keep
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * *cur unchanged.
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstatic char *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *q = *cur;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* null terminate the return token */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl p++; /* skip the key */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (q);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* Return 1 if the string contains all digits, else return 0. */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl for (; *s; s++)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (0);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (1);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl_nsw_getoneconfig_v1(const char *name, char *linep, enum __nsw_parse_err *errp)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* linep Nota Bene: not const char * */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* errp Meanings are abused a bit */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if ((cfp = calloc(1, sizeof (struct __nsw_switchconfig_v1)))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* linep points to a naming service name */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl for (;;) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* white space following the last service */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl for (i = 0; i < __NSW_STD_ERRS_V1; i++)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl else if (i == __NSW_TRYAGAIN)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* get criteria for the naming service */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* premature end, illegal char following [ */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* linep points to a switch_err */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl for (;;) {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* premature end, ill char following = */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* linep points to the string following '=' */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (*p == ']')
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (*p == ']') {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *p++ = '\0';
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else if (!islabel(*p))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* p better be the next switch_err */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl "dns") == 0 &&
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Add one more condition
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * so it retries only if it's
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * "dns [TRYAGAIN=continue]"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl "nis") == 0)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * convert string tokenp to integer
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and put in long_errs
cb5caa98562cf06753163f558cbcfe30b8f4673adjl break; /* process next naming service */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } /* end of while loop for a name service's criteria */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * no criteria for this naming service.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * linep points to name service, but not null
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * terminated.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *p = '\0';
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *p++ = '\0';
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } /* end of while(1) loop for a name service */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return (0);