GETGRENT(3) BSD Programmer's Manual GETGRENT(3)
g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt, g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm, g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd, s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt, s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt, e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt - group
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<g
\bgr
\brp
\bp.
\b.h
\bh>
\b>
_
\bs_
\bt_
\br_
\bu_
\bc_
\bt _
\bg_
\br_
\bo_
\bu_
\bp _
\b*
g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(_
\bv_
\bo_
\bi_
\bd);
_
\bs_
\bt_
\br_
\bu_
\bc_
\bt _
\bg_
\br_
\bo_
\bu_
\bp _
\b*
g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm(_
\bc_
\bo_
\bn_
\bs_
\bt _
\bc_
\bh_
\ba_
\br _
\b*_
\bn_
\ba_
\bm_
\be);
_
\bs_
\bt_
\br_
\bu_
\bc_
\bt _
\bg_
\br_
\bo_
\bu_
\bp _
\b*
g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd(_
\bg_
\bi_
\bd_
\b__
\bt _
\bg_
\bi_
\bd);
_
\bs_
\bt_
\br_
\bu_
\bc_
\bt _
\bg_
\br_
\bo_
\bu_
\bp _
\b*
s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt(_
\bi_
\bn_
\bt _
\bs_
\bt_
\ba_
\by_
\bo_
\bp_
\be_
\bn);
s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(_
\bv_
\bo_
\bi_
\bd);
e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt(_
\bv_
\bo_
\bi_
\bd);
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
These functions operate on the group database file _
\b/_
\be_
\bt_
\bc_
\b/_
\bg_
\br_
\bo_
\bu_
\bp which is
described in group(5). Each line of the database is defined by the
structure _
\bg_
\br_
\bo_
\bu_
\bp found in the include file <_
\bg_
\br_
\bp_
\b._
\bh>:
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
The functions g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm() and g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd() search the group database for the
given group name pointed to by _
\bn_
\ba_
\bm_
\be or the group id pointed to by _
\bg_
\bi_
\bd,
respectively, returning the first one encountered. Identical group names
or group gids may result in undefined behavior.
The g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() function sequentially reads the group database and is in-
tended for programs that wish to step through the complete list of
All three routines will open the group file for reading, if necesssary.
The s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt() function opens the file, or rewinds it if it is already
open. If _
\bs_
\bt_
\ba_
\by_
\bo_
\bp_
\be_
\bn is non-zero, file descriptors are left open, signifi-
cantly speeding functions subsequent calls. This functionality is unnec-
essary for g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() as it doesn't close its file descriptors by de-
fault. It should also be noted that it is dangerous for long-running
programs to use this functionality as the group file may be updated.
The s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() function is identical to s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt() with an argument of
The e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt() function closes any open files.
R
\bRE
\bET
\bTU
\bUR
\bRN
\bN V
\bVA
\bAL
\bLU
\bUE
\bES
\bS
The functions g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(), g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm(), and g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd(), return a pointer to
the group entry if successful; if end-of-file is reached or an error oc-
curs a null pointer is returned. The functions s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt() and
s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() return the value 1 if successful, otherwise the value 0 is re-
turned. The functions e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt() and s
\bse
\bet
\btg
\bgr
\brf
\bfi
\bil
\ble
\be() have no return value.
/etc/group group database file
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
g
\bge
\bet
\btp
\bpw
\bwe
\ben
\bnt
\bt(_
\b3), g
\bgr
\bro
\bou
\bup
\bp(_
\b5)
H
\bHI
\bIS
\bST
\bTO
\bOR
\bRY
\bY
The functions e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt(), g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(), g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm(), g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd(), and
s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() appeared in Version 7 AT&T UNIX. The functions s
\bse
\bet
\btg
\bgr
\brf
\bfi
\bil
\ble
\be()
and s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt() appeared in 4.3BSD-Reno.
C
\bCO
\bOM
\bMP
\bPA
\bAT
\bTI
\bIB
\bBI
\bIL
\bLI
\bIT
\bTY
\bY
The historic function s
\bse
\bet
\btg
\bgr
\brf
\bfi
\bil
\ble
\be(), which allowed the specification of al-
ternate password databases, has been deprecated and is no longer avail-
The functions g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(), g
\bge
\bet
\btg
\bgr
\brn
\bna
\bam
\bm(), g
\bge
\bet
\btg
\bgr
\brg
\bgi
\bid
\bd(), s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt() and
s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() leave their results in an internal static object and return a
pointer to that object. Subsequent calls to the same function will modify
The functions g
\bge
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt(), e
\ben
\bnd
\bdg
\bgr
\bre
\ben
\bnt
\bt(), s
\bse
\bet
\btg
\bgr
\bro
\bou
\bup
\bpe
\ben
\bnt
\bt(), and s
\bse
\bet
\btg
\bgr
\bre
\ben
\bnt
\bt() are
fairly useless in a networked environment and should be avoided, if pos-