]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_table.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / nis / nis_table.c
index cb25be61e2443cacc04b7342cd3f99a5480b6312..9344a1f7b3b5205a8f32f61e34928adac11e1478 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997-1999,2003,2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (c) 1997-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
 #include <string.h>
@@ -100,8 +99,8 @@ __create_ib_request (const_nis_name name, unsigned int flags)
        }
       *val++ = '\0';
       if (search_len + 1 >= size)
-        {
-          size += 1;
+       {
+         size += 1;
          nis_attr *newp = realloc (search_val, size * sizeof (nis_attr));
          if (newp == NULL)
            goto free_null;
@@ -274,21 +273,14 @@ nis_list (const_nis_name name, unsigned int flags,
       memset (res, '\0', sizeof (nis_result));
 
       status = __nisfind_server (ibreq->ibr_name,
-                                ibreq->ibr_srch.ibr_srch_val != NULL, &dir);
+                                ibreq->ibr_srch.ibr_srch_val != NULL,
+                                &dir, &bptr, flags & ~MASTER_ONLY);
       if (status != NIS_SUCCESS)
        {
-          NIS_RES_STATUS (res) = status;
-          goto fail3;
+         NIS_RES_STATUS (res) = status;
+         goto fail3;
        }
 
-      status = __nisbind_create (&bptr, dir->do_servers.do_servers_val,
-                                dir->do_servers.do_servers_len, flags);
-      if (__builtin_expect (status != NIS_SUCCESS, 0))
-        {
-          NIS_RES_STATUS (res) = status;
-         goto fail2;
-        }
-
       while (__nisbind_connect (&bptr) != NIS_SUCCESS)
        if (__builtin_expect (__nisbind_next (&bptr) != NIS_SUCCESS, 0))
          {
@@ -338,7 +330,6 @@ nis_list (const_nis_name name, unsigned int flags,
                    NIS_RES_STATUS (res) = NIS_NOMEMORY;
                  fail:
                    __nisbind_destroy (&bptr);
-                 fail2:
                    nis_free_directory (dir);
                  fail3:
                    free (tablepath);
@@ -375,11 +366,12 @@ nis_list (const_nis_name name, unsigned int flags,
            else if ((flags & FOLLOW_PATH)
                     && NIS_RES_STATUS (res) == NIS_PARTIAL)
              {
-               clnt_status = __follow_path (&tablepath, &tableptr, ibreq,
-                                            &bptr);
-               if (clnt_status != NIS_SUCCESS)
+               enum nis_error err = __follow_path (&tablepath, &tableptr,
+                                                   ibreq, &bptr);
+               if (err != NIS_SUCCESS)
                  {
-                   NIS_RES_STATUS (res) = clnt_status;
+                   if (err == NIS_NOMEMORY)
+                     NIS_RES_STATUS (res) = err;
                    ++done;
                  }
                else
@@ -434,15 +426,15 @@ nis_list (const_nis_name name, unsigned int flags,
                    NIS_RES_STATUS (allres) = NIS_RES_STATUS (res);
                    xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res);
                  }
-               clnt_status = __follow_path (&tablepath, &tableptr, ibreq,
-                                            &bptr);
-               if (clnt_status != NIS_SUCCESS)
+               enum nis_error err = __follow_path (&tablepath, &tableptr,
+                                                   ibreq, &bptr);
+               if (err != NIS_SUCCESS)
                  {
                    /* Prepare for the nis_freeresult call.  */
                    memset (res, '\0', sizeof (*res));
 
-                   if (clnt_status == NIS_NOMEMORY)
-                     NIS_RES_STATUS (allres) = clnt_status;
+                   if (err == NIS_NOMEMORY)
+                     NIS_RES_STATUS (allres) = err;
                    ++done;
                  }
              }
@@ -459,10 +451,14 @@ nis_list (const_nis_name name, unsigned int flags,
                  ++done;
                else
                  {
-                   NIS_RES_STATUS (res)
+                   enum nis_error err
                      = __follow_path (&tablepath, &tableptr, ibreq, &bptr);
-                   if (NIS_RES_STATUS (res) != NIS_SUCCESS)
-                     ++done;
+                   if (err != NIS_SUCCESS)
+                     {
+                       if (err == NIS_NOMEMORY)
+                         NIS_RES_STATUS (res) = err;
+                       ++done;
+                     }
                  }
              }
            break;