This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
This report was very unclear. I asked for clarification, and got back some more junk, but got enough information out of it to find out what the problem is. Our netgroup parser doesn't strip off any whitespace from the netgroup parts, and therefore matching done against them might fail. Thus right now the netgroup ( foo , bar,foobar.net ) gives host = " foo ", user = "bar " and domain = "foobar.net ". Attached is an *untested* patch to correct this. It would be great if anyone actually using netgroups could test this patch 2000-07-25 Mark Kettenis <kettenis@gnu.org> * nss/nss_files/files-netgrp.c (strip_whitespace): New function. (_nss_netgroup_parseline): Use strip_whitespace to strip off any leading and trailing spaces from host, user and domain name. Index: nss/nss_files/files-netgrp.c =================================================================== RCS file: /cvs/glibc/libc/nss/nss_files/files-netgrp.c,v retrieving revision 1.9 diff -u -p -r1.9 files-netgrp.c --- nss/nss_files/files-netgrp.c 1997/12/08 02:42:38 1.9 +++ nss/nss_files/files-netgrp.c 2000/07/25 21:22:21 @@ -1,5 +1,5 @@ /* Netgroup file parser in nss_files modules. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -159,6 +159,24 @@ _nss_files_endnetgrent (struct __netgren return NSS_STATUS_SUCCESS; } +static char * +strip_whitespace (char *str) +{ + char *cp = str; + + /* Skip leading spaces. */ + while (isspace (*cp)) + cp++; + + str = cp; + while (*cp != '\0' && ! isspace(*cp)) + cp++; + + /* Null-terminate, stripping off any trailing spaces. */ + *cp = '\0'; + + return *str == '\0' ? NULL : str; +} enum nss_status _nss_netgroup_parseline (char **cursor, struct __netgrent *result, @@ -235,15 +253,14 @@ _nss_netgroup_parseline (char **cursor, memcpy (buffer, host, cp - host); result->type = triple_val; - buffer[(user - host) - 1] = '\0'; - result->val.triple.host = *host == ',' ? NULL : buffer; + buffer[(user - host) - 1] = '\0'; /* Replace ',' with '\0'. */ + result->val.triple.host = strip_whitespace (buffer); - buffer[(domain - host) - 1] = '\0'; - result->val.triple.user = *user == ',' ? NULL : buffer + (user - host); + buffer[(domain - host) - 1] = '\0'; /* Replace ',' with '\0'. */ + result->val.triple.user = strip_whitespace (buffer + (user - host)); - buffer[(cp - host) - 1] = '\0'; - result->val.triple.domain = - *domain == ')' ? NULL : buffer + (domain - host); + buffer[(cp - host) - 1] = '\0'; /* Replace ')' with '\0'. */ + result->val.triple.domain = strip_whitespace (buffer + (domain - host)); status = NSS_STATUS_SUCCESS;
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |