# 2.11BSD#431 - /usr/src/lib/libc/gen/initgroups.c

##### Functions

    initgroups        X

       1: /*
       2:  * Copyright (c) 1983 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #if defined(LIBC_SCCS) && !defined(lint)
       8: static char sccsid[] = "@(#)initgroups.c	5.3 (Berkeley) 4/27/86";
       9: #endif LIBC_SCCS and not lint
      10:
      11: /*
      12:  * initgroups
      13:  */
      14: #include <stdio.h>
      15: #include <sys/param.h>
      16: #include <grp.h>
      17:
      18: struct group *getgrent();
      19:
      20: initgroups(uname, agroup)
      21:     char *uname;
      22:     int agroup;
      23: {
      24:     int groups[NGROUPS], ngroups = 0;
      25:     register struct group *grp;
      26:     register int i;
      27:
      28:     if (agroup >= 0)
      29:         groups[ngroups++] = agroup;
      30:     setgrent();
      31:     while (grp = getgrent()) {
      32:         if (grp->gr_gid == agroup)
      33:             continue;
      34:         for (i = 0; grp->gr_mem[i]; i++)
      35:             if (!strcmp(grp->gr_mem[i], uname)) {
      36:                 if (ngroups == NGROUPS) {
      37: fprintf(stderr, "initgroups: %s is in too many groups\n", uname);
      38:                     goto toomany;
      39:                 }
      40:                 groups[ngroups++] = grp->gr_gid;
      41:             }
      42:     }
      43: toomany:
      44:     endgrent();
      45:     if (setgroups(ngroups, groups) < 0) {
      46:         perror("setgroups");
      47:         return (-1);
      48:     }
      49:     return (0);
      50: }

#### Defined functions

initgroups defined in line 20; used 9 times

- in /usr/src/bin/login/login.c line 383
- in /usr/src/bin/su.c line 114
- in /usr/src/libexec/ftpd/ftpd.c line 444
- in /usr/src/libexec/rexecd/rexecd.c line 185
- in /usr/src/libexec/rshd/rshd.c line 371
- in /usr/src/usr.bin/at/atrun.c line 317
- in /usr/src/usr.bin/uucp/uucpd.c line 189
- in /usr/src/usr.sbin/cron/do_command.c line 182
- in /usr/src/usr.sbin/inetd/inetd.c line 440

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1986-04-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 501 |