Changeset 1553 for trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c
- Timestamp:
- May 3, 2010, 1:20:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c
r1131 r1553 3 3 * group database for nss_nonlocal proxy 4 4 * 5 * Copyright © 2007 Anders Kaseorg <andersk@mit.edu> and Tim Abbott6 * <tabbott@mit.edu>5 * Copyright © 2007–2010 Anders Kaseorg <andersk@mit.edu> and Tim 6 * Abbott <tabbott@mit.edu> 7 7 * 8 * Permission is hereby granted, free of charge, to any person 9 * obtaining a copy of this software and associated documentation 10 * files (the "Software"), to deal in the Software without 11 * restriction, including without limitation the rights to use, copy, 12 * modify, merge, publish, distribute, sublicense, and/or sell copies 13 * of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 8 * This file is part of nss_nonlocal. 15 9 * 16 * The above copyright notice and this permission notice shall be 17 * included in all copies or substantial portions of the Software. 10 * nss_nonlocal is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public License 12 * as published by the Free Software Foundation; either version 2.1 of 13 * the License, or (at your option) any later version. 18 14 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 * SOFTWARE. 15 * nss_nonlocal is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with nss_nonlocal; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 23 * 02110-1301 USA 27 24 */ 28 25 … … 82 79 int old_errno = errno; 83 80 84 int buflen = sysconf(_SC_GETGR_R_SIZE_MAX);81 size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); 85 82 char *buf = malloc(buflen); 86 83 if (buf == NULL) { … … 117 114 118 115 if (status == NSS_STATUS_SUCCESS) { 119 syslog(LOG_ WARNING, "nss_nonlocal: removing local group %u (%s) from non-local user %s\n", gbuf.gr_gid, gbuf.gr_name, user);116 syslog(LOG_DEBUG, "nss_nonlocal: removing local group %u (%s) from non-local user %s\n", gbuf.gr_gid, gbuf.gr_name, user); 120 117 status = NSS_STATUS_NOTFOUND; 121 118 } else if (status != NSS_STATUS_TRYAGAIN) { … … 125 122 free(buf); 126 123 return status; 124 } 125 126 enum nss_status 127 check_nonlocal_group(const char *user, struct group *grp, int *errnop) 128 { 129 enum nss_status status = NSS_STATUS_SUCCESS; 130 int old_errno = errno; 131 char *end; 132 unsigned long gid; 133 134 errno = 0; 135 gid = strtoul(grp->gr_name, &end, 10); 136 if (errno == 0 && *end == '\0' && (gid_t)gid == gid) 137 status = check_nonlocal_gid(user, gid, errnop); 138 errno = old_errno; 139 if (status != NSS_STATUS_SUCCESS) 140 return status; 141 142 return check_nonlocal_gid(user, grp->gr_gid, errnop); 127 143 } 128 144 … … 281 297 status = DL_CALL_FCT(grent_fct.l, (grp, buffer, buflen, errnop)); 282 298 while (status == NSS_STATUS_SUCCESS && 283 check_nonlocal_g id("(unknown)", grp->gr_gid, &nonlocal_errno) != NSS_STATUS_SUCCESS);299 check_nonlocal_group("(unknown)", grp, &nonlocal_errno) != NSS_STATUS_SUCCESS); 284 300 } 285 301 if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) … … 330 346 return status; 331 347 332 return check_nonlocal_gid(name, grp->gr_gid, errnop); 348 if (strcmp(name, grp->gr_name) != 0) { 349 syslog(LOG_ERR, "nss_nonlocal: discarding group %s from lookup for group %s\n", grp->gr_name, name); 350 return NSS_STATUS_NOTFOUND; 351 } 352 353 return check_nonlocal_group(name, grp, errnop); 333 354 } 334 355 … … 368 389 return status; 369 390 370 return check_nonlocal_gid(grp->gr_name, grp->gr_gid, errnop); 391 if (gid != grp->gr_gid) { 392 syslog(LOG_ERR, "nss_nonlocal: discarding gid %d from lookup for gid %d\n", grp->gr_gid, gid); 393 return NSS_STATUS_NOTFOUND; 394 } 395 396 return check_nonlocal_group(grp->gr_name, grp, errnop); 371 397 } 372 398 … … 391 417 int is_local = 0; 392 418 char *buffer; 419 int old_errno; 420 int in, out, i; 393 421 394 422 /* Check that the user is a nonlocal user before adding any groups. */ … … 399 427 is_local = 1; 400 428 401 intold_errno = errno;429 old_errno = errno; 402 430 403 431 status = get_local_group(MAGIC_LOCAL_GROUPNAME, … … 462 490 return NSS_STATUS_SUCCESS; 463 491 464 in t in = *start, out = *start, i;492 in = out = *start; 465 493 466 494 nip = nss_group_nonlocal_database();
Note: See TracChangeset
for help on using the changeset viewer.