ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/src/trunk/lib/libc/gen/getgrent.c
(Generate patch)

Comparing trunk/lib/libc/gen/getgrent.c (file contents):
Revision 10620 by laffer1, Sat Dec 7 23:54:44 2013 UTC vs.
Revision 10621 by laffer1, Sat Jun 9 15:41:32 2018 UTC

# Line 1 | Line 1
1 + /* $MidnightBSD$ */
2   /*-
3   * Copyright (c) 2003 Networks Associates Technology, Inc.
4   * All rights reserved.
# Line 31 | Line 32
32   *
33   */
34   #include <sys/cdefs.h>
35 < __MBSDID("$MidnightBSD$");
35 > __FBSDID("$FreeBSD: stable/10/lib/libc/gen/getgrent.c 328943 2018-02-06 19:09:49Z mckusick $");
36  
37   #include "namespace.h"
38   #include <sys/param.h>
# Line 433 | Line 434 | gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *g
434   {
435          int     ret, dupc;
436  
437 <        for (dupc = 0; dupc < MIN(maxgrp, *grpcnt); dupc++) {
437 >        for (dupc = 1; dupc < MIN(maxgrp, *grpcnt); dupc++) {
438                  if (groups[dupc] == gid)
439                          return 1;
440          }
# Line 659 | Line 660 | __getgroupmembership(const char *uname, gid_t agroup,
660                  NS_FALLBACK_CB(getgroupmembership_fallback)
661                  { NULL, NULL, NULL }
662          };
662        int rv;
663  
664          assert(uname != NULL);
665          /* groups may be NULL if just sizing when invoked with maxgrp = 0 */
666          assert(grpcnt != NULL);
667  
668          *grpcnt = 0;
669 <        rv = _nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
669 >        (void)_nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
670              defaultsrc, uname, agroup, groups, maxgrp, grpcnt);
671  
672          /* too many groups found? */
# Line 810 | Line 810 | files_setgrent(void *retval, void *mdata, va_list ap)
810                  if (st->fp != NULL)
811                          rewind(st->fp);
812                  else if (stayopen)
813 <                        st->fp = fopen(_PATH_GROUP, "r");
813 >                        st->fp = fopen(_PATH_GROUP, "re");
814                  break;
815          case ENDGRENT:
816                  if (st->fp != NULL) {
# Line 861 | Line 861 | files_group(void *retval, void *mdata, va_list ap)
861          if (*errnop != 0)
862                  return (NS_UNAVAIL);
863          if (st->fp == NULL &&
864 <            ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
864 >            ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
865                  *errnop = errno;
866                  return (NS_UNAVAIL);
867          }
# Line 1251 | Line 1251 | compat_setgrent(void *retval, void *mdata, va_list ap)
1251                  if (st->fp != NULL)
1252                          rewind(st->fp);
1253                  else if (stayopen)
1254 <                        st->fp = fopen(_PATH_GROUP, "r");
1254 >                        st->fp = fopen(_PATH_GROUP, "re");
1255                  set_setent(dtab, mdata);
1256                  (void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
1257                      compatsrc, 0);
# Line 1335 | Line 1335 | compat_group(void *retval, void *mdata, va_list ap)
1335          if (*errnop != 0)
1336                  return (NS_UNAVAIL);
1337          if (st->fp == NULL &&
1338 <            ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
1338 >            ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
1339                  *errnop = errno;
1340                  rv = NS_UNAVAIL;
1341                  goto fin;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines