~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to grp/initgroups.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1989,91,93,1996-2006,2008,2010 Free Software Foundation, Inc.
 
1
/* Copyright (C) 1989,1991,1993,1996-2006,2008,2010,2011
 
2
   Free Software Foundation, Inc.
2
3
   This file is part of the GNU C Library.
3
4
 
4
5
   The GNU C Library is free software; you can redistribute it and/or
43
44
extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
44
45
 
45
46
extern service_user *__nss_group_database attribute_hidden;
 
47
service_user *__nss_initgroups_database;
 
48
static bool use_initgroups_entry;
46
49
 
47
50
 
48
51
#include "compat-initgroups.c"
68
71
    }
69
72
#endif
70
73
 
71
 
  service_user *nip = NULL;
72
 
  initgroups_dyn_function fct;
73
74
  enum nss_status status = NSS_STATUS_UNAVAIL;
74
 
  int no_more;
75
 
  /* Start is one, because we have the first group as parameter.  */
76
 
  long int start = 1;
 
75
  int no_more = 0;
77
76
 
78
77
  /* Never store more than the starting *SIZE number of elements.  */
79
78
  assert (*size > 0);
80
79
  (*groupsp)[0] = group;
 
80
  /* Start is one, because we have the first group as parameter.  */
 
81
  long int start = 1;
81
82
 
82
 
  if (__nss_group_database != NULL)
 
83
  if (__nss_initgroups_database == NULL)
83
84
    {
84
 
      no_more = 0;
85
 
      nip = __nss_group_database;
 
85
      if (__nss_database_lookup ("initgroups", NULL, "",
 
86
                                 &__nss_initgroups_database) < 0)
 
87
        {
 
88
          if (__nss_group_database == NULL)
 
89
            no_more = __nss_database_lookup ("group", NULL, "compat files",
 
90
                                             &__nss_group_database);
 
91
 
 
92
          __nss_initgroups_database = __nss_group_database;
 
93
        }
 
94
      else
 
95
        use_initgroups_entry = true;
86
96
    }
87
97
  else
88
 
    no_more = __nss_database_lookup ("group", NULL,
89
 
                                     "compat [NOTFOUND=return] files", &nip);
 
98
    /* __nss_initgroups_database might have been set through
 
99
       __nss_configure_lookup in which case use_initgroups_entry was
 
100
       not set here.  */
 
101
    use_initgroups_entry = __nss_initgroups_database != __nss_group_database;
90
102
 
 
103
  service_user *nip = __nss_initgroups_database;
91
104
  while (! no_more)
92
105
    {
93
106
      long int prev_start = start;
94
107
 
95
 
      fct = __nss_lookup_function (nip, "initgroups_dyn");
96
 
 
 
108
      initgroups_dyn_function fct = __nss_lookup_function (nip,
 
109
                                                           "initgroups_dyn");
97
110
      if (fct == NULL)
98
111
        status = compat_call (nip, user, group, &start, size, groupsp,
99
112
                              limit, &errno);
120
133
      if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN)
121
134
        __libc_fatal ("illegal status in internal_getgrouplist");
122
135
 
123
 
      if (status != NSS_STATUS_SUCCESS
 
136
      /* For compatibility reason we will continue to look for more
 
137
         entries using the next service even though data has already
 
138
         been found if the nsswitch.conf file contained only a 'groups'
 
139
         line and no 'initgroups' line.  If the latter is available
 
140
         we always respect the status.  This means that the default
 
141
         for successful lookups is to return.  */
 
142
      if ((use_initgroups_entry || status != NSS_STATUS_SUCCESS)
124
143
          && nss_next_action (nip, status) == NSS_ACTION_RETURN)
125
144
         break;
126
145