summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chang <Benjamin.Chang@Oracle.COM>2010-08-18 10:13:15 -0700
committerBen Chang <Benjamin.Chang@Oracle.COM>2010-08-18 10:13:15 -0700
commitea10ff14a02f7788b8ec27b4b21b925542a8cca6 (patch)
tree1c08559dd4b2c70dbe63547aa30e588a426bd7b8
parent2b5d0e779e492fcdbfc163a5553804f3ca09354b (diff)
downloadillumos-joyent-ea10ff14a02f7788b8ec27b4b21b925542a8cca6.tar.gz
6861238 N2L: ypserv doesn't store hostnames in lowercase in the key-column in hosts.byname
-rw-r--r--usr/src/lib/libnisdb/yptol/dit_access.c31
-rw-r--r--usr/src/lib/libnisdb/yptol/dit_access_utils.c54
-rw-r--r--usr/src/lib/libnisdb/yptol/dit_access_utils.h13
3 files changed, 71 insertions, 27 deletions
diff --git a/usr/src/lib/libnisdb/yptol/dit_access.c b/usr/src/lib/libnisdb/yptol/dit_access.c
index cfbaba4651..0dbcb27174 100644
--- a/usr/src/lib/libnisdb/yptol/dit_access.c
+++ b/usr/src/lib/libnisdb/yptol/dit_access.c
@@ -19,12 +19,9 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* DESCRIPTION: Contains top level functions to read/write to the DIT. These
* are the API between the shim and the mapping system.
@@ -615,6 +612,16 @@ update_map_from_dit(map_ctrl *map, bool_t log_flag) {
int next_print = PRINT_FREQ;
int search_flag = SUCCESS;
+ int m;
+
+ /* list of maps whose keys will be transliterated to lowercase */
+ char *xlate_to_lcase_maps[] = {
+ "hosts.byname",
+ "ipnodes.byname",
+ NULL
+ };
+ bool_t xlate_to_lcase = FALSE;
+
if (!map || !map->map_name || !map->domain) {
return (FAILURE);
}
@@ -692,6 +699,20 @@ update_map_from_dit(map_ctrl *map, bool_t log_flag) {
return (FAILURE);
}
+ /*
+ * set xlate_to_lcase to TRUE if map_name is found in
+ * xlate_to_lcase_maps[]
+ */
+ m = 0;
+ while (xlate_to_lcase_maps[m] != NULL) {
+ if (strncmp(map->map_name, xlate_to_lcase_maps[m],
+ strlen(xlate_to_lcase_maps[m])) == 0) {
+ xlate_to_lcase = TRUE;
+ break;
+ }
+ ++m;
+ }
+
/* Try each mapping for the map */
for (flag = 0; t != 0 && search_flag != FAILURE; t = t->next) {
@@ -802,7 +823,7 @@ update_map_from_dit(map_ctrl *map, bool_t log_flag) {
/* Obtain the datum for key */
datkey = getKeyFromRuleValue(t, &rv[i],
- &nv, &statP);
+ &nv, &statP, xlate_to_lcase);
if (datkey == 0) {
logmsg(MSG_NOTIMECHECK, LOG_WARNING,
"%s: Unable to obtain NIS "
diff --git a/usr/src/lib/libnisdb/yptol/dit_access_utils.c b/usr/src/lib/libnisdb/yptol/dit_access_utils.c
index 5f63001f35..80d6d1744c 100644
--- a/usr/src/lib/libnisdb/yptol/dit_access_utils.c
+++ b/usr/src/lib/libnisdb/yptol/dit_access_utils.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,9 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* DESCRIPTION: Contains dit_access interface support functions.
*/
@@ -55,6 +51,9 @@
#include "yptol.h"
#include "dit_access_utils.h"
+#define YPMULTI "YP_MULTI_"
+#define YPMULTISZ 9 /* == strlen(YPMULTI) */
+
/*
* Returns 'map,domain.'
*/
@@ -852,8 +851,9 @@ ruleValueToDatum(__nis_table_mapping_t *t, __nis_rule_value_t *rv, int *statP) {
datum *
getKeyFromRuleValue(__nis_table_mapping_t *t, __nis_rule_value_t *rv, int *nv,
- int *statP) {
- int i, j;
+ int *statP, bool_t xlate_to_lcase)
+{
+ int i, j, k;
datum *key = 0;
char *str;
char *myself = "getKeyFromRuleValue";
@@ -868,7 +868,7 @@ getKeyFromRuleValue(__nis_table_mapping_t *t, __nis_rule_value_t *rv, int *nv,
if (rv->colName[i] == 0)
continue;
if (strcasecmp(N2LKEY, rv->colName[i]) == 0 ||
- strcasecmp(N2LIPKEY, rv->colName[i]) == 0) {
+ strcasecmp(N2LIPKEY, rv->colName[i]) == 0) {
if ((*nv = rv->colVal[i].numVals) == 0)
return (0);
if ((key = am(myself, sizeof (key[0]) * *nv)) == 0) {
@@ -881,15 +881,15 @@ getKeyFromRuleValue(__nis_table_mapping_t *t, __nis_rule_value_t *rv, int *nv,
key[j].dptr = 0;
} else {
if (verifyIndexMatch(t, 0, 0,
- rv->colName[i],
- str) == 0) {
+ rv->colName[i], str) == 0) {
key[j].dsize = 0;
key[j].dptr = 0;
continue;
}
+
key[j].dsize = strlen(str);
key[j].dptr = am(myself,
- key[j].dsize + 1);
+ key[j].dsize + 1);
if (key[j].dptr == 0) {
*statP = MAP_NO_MEMORY;
for (--j; j >= 0; j--)
@@ -897,7 +897,33 @@ getKeyFromRuleValue(__nis_table_mapping_t *t, __nis_rule_value_t *rv, int *nv,
sfree(key);
return (0);
}
- bcopy(str, key[j].dptr, key[j].dsize);
+
+ /* transliterate key to lowercase */
+ if (xlate_to_lcase == TRUE) {
+
+ /*
+ * For multi-homed
+ * entries, skip over
+ * "YP_MULTI_" prefix.
+ */
+ k = 0;
+ if (strncmp(YPMULTI, str,
+ YPMULTISZ) == 0) {
+ k = YPMULTISZ;
+ bcopy(str, key[j].dptr,
+ YPMULTISZ);
+ }
+ while (k < key[j].dsize) {
+ key[j].dptr[k] =
+ (char)tolower(
+ (int)(uchar_t)
+ str[k]);
+ k++;
+ }
+ } else {
+ bcopy(str, key[j].dptr,
+ key[j].dsize);
+ }
}
}
return (key);
diff --git a/usr/src/lib/libnisdb/yptol/dit_access_utils.h b/usr/src/lib/libnisdb/yptol/dit_access_utils.h
index 60752a8605..a0364c7cd6 100644
--- a/usr/src/lib/libnisdb/yptol/dit_access_utils.h
+++ b/usr/src/lib/libnisdb/yptol/dit_access_utils.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,12 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _DIT_ACCESS_UTILS_H
#define _DIT_ACCESS_UTILS_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -73,7 +69,8 @@ extern suc_code addSplitFieldValues(__nis_table_mapping_t *t,
extern datum *ruleValueToDatum(__nis_table_mapping_t *t,
__nis_rule_value_t *rv, int *statP);
extern datum *getKeyFromRuleValue(__nis_table_mapping_t *t,
- __nis_rule_value_t *rv, int *nv, int *statP);
+ __nis_rule_value_t *rv, int *nv, int *statP,
+ bool_t xlate_to_lcase);
extern const char *getObjectClass(char *rdn);
extern suc_code makeNISObject(char *domain, char *dn);
extern suc_code addNISObject(char *domain, char *dn,