1 .\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" A few pieces remain from an earlier version written in
25 .\" 2002 by Walter Harms (walter.harms@informatik.uni-oldenburg.de)
27 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
28 .\" all rights reserved.
29 .\" Translated 2004-08-07, Yuichi SATO <ysato444@yahoo.co.jp>
30 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
32 .TH GETGROUPLIST 3 2009-07-03 "GNU" "Linux Programmer's Manual"
34 getgrouplist \- ¥æ¡¼¥¶¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë
38 .BI "int getgrouplist(const char *" user ", gid_t " group ,
40 .BI " gid_t *" groups ", int *" ngroups );
43 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
44 .RB ( feature_test_macros (7)
52 ´Ø¿ô¤Ï¡¢¥°¥ë¡¼¥×¥Ç¡¼¥¿¥Ù¡¼¥¹
56 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë¡£
57 ¸«¤Ä¤«¤Ã¤¿¥°¥ë¡¼¥×¤Î¤¦¤ÁºÇÂç
61 ¤Ë³ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¡£
65 ¤¬¥°¥ë¡¼¥×¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë
67 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¤¬¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
69 ¤¬ÊÖ¤¹¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤Ë°ú¤¿ô
72 Ä̾ï¤Ï¡¢¤³¤Î°ú¤¿ô¤Ë¤Ï¥æ¡¼¥¶
74 ¤Î¥Ñ¥¹¥ï¡¼¥É¥ì¥³¡¼¥É¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¥°¥ë¡¼¥× ID ¤ò»ØÄꤹ¤ë¡£
78 ¤Ï¡¢ÃÍÅϤ·¤È·ë²Ì¤ÎξÊý¤Ë»ÈÍѤµ¤ì¤ë°ú¤¿ô (value-result argument) ¤Ç¤¢¤ê¡¢
83 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¿ô¤¬³ÊǼ¤µ¤ì¤ë¡£
86 ¤Ë³ÊǼ¤µ¤ì¤¿¥°¥ë¡¼¥×¿ô¤è¤êÂ礤¯¤Ê¤ë²ÄǽÀ¤¬¤¢¤ë¡£
89 ¤¬½ê°¤·¤Æ¤¤¤ë¥°¥ë¡¼¥×¿ô¤¬
97 ¤è¤ê¿¤¯¤Î¥°¥ë¡¼¥×¤Ë½ê°¤·¤Æ¤¤¤ë¾ì¹ç¡¢
102 ¤ÇÊÖ¤µ¤ì¤ëÃͤò»È¤Ã¤Æ¡¢¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤òÊѹ¹¤·¤Æ¤«¤é¡¢
104 ¤ò¤â¤¦°ìÅٸƤӽФ¹¤³¤È¤¬¤Ç¤¤ë¡£
106 ¤³¤Î´Ø¿ô¤Ï glibc 2.2.4 ¤«¤é¸ºß¤¹¤ë¡£
108 ¤³¤Î´Ø¿ô¤ÏÈóɸ½à¤Ç¤¢¤ë¡£¤Û¤È¤ó¤É¤Î BSD ¤Ë¸ºß¤¹¤ë¡£
110 ¥Ð¡¼¥¸¥ç¥ó 2.3.3 ¤è¤êÁ°¤Î glibc ¤Ç¤Ï¡¢
111 ¤³¤Î´Ø¿ô¤Î¼ÂÁõ¤Ë¤Ï¥Ð¥Ã¥Õ¥¡¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Î¥Ð¥°¤¬¤¢¤ê¡¢
113 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¿ô¤¬
115 ¤è¤ê¿¤¤¾ì¹ç¤Ç¤¢¤Ã¤Æ¤â¡¢
117 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¤ÎÁ´¥ê¥¹¥È¤òÇÛÎó
122 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢°ì¤ÄÌܤΥ³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤Ç»ØÄꤵ¤ì¤¿Ì¾Á°¤Î¥æ¡¼¥¶
123 ¤¬½ê°¤¹¤ë¥°¥ë¡¼¥×¤Î¥ê¥¹¥È¤òɽ¼¨¤¹¤ë¡£
124 ÆóÈÖÌܤΥ³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤Ë¤Ï¡¢
129 °Ê²¼¤Î¥·¥§¥ë¤Î¥»¥Ã¥·¥ç¥ó¤Ï¤³¤Î¥×¥í¥°¥é¥à¤Î»ÈÍÑÎã¤ò¼¨¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
133 .RB "$" " ./a.out cecilia 0"
134 getgrouplist() returned -1; ngroups = 3
135 .RB "$" " ./a.out cecilia 3"
142 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
151 main(int argc, char *argv[])
159 fprintf(stderr, "Usage: %s <user> <ngroups>\\n", argv[0]);
163 ngroups = atoi(argv[2]);
165 groups = malloc(ngroups * sizeof (gid_t));
166 if (groups == NULL) {
171 /* Fetch passwd structure (contains first group ID for user) */
173 pw = getpwnam(argv[1]);
179 /* Retrieve group list */
181 if (getgrouplist(argv[1], pw\->pw_gid, groups, &ngroups) == \-1) {
182 fprintf(stderr, "getgrouplist() returned \-1; ngroups = %d\\n",
187 /* Display list of retrieved groups, along with group names */
189 fprintf(stderr, "ngroups = %d\\n", ngroups);
190 for (j = 0; j < ngroups; j++) {
191 printf("%d", groups[j]);
192 gr = getgrgid(groups[j]);
194 printf(" (%s)", gr\->gr_name);