diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-04-05 01:26:47 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-04-05 01:26:47 +0000 |
commit | 26dee9c49cbbec8826db4c29e99fb50d9392a047 (patch) | |
tree | 98cce94e2e72bcb491b108c3c8f82192070b4b8f /nis/nss_nisplus | |
parent | fe7bdd630fab35270a88b0731cd0fc10de062046 (diff) | |
download | glibc-26dee9c49cbbec8826db4c29e99fb50d9392a047.tar glibc-26dee9c49cbbec8826db4c29e99fb50d9392a047.tar.gz glibc-26dee9c49cbbec8826db4c29e99fb50d9392a047.tar.bz2 glibc-26dee9c49cbbec8826db4c29e99fb50d9392a047.zip |
Update.cvs/libc-ud-970404cvs/libc-970412cvs/libc-970411cvs/libc-970410cvs/libc-970409cvs/libc-970408cvs/libc-970407cvs/libc-970406cvs/libc-970405
1997-04-05 03:11 Ulrich Drepper <drepper@cygnus.com>
* inet/arpa/inet.h: Rewrite. Don't use the ugly BSD way to write
headers but instead add comments and parameter names.
Don't use BSD specific types in prototypes.
* manual/nss.texi: Correct a few typos and errors.
* sysdeps/libm-ieee754/s_cbrt.c: Complete rewrite based on better
algorithm.
* sysdeps/libm-ieee754/s_cbrtf.c: Likewise.
* sysdeps/libm-ieee754/s_cbrtl.c: Likewise.
* sysdeps/libm-i387/s_cbrt.S: New file. Optimized assembler version
with new algorithm.
* sysdeps/libm-i387/s_cbrtf.S: New file.
* sysdeps/libm-i387/s_cbrtl.S: New file.
* sysdeps/libm-i387/s_frexp.S: Optimize even more.
* sysdeps/libm-i387/s_frexpf.S: Likewise.
* sysdeps/libm-i387/s_frexpl.S: Likewise.
1997-04-04 18:55 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/Makefile: Remove CFLAGS-*, add publickey to databases.
* nis/nis_call.c: Add MASTER_ONLY and HARD_LOOKUP flags, compile
DES part only with secure RPC add-on.
* nis/nis_names.c (nis_modify): Fix rpc function number.
* nis/nis_server.c: Fix typos.
* nis/nss_compat/compat-grp.c: Add NIS+ support.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* nis/nss_nis/nis-grp.c: Only a return value > 0 from parse_line
signals success.
* nis/nss_nis/nis-publickey.c: Changes for compiling with/without
secure RPC.
* nis/nss_nisplus/nisplus-publickey.c: Likewise.
* nis/ypclnt.c: Likewise.
* nis/nis_intern.h: Likewise.
* nis/nss_nisplus/nisplus-alias.c: Correct parser return code.
* nis/nss_nisplus/nisplus-ethers.c: Likewise.
* nis/nss_nisplus/nisplus-hosts.c: Likewise.
* nis/nss_nisplus/nisplus-network.c: Likewise.
* nis/nss_nisplus/nisplus-proto.c: Likewise.
* nis/nss_nisplus/nisplus-pwd.c: Likewise.
* nis/nss_nisplus/nisplus-rpc.c: Likewise.
* nis/nss_nisplus/nisplus-service.c: Likewise.
* nis/nss_nisplus/nisplus-spwd.c: Likewise.
* nis/nss_nisplus/nisplus-grp.c: Rewrite parser for fixing errors
and speedup.
* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
1997-04-04 17:03 Ulrich Drepper <drepper@cygnus.com>
* math/libm-test.c (cbrt_test): Add tests for +-inf and NaN
arguments.
1997-04-03 19:24 H.J. Lu <hjl@gnu.ai.mit.edu>
* sysdeps/unix/sysv/linux/sigset.h (__sigisemptyset): Fix a
typo.
1997-04-03 16:10 Andreas Jaeger <aj@arthur.pfalz.de>
* sysdeps/libm-ieee754/s_nanf.c:
* sysdeps/libm-ieee754/s_nan.c:
* sysdeps/libm-ieee754/s_nanl.c: Include <stdio.h> for
declaration of sprintf.
1997-04-03 13:37 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/libm-ieee754/s_cexp.c: Fix type: string_alias ->
strong_alias.
Reported by sun <asun@zoology.washington.edu>.
* rpc/auth.h: Removed.
* rpc/auth_des.h: Removed.
* sunrpc/rpc/auth.h: Moved to ...
* sysdeps/generic/rpc/auth.h: ...here.
* sunrpc/rpc/auth_des.h: Moved to ...
* sysdeps/generic/rpc/auth_des.h: ...here.
1997-04-03 04:28 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/libm-i387/s_frexp.S: New file. ix87 optimized version.
* sysdeps/libm-i387/s_frexpf.S: New file.
* sysdeps/libm-i387/s_frexpl.S: New file.
1997-04-01 10:11 H.J. Lu <hjl@gnu.ai.mit.edu>
* sysdeps/unix/sysv/linux/Makefile [$(subdir)=inet]
(sysdep_headers): Remove netinet/icmp.h.
Describe `inf', `infinity', `nan', `nan(...)' inputs for strtod
* sysdeps/i386/memcmp.S: Likewise.
* time/antarctica: Likewise.
* time/australasia: Likewise.
Diffstat (limited to 'nis/nss_nisplus')
-rw-r--r-- | nis/nss_nisplus/nisplus-alias.c | 6 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-ethers.c | 8 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-grp.c | 107 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-hosts.c | 10 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-netgrp.c | 151 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-network.c | 11 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-proto.c | 10 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-publickey.c | 16 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-pwd.c | 8 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-rpc.c | 10 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-service.c | 12 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-spwd.c | 8 |
12 files changed, 175 insertions, 182 deletions
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c index b0f035178e..b27f1a87ab 100644 --- a/nis/nss_nisplus/nisplus-alias.c +++ b/nis/nss_nisplus/nisplus-alias.c @@ -44,7 +44,7 @@ _nss_nisplus_parse_aliasent (nis_result *result, struct aliasent *alias, char *buffer, size_t buflen) { if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_len != 1 || @@ -52,7 +52,7 @@ _nss_nisplus_parse_aliasent (nis_result *result, struct aliasent *alias, strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "mail_aliases") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 2) - return -1; + return 0; else { char *first_unused = buffer + NISENTRYLEN(0, 1, result) + 1; @@ -67,7 +67,7 @@ _nss_nisplus_parse_aliasent (nis_result *result, struct aliasent *alias, /* The line is too long for our buffer. */ no_more_room: __set_errno (ERANGE); - return -1; + return 0; } else { diff --git a/nis/nss_nisplus/nisplus-ethers.c b/nis/nss_nisplus/nisplus-ethers.c index ac3e06960a..2cdc2dfd7a 100644 --- a/nis/nss_nisplus/nisplus-ethers.c +++ b/nis/nss_nisplus/nisplus-ethers.c @@ -86,7 +86,7 @@ _nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_len != 1 || @@ -94,7 +94,7 @@ _nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether, strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "ethers_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 2) - return -1; + return 0; memset (p, '\0', room_left); @@ -102,7 +102,7 @@ _nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether, if (NISENTRYLEN (0, 0, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); room_left -= (NISENTRYLEN (0, 0, result) +1); @@ -110,7 +110,7 @@ _nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether, if (NISENTRYLEN (0, 1, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 1, result), NISENTRYLEN (0, 1, result)); diff --git a/nis/nss_nisplus/nisplus-grp.c b/nis/nss_nisplus/nisplus-grp.c index 2e56afa6fc..1c73ca555b 100644 --- a/nis/nss_nisplus/nisplus-grp.c +++ b/nis/nss_nisplus/nisplus-grp.c @@ -39,63 +39,34 @@ static nis_name *names = NULL; #define NISENTRYLEN(idx,col,res) \ ((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len) -#define STRUCTURE group -#define ENTNAME grent -struct grent_data {}; - -#define TRAILING_LIST_MEMBER gr_mem -#define TRAILING_LIST_SEPARATOR_P(c) ((c) == ',') -#include "../../nss/nss_files/files-parse.c" -LINE_PARSER -(, - STRING_FIELD (result->gr_name, ISCOLON, 0); - if (line[0] == '\0' - && (result->gr_name[0] == '+' || result->gr_name[0] == '-')) - { - result->gr_passwd = NULL; - result->gr_gid = 0; - } - else - { - STRING_FIELD (result->gr_passwd, ISCOLON, 0); - if (result->gr_name[0] == '+' || result->gr_name[0] == '-') - INT_FIELD_MAYBE_NULL (result->gr_gid, ISCOLON, 0, 10, , 0) - else - INT_FIELD (result->gr_gid, ISCOLON, 0, 10,) - } - ) - -static int +int _nss_nisplus_parse_grent (nis_result * result, struct group *gr, char *buffer, size_t buflen) { -#if 0 - /* XXX here is a bug, sometimes we get some special characters at the - end of a line */ char *first_unused = buffer; size_t room_left = buflen; char *line; int count; - + if (result == NULL) - return -1; - + return 0; + if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_len != 1 || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || - strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, - "group_tbl") != 0 || + strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, + "group_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4) - return -1; + return 0; if (NISENTRYLEN (0, 0, result) >= room_left) { /* The line is too long for our buffer. */ no_more_room: __set_errno (ERANGE); - return -1; + return 0; } - + strncpy (first_unused, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); first_unused[NISENTRYLEN (0, 0, result)] = '\0'; @@ -158,8 +129,11 @@ _nss_nisplus_parse_grent (nis_result * result, struct group *gr, if (line != gr->gr_mem[count]) { - *line = '\0'; - ++line; + if (*line != '\0') + { + *line = '\0'; + ++line; + } ++count; } else @@ -171,59 +145,6 @@ _nss_nisplus_parse_grent (nis_result * result, struct group *gr, gr->gr_mem[count] = NULL; return 1; -#else - char *p = buffer; - size_t room_left = buflen; - struct parser_data *data = (void *) buffer; - - if (result == NULL) - return -1; - - if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || - result->objects.objects_len != 1 || - result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || - strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, - "group_tbl") != 0 || - result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4) - return -1; - - memset (p, '\0', room_left); - - if (NISENTRYLEN (0, 0, result) + 1 > room_left) - { - __set_errno (ERANGE); - return -1; - } - strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); - room_left -= (NISENTRYLEN (0, 0, result) + 1); - strcat (p, ":"); - - if (NISENTRYLEN (0, 1, result) + 1 > room_left) - { - __set_errno (ERANGE); - return -1; - } - strncat (p, NISENTRYVAL (0, 1, result), NISENTRYLEN (0, 1, result)); - room_left -= (NISENTRYLEN (0, 1, result) + 1); - strcat (p, ":"); - if (NISENTRYLEN (0, 2, result) + 1 > room_left) - { - __set_errno (ERANGE); - return -1; - } - strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); - room_left -= (NISENTRYLEN (0, 2, result) + 1); - strcat (p, ":"); - if (NISENTRYLEN (0, 3, result) + 1 > room_left) - { - __set_errno (ERANGE); - return -1; - } - strncat (p, NISENTRYVAL (0, 3, result), NISENTRYLEN (0, 3, result)); - room_left -= (NISENTRYLEN (0, 3, result) + 1); - - return _nss_files_parse_grent (p, gr, data, buflen); -#endif } enum nss_status diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c index 0a486411de..1bcbe40e87 100644 --- a/nis/nss_nisplus/nisplus-hosts.c +++ b/nis/nss_nisplus/nisplus-hosts.c @@ -121,14 +121,14 @@ _nss_nisplus_parse_hostent (nis_result *result, struct hostent *host, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "hosts_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4) - return -1; + return 0; memset (p, '\0', room_left); @@ -136,7 +136,7 @@ _nss_nisplus_parse_hostent (nis_result *result, struct hostent *host, if (NISENTRYLEN (0, 2, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strncpy (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); @@ -145,7 +145,7 @@ _nss_nisplus_parse_hostent (nis_result *result, struct hostent *host, if (NISENTRYLEN (0, 0, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); @@ -157,7 +157,7 @@ _nss_nisplus_parse_hostent (nis_result *result, struct hostent *host, if (NISENTRYLEN (i, 1, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, " "); strcat (p, NISENTRYVAL (i, 1, result)); diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c index 766d2bc773..f2a1b301b9 100644 --- a/nis/nss_nisplus/nisplus-netgrp.c +++ b/nis/nss_nisplus/nisplus-netgrp.c @@ -31,13 +31,9 @@ __libc_lock_define_initialized (static, lock) -static char *data = NULL; -static size_t data_size = 0; -static char *cursor = NULL;; - -extern enum nss_status -_nss_netgroup_parseline (char **cursor, struct __netgrent *result, - char *buffer, size_t buflen); +static nis_result *data = NULL; +static unsigned long data_size = 0; +static unsigned long position = 0; #define NISENTRYVAL(idx,col,res) \ ((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val) @@ -45,15 +41,103 @@ _nss_netgroup_parseline (char **cursor, struct __netgrent *result, #define NISENTRYLEN(idx,col,res) \ ((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len) +static enum nss_status +_nss_nisplus_parse_netgroup (struct __netgrent *result, char *buffer, + size_t buflen) +{ + enum nss_status status; + + /* Some sanity checks. */ + if (data == NULL || data_size == 0) + /* User bug. setnetgrent() wasn't called before. */ + abort (); + + if (position == data_size) + return result->first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN; + + if (NISENTRYLEN (position, 1, data) > 0) + { + /* We have a list of other netgroups. */ + + result->type = group_val; + if (NISENTRYLEN (position, 1, data) >= buflen) + { + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + strncpy (buffer, NISENTRYVAL (position, 1, data), + NISENTRYLEN (position, 1, data)); + buffer[NISENTRYLEN (position, 1, data)] = '\0'; + result->val.group = buffer; + ++position; + result->first = 0; + + return NSS_STATUS_SUCCESS; + } + + /* Before we can copy the entry to the private buffer we have to make + sure it is big enough. */ + if (NISENTRYLEN (position, 2, data) + NISENTRYLEN (position, 3, data) + + NISENTRYLEN (position, 4, data) + 6 > buflen) + { + __set_errno (ERANGE); + status = NSS_STATUS_UNAVAIL; + } + else + { + char *cp = buffer; + + result->type = triple_val; + + if (NISENTRYLEN (position, 2, data) == 0) + result->val.triple.host = NULL; + else + { + result->val.triple.host = cp; + cp = stpncpy (cp, NISENTRYVAL (position, 2, data), + NISENTRYLEN (position, 2, data)); + *cp = '\0'; + ++cp; + } + + if (NISENTRYLEN (position, 3, data) == 0) + result->val.triple.user = NULL; + else + { + result->val.triple.user = cp; + cp = stpncpy (cp, NISENTRYVAL (position, 3, data), + NISENTRYLEN (position, 3, data)); + *cp = '\0'; + ++cp; + } + + if (NISENTRYLEN (position, 4, data) == 0) + result->val.triple.domain = NULL; + else + { + result->val.triple.domain = cp; + cp = stpncpy (cp, NISENTRYVAL (position, 4, data), + NISENTRYLEN (position, 4, data)); + *cp = '\0'; + } + + status = NSS_STATUS_SUCCESS; + + /* Remember where we stopped reading. */ + ++position; + + result->first = 0; + } + + return status; +} + enum nss_status _nss_nisplus_setnetgrent (char *group) { enum nss_status status; - nis_result *result; char buf[strlen (group) + 30]; - int i; - size_t len; if (group == NULL || group[0] == '\0') return NSS_STATUS_UNAVAIL; @@ -64,43 +148,27 @@ _nss_nisplus_setnetgrent (char *group) if (data != NULL) { - free (data); + nis_freeresult (data); data = NULL; data_size = 0; - cursor = NULL; + position = 0; } sprintf(buf, "[name=%s],netgroup.org_dir", group); - result = nis_list(buf, EXPAND_NAME, NULL, NULL); - - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - status = niserr2nss (result->status); - - len = 0; - for (i = 0; i < result->objects.objects_len; i++) - len += 1 + NISENTRYLEN (i, 1, result) + 1 + NISENTRYLEN(i,2,result) - + 1 + NISENTRYLEN(i,3,result) + 1 + NISENTRYLEN(i,4,result) + 2; - - data = malloc (len+1); - memset (data, '\0', len+1); + data = nis_list(buf, EXPAND_NAME, NULL, NULL); - for (i = 0; i < result->objects.objects_len; i++) + if (niserr2nss (data->status) != NSS_STATUS_SUCCESS) { - strncat (data, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); - strcat (data," ("); - strncat (data, NISENTRYVAL(i,2,result), NISENTRYLEN (i, 2, result)); - strcat (data, ","); - strncat (data, NISENTRYVAL(i,3,result), NISENTRYLEN (i, 3, result)); - strcat (data, ","); - strncat (data, NISENTRYVAL(i,4,result), NISENTRYLEN (i, 4, result)); - strcat (data, ") "); + status = niserr2nss (data->status); + nis_freeresult (data); + data = NULL; } - - nis_freeresult (result); - + else + data_size = data->objects.objects_len; + __libc_lock_unlock (lock); - + return status; } @@ -111,10 +179,10 @@ _nss_nisplus_endnetgrent (void) if (data != NULL) { - free (data); + nis_freeresult (data); data = NULL; data_size = 0; - cursor = NULL; + position = 0; } __libc_lock_unlock (lock); @@ -128,12 +196,9 @@ _nss_nisplus_getnetgrent_r (struct __netgrent *result, { enum nss_status status; - if (cursor == NULL) - return NSS_STATUS_NOTFOUND; - __libc_lock_lock (lock); - status = _nss_netgroup_parseline (&cursor, result, buffer, buflen); + status = _nss_nisplus_parse_netgroup (result, buffer, buflen); __libc_lock_unlock (lock); diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c index 28580b6bc9..7e0ccd6411 100644 --- a/nis/nss_nisplus/nisplus-network.c +++ b/nis/nss_nisplus/nisplus-network.c @@ -69,20 +69,20 @@ _nss_nisplus_parse_netent (nis_result *result, struct netent *network, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "networks_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3) - return -1; + return 0; /* Generate the network entry format and use the normal parser */ if (NISENTRYLEN (0, 0, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } memset (p, '\0', room_left); @@ -93,7 +93,7 @@ _nss_nisplus_parse_netent (nis_result *result, struct netent *network, if (NISENTRYLEN (0, 2, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); @@ -101,12 +101,11 @@ _nss_nisplus_parse_netent (nis_result *result, struct netent *network, /* + 1: We overwrite the last \0 */ for (i = 1; i < result->objects.objects_len; i++) - /* XXX should we start with i = 0 or with i = 1 ? */ { if (NISENTRYLEN (i, 1, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, " "); strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c index b26cb8230e..5cb55d367c 100644 --- a/nis/nss_nisplus/nisplus-proto.c +++ b/nis/nss_nisplus/nisplus-proto.c @@ -60,14 +60,14 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "protocols_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3) - return -1; + return 0; memset (p, '\0', room_left); @@ -75,7 +75,7 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto, if (NISENTRYLEN (0, 0, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); room_left -= (NISENTRYLEN (0, 0, result) + 1); @@ -83,7 +83,7 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto, if (NISENTRYLEN (0, 2, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); @@ -95,7 +95,7 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto, if (NISENTRYLEN (i, 1, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, " "); strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c index 7312c91229..91cfba730e 100644 --- a/nis/nss_nisplus/nisplus-publickey.c +++ b/nis/nss_nisplus/nisplus-publickey.c @@ -23,15 +23,17 @@ #include <stdio.h> #include <string.h> #include <syslog.h> -#include <rpc/key_prot.h> +#include <rpc/rpc.h> #include <rpcsvc/nis.h> #include <rpcsvc/nislib.h> +#ifdef HAVE_SECURE_RPC +#include <rpc/key_prot.h> +extern int xdecrypt (char *, char *); +#endif #include <nss-nisplus.h> -extern int xdecrypt (char *, char *); - -/* If we found the entry, we give a SUCCESS and an empty key back. */ +/* If we haven't found the entry, we give a SUCCESS and an empty key back. */ enum nss_status _nss_nisplus_getpublickey (const char *netname, char *pkey) { @@ -70,6 +72,8 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey) { if (retval == NSS_STATUS_TRYAGAIN) __set_errno (EAGAIN); + if (res->status == NIS_NOTFOUND) + retval = NSS_STATUS_SUCCESS; nis_freeresult (res); return retval; } @@ -100,6 +104,7 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey) enum nss_status _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd) { +#ifdef HAVE_SECURE_RPC nis_result *res; enum nss_status retval; char buf[NIS_MAXNAMELEN+2]; @@ -167,6 +172,9 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd) buf[HEXKEYBYTES] = 0; strcpy (skey, buf); +#else + skey[0] = 0; +#endif return NSS_STATUS_SUCCESS; } diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c index 3717d5e98a..b65a9fe395 100644 --- a/nis/nss_nisplus/nisplus-pwd.c +++ b/nis/nss_nisplus/nisplus-pwd.c @@ -38,7 +38,7 @@ static nis_name *names = NULL; #define NISENTRYLEN(idx,col,res) \ ((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len) -static int +int _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, char *buffer, size_t buflen) { @@ -46,7 +46,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, size_t room_left = buflen; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_len != 1 || @@ -54,14 +54,14 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "passwd_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 7) - return -1; + return 0; if (NISENTRYLEN(0, 0, result) >= room_left) { /* The line is too long for our buffer. */ no_more_room: __set_errno (ERANGE); - return -1; + return 0; } strncpy (first_unused, NISENTRYVAL(0, 0, result), diff --git a/nis/nss_nisplus/nisplus-rpc.c b/nis/nss_nisplus/nisplus-rpc.c index 326f262749..9cf9f68b44 100644 --- a/nis/nss_nisplus/nisplus-rpc.c +++ b/nis/nss_nisplus/nisplus-rpc.c @@ -60,14 +60,14 @@ _nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "rpc_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3) - return -1; + return 0; memset (p, '\0', room_left); @@ -75,7 +75,7 @@ _nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc, if (NISENTRYLEN (0, 0, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); room_left -= (NISENTRYLEN (0, 0, result) +1); @@ -83,7 +83,7 @@ _nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc, if (NISENTRYLEN (0, 2, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); @@ -96,7 +96,7 @@ _nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc, if (NISENTRYLEN (i, 1, result) +1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, " "); strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); diff --git a/nis/nss_nisplus/nisplus-service.c b/nis/nss_nisplus/nisplus-service.c index 54f4f876c7..1a8716ab9d 100644 --- a/nis/nss_nisplus/nisplus-service.c +++ b/nis/nss_nisplus/nisplus-service.c @@ -63,14 +63,14 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv, struct parser_data *data = (void *) buffer; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ || strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "services_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4) - return -1; + return 0; memset (p, '\0', room_left); @@ -78,7 +78,7 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv, if (NISENTRYLEN (0, 0, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); room_left -= (NISENTRYLEN (0, 0, result) + 1); @@ -86,7 +86,7 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv, if (NISENTRYLEN (0, 3, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "\t"); strncat (p, NISENTRYVAL (0, 3, result), NISENTRYLEN (0, 3, result)); @@ -94,7 +94,7 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv, if (NISENTRYLEN (0, 2, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, "/"); strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); @@ -105,7 +105,7 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv, if (NISENTRYLEN (i, 1, result) + 1 > room_left) { __set_errno (ERANGE); - return -1; + return 0; } strcat (p, " "); strcat (p, NISENTRYVAL (i, 1, result)); diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c index ec4b5b3340..3400e28da7 100644 --- a/nis/nss_nisplus/nisplus-spwd.c +++ b/nis/nss_nisplus/nisplus-spwd.c @@ -38,7 +38,7 @@ static nis_name *names = NULL; #define NISENTRYLEN(idx,col,res) \ ((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len) -static int +int _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, char *buffer, size_t buflen) { @@ -47,7 +47,7 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, char *line, *cp; if (result == NULL) - return -1; + return 0; if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) || result->objects.objects_len != 1 || @@ -55,14 +55,14 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type, "passwd_tbl") != 0 || result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 8) - return -1; + return 0; if (NISENTRYLEN(0, 0, result) >= room_left) { /* The line is too long for our buffer. */ no_more_room: __set_errno (ERANGE); - return -1; + return 0; } strncpy (first_unused, NISENTRYVAL (0, 0, result), |