about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/db-Makefile28
-rw-r--r--nss/getXXbyYY_r.c3
-rw-r--r--nss/getXXent_r.c7
-rw-r--r--nss/nss_files/files-alias.c27
4 files changed, 39 insertions, 26 deletions
diff --git a/nss/db-Makefile b/nss/db-Makefile
index 756f4c6ce6..983a36fb59 100644
--- a/nss/db-Makefile
+++ b/nss/db-Makefile
@@ -11,7 +11,8 @@ all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
 
 $(VAR_DB)/passwd.db: /etc/passwd
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
 		 /^[^#]/ { printf ".%s ", $$1; print; \
 			   if (!uids[$$3]++) \
 			     { printf "=%s ", $$3; print } }' $^ | \
@@ -20,7 +21,8 @@ $(VAR_DB)/passwd.db: /etc/passwd
 
 $(VAR_DB)/group.db: /etc/group
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
 		 /^[^#]/ { printf ".%s ", $$1; print; \
 			   printf "=%s ", $$3; print }' $^ | \
 	$(MAKEDB) -o $@ -
@@ -28,14 +30,18 @@ $(VAR_DB)/group.db: /etc/group
 
 $(VAR_DB)/ethers.db: /etc/ethers
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+	@$(AWK) 'BEGIN { cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
+		 /^[^#]/ { printf ".%s ", $$1; print; \
 			   printf "=%s ", $$2; print }' $^ | \
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
 $(VAR_DB)/protocols.db: /etc/protocols
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+	@$(AWK) 'BEGIN { cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
+		 /^[^#]/ { printf ".%s ", $$1; print; \
 			   printf "=%s ", $$2; print; \
 			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
 			     { printf ".%s ", $$i; print } }' $^ | \
@@ -44,7 +50,9 @@ $(VAR_DB)/protocols.db: /etc/protocols
 
 $(VAR_DB)/rpc.db: /etc/rpc
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+	@$(AWK) 'BEGIN { cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
+		 /^[^#]/ { printf ".%s ", $$1; print; \
 			   printf "=%s ", $$2; print; \
 			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
 			     { printf ".%s ", $$i; print } }' $^ | \
@@ -53,7 +61,8 @@ $(VAR_DB)/rpc.db: /etc/rpc
 
 $(VAR_DB)/services.db: /etc/services
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) 'BEGIN { FS="[ \t/]+" } \
+	@$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
 		 /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
 			   printf "=%s/%s ", $$2, $$3; print; \
 			   for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
@@ -63,14 +72,17 @@ $(VAR_DB)/services.db: /etc/services
 
 $(VAR_DB)/shadow.db: /etc/shadow
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
 		 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
 $(VAR_DB)/netgroup.db: /etc/netgroup
 	@echo -n "$(patsubst %.db,%,$(@F))... "
-	@$(AWK) '/^[^#]/ { end=sub(/\\/, " "); \
+	@$(AWK) 'BEGIN { cnt=0 } \
+		 { printf "0%u ", cnt++; print } \
+		 /^[^#]/ { end=sub(/\\/, " "); \
 			   gsub(/[ \t]+/, " "); \
 			   if(end == 1) printf "%s", $$0; else print }' $^ | \
 	$(MAKEDB) -o $@ -
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index f12907c244..6ddfd61d8d 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -109,7 +109,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 	  if ((_res.options & RES_INIT) == 0 && res_init () == -1)
 	    {
 	      *h_errnop = NETDB_INTERNAL;
-	      return NULL;
+	      *result = NULL;
+	      return -1;
 	    }
 #endif /* need _res */
 	}
diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c
index 876ad10963..6c8105c03f 100644
--- a/nss/getXXent_r.c
+++ b/nss/getXXent_r.c
@@ -150,7 +150,7 @@ SETFUNC_NAME (STAYOPEN)
   if ((_res.options & RES_INIT) == 0 && res_init () == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
-      return NULL;
+      return;
     }
 #endif /* need _res */
 
@@ -188,7 +188,7 @@ ENDFUNC_NAME (void)
   if ((_res.options & RES_INIT) == 0 && res_init () == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
-      return NULL;
+      return;
     }
 #endif /* need _res */
 
@@ -225,7 +225,8 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer, size_t buflen,
   if ((_res.options & RES_INIT) == 0 && res_init () == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
-      return NULL;
+      *result = NULL;
+      return -1;
     }
 #endif /* need _res */
 
diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c
index 2b0f292d66..341e9d4d68 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -149,7 +149,7 @@ get_next_alias (const char *match, struct aliasent *result,
 	  /* If we are in IGNORE mode and the first character in the
 	     line is a white space we ignore the line and start
 	     reading the next.  */
-	  if (ignore && isspace (first_unused))
+	  if (ignore && isspace (*first_unused))
 	    continue;
 
 	  /* Terminate the line for any case.  */
@@ -179,7 +179,7 @@ get_next_alias (const char *match, struct aliasent *result,
 	     looking for.  If it does not match we simply ignore all
 	     lines until the next line containing the start of a new
 	     alias is found.  */
-	  ignore = match != NULL && strcmp (result->alias_name, match) == 0;
+	  ignore = match != NULL && strcmp (result->alias_name, match) != 0;
 
 	  while (! ignore)
 	    {
@@ -192,16 +192,11 @@ get_next_alias (const char *match, struct aliasent *result,
 
 	      if (first_unused != cp)
 		{
+		  /* OK, we can have a regular entry or an include
+		     request.  */
 		  if (*line != '\0')
-		    {
-		      /* OK, we can have a regular entry or an include
-			 request.  */
-		      *first_unused++ = '\0';
-		      ++line;
-		    }
-		  else
-		    ++first_unused;
-
+		    ++line;
+		  *first_unused++ = '\0';
 
 		  if (strncmp (cp, ":include:", 9) != 0)
 		    {
@@ -295,10 +290,8 @@ get_next_alias (const char *match, struct aliasent *result,
 		     just read character.  */
 		  int ch;
 
-		  first_unused[room_left - 1] = '\0';
-		  line = first_unused;
 		  ch = fgetc (stream);
-		  if (ch == EOF || !isspace (ch))
+		  if (ch == EOF || ch == '\n' || !isspace (ch))
 		    {
 		      size_t cnt;
 
@@ -329,6 +322,10 @@ get_next_alias (const char *match, struct aliasent *result,
 
 		  /* The just read character is a white space and so
 		     can be ignored.  */
+		  first_unused[room_left - 1] = '\0';
+		  line = fgets (first_unused, room_left, stream);
+		  if (first_unused[room_left - 1] != '\0')
+		    goto no_more_room;
 		  cp = strpbrk (line, "#\n");
 		  if (cp != NULL)
 		    *cp = '\0';
@@ -419,6 +416,8 @@ _nss_files_getaliasbyname_r (const char *name, struct aliasent *result,
       while (status == NSS_STATUS_RETURN);
     }
 
+  internal_endent ();
+
   __libc_lock_unlock (lock);
 
   return status;