Changeset 1131 for trunk/server
- Timestamp:
- May 24, 2009, 6:03:52 PM (15 years ago)
- Location:
- trunk/server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/nss_nonlocal/configure.ac
r800 r1131 1 AC_INIT([nss_nonlocal], [1. 8], [andersk@mit.edu])1 AC_INIT([nss_nonlocal], [1.9], [andersk@mit.edu]) 2 2 AC_CANONICAL_TARGET 3 3 AM_INIT_AUTOMAKE([-Wall -Werror foreign]) -
trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c
r800 r1131 98 98 fct.ptr = fct_start; 99 99 do { 100 morebuf: 100 101 if (fct.l == _nss_nonlocal_getgrgid_r) 101 102 status = NSS_STATUS_NOTFOUND; 102 103 else 103 104 status = DL_CALL_FCT(fct.l, (gid, &gbuf, buf, buflen, errnop)); 104 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) 105 break; 105 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) { 106 free(buf); 107 buflen *= 2; 108 buf = malloc(buflen); 109 if (buf == NULL) { 110 *errnop = ENOMEM; 111 errno = old_errno; 112 return NSS_STATUS_TRYAGAIN; 113 } 114 goto morebuf; 115 } 106 116 } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0); 107 117 … … 118 128 119 129 enum nss_status 120 get_local_group(const char *name, struct group *grp, char * buffer, size_t buflen, int *errnop)130 get_local_group(const char *name, struct group *grp, char **buffer, int *errnop) 121 131 { 122 132 static const char *fct_name = "getgrnam_r"; … … 130 140 void *ptr; 131 141 } fct; 132 struct group gbuf; 133 int n; 142 size_t buflen; 134 143 int old_errno = errno; 135 144 136 intlen = sysconf(_SC_GETGR_R_SIZE_MAX);137 char *buf = malloc(len);138 if ( buf== NULL) {145 buflen = sysconf(_SC_GETGR_R_SIZE_MAX); 146 *buffer = malloc(buflen); 147 if (*buffer == NULL) { 139 148 *errnop = ENOMEM; 140 149 errno = old_errno; … … 144 153 if (fct_start == NULL && 145 154 __nss_group_lookup(&startp, fct_name, &fct_start) != 0) { 146 free(buf); 155 free(*buffer); 156 *buffer = NULL; 147 157 return NSS_STATUS_UNAVAIL; 148 158 } … … 150 160 fct.ptr = fct_start; 151 161 do { 162 morebuf: 152 163 if (fct.l == _nss_nonlocal_getgrnam_r) 153 164 status = NSS_STATUS_NOTFOUND; 154 165 else 155 status = DL_CALL_FCT(fct.l, (name, &gbuf, buf, buflen, errnop)); 156 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) 157 break; 158 } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0); 159 160 if (status != NSS_STATUS_SUCCESS) 161 goto get_local_group_done; 162 163 n = snprintf(buffer, buflen, "%s", gbuf.gr_name); 164 if (n < 0 || n >= buflen) { 165 *errnop = ERANGE; 166 status = NSS_STATUS_TRYAGAIN; 167 goto get_local_group_done; 168 } 169 grp->gr_name = buffer; 170 buffer += n; 171 buflen -= n; 172 173 n = snprintf(buffer, buflen, "%s", gbuf.gr_passwd); 174 if (n < 0 || n >= buflen) { 175 *errnop = ERANGE; 176 status = NSS_STATUS_TRYAGAIN; 177 goto get_local_group_done; 178 } 179 grp->gr_passwd = buffer; 180 buffer += n; 181 buflen -= n; 182 183 grp->gr_gid = gbuf.gr_gid; 184 185 if (buflen < sizeof(void *)) { 186 *errnop = ERANGE; 187 status = NSS_STATUS_TRYAGAIN; 188 goto get_local_group_done; 189 } 190 *(void **)buffer = NULL; 191 buffer += sizeof(void *); 192 buflen -= sizeof(void *); 193 194 get_local_group_done: 195 free(buf); 166 status = DL_CALL_FCT(fct.l, (name, grp, *buffer, buflen, errnop)); 167 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) { 168 free(*buffer); 169 buflen *= 2; 170 *buffer = malloc(buflen); 171 if (*buffer == NULL) { 172 *errnop = ENOMEM; 173 errno = old_errno; 174 return NSS_STATUS_TRYAGAIN; 175 } 176 goto morebuf; 177 } 178 } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0); 179 180 if (status != NSS_STATUS_SUCCESS) { 181 free(*buffer); 182 *buffer = NULL; 183 } 184 196 185 return status; 197 186 } … … 401 390 gid_t local_users_gid, gid; 402 391 int is_local = 0; 403 int buflen;404 392 char *buffer; 405 393 … … 413 401 int old_errno = errno; 414 402 415 buflen = sysconf(_SC_GETGR_R_SIZE_MAX);416 buffer = malloc(buflen);417 if (buffer == NULL) {418 *errnop = ENOMEM;419 errno = old_errno;420 return NSS_STATUS_TRYAGAIN;421 }422 403 status = get_local_group(MAGIC_LOCAL_GROUPNAME, 423 &local_users_group, buffer, buflen, errnop);404 &local_users_group, &buffer, errnop); 424 405 if (status == NSS_STATUS_SUCCESS) { 425 406 local_users_gid = local_users_group.gr_gid; 407 free(buffer); 426 408 } else if (status == NSS_STATUS_TRYAGAIN) { 427 free(buffer);428 409 return status; 429 410 } else { … … 432 413 local_users_gid = -1; 433 414 } 434 free(buffer);435 415 436 416 if (is_local) { 437 417 gid = local_users_gid; 438 418 } else { 439 buflen = sysconf(_SC_GETGR_R_SIZE_MAX);440 buffer = malloc(buflen);441 if (buffer == NULL) {442 *errnop = ENOMEM;443 errno = old_errno;444 return NSS_STATUS_TRYAGAIN;445 }446 419 status = get_local_group(MAGIC_NONLOCAL_GROUPNAME, 447 &nonlocal_users_group, buffer, buflen, errnop);420 &nonlocal_users_group, &buffer, errnop); 448 421 if (status == NSS_STATUS_SUCCESS) { 449 422 gid = nonlocal_users_group.gr_gid; 423 free(buffer); 450 424 } else if (status == NSS_STATUS_TRYAGAIN) { 451 free(buffer);452 425 return status; 453 426 } else { … … 456 429 gid = -1; 457 430 } 458 free(buffer);459 431 } 460 432 -
trunk/server/common/oursrc/nss_nonlocal/nonlocal-passwd.c
r782 r1131 96 96 fct.ptr = fct_start; 97 97 do { 98 morebuf: 98 99 if (fct.l == _nss_nonlocal_getpwuid_r) 99 100 status = NSS_STATUS_NOTFOUND; 100 101 else 101 102 status = DL_CALL_FCT(fct.l, (uid, &pwbuf, buf, buflen, errnop)); 102 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) 103 break; 103 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) { 104 free(buf); 105 buflen *= 2; 106 buf = malloc(buflen); 107 if (buf == NULL) { 108 *errnop = ENOMEM; 109 errno = old_errno; 110 return NSS_STATUS_TRYAGAIN; 111 } 112 goto morebuf; 113 } 104 114 } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0); 105 115 … … 147 157 fct.ptr = fct_start; 148 158 do { 159 morebuf: 149 160 if (fct.l == _nss_nonlocal_getpwnam_r) 150 161 status = NSS_STATUS_NOTFOUND; 151 162 else 152 163 status = DL_CALL_FCT(fct.l, (user, &pwbuf, buf, buflen, errnop)); 153 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) 154 break; 164 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) { 165 free(buf); 166 buflen *= 2; 167 buf = malloc(buflen); 168 if (buf == NULL) { 169 *errnop = ENOMEM; 170 errno = old_errno; 171 return NSS_STATUS_TRYAGAIN; 172 } 173 goto morebuf; 174 } 155 175 } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0); 156 176 -
trunk/server/fedora/specs/nss_nonlocal.spec
r800 r1131 2 2 Group: System Environment/Libraries 3 3 Name: nss_nonlocal 4 Version: 1. 84 Version: 1.9 5 5 Release: 0 6 6 URL: http://debathena.mit.edu/nss_nonlocal/
Note: See TracChangeset
for help on using the changeset viewer.