OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / release / man2 / getgroups.2
1 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified Thu Oct 31 12:04:29 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\"     Added notes on capability requirements
28 .\" 2008-05-03, mtk, expanded and rewrote parts of DESCRIPTION and RETURN
29 .\"     VALUE, made style of page more consistent with man-pages style.
30 .\"
31 .\"*******************************************************************
32 .\"
33 .\" This file was generated with po4a. Translate the source file.
34 .\"
35 .\"*******************************************************************
36 .\"
37 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
38 .\"         all rights reserved.
39 .\" Translated 1997-02-22, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
40 .\" Updated 2001-02-10, Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
41 .\" Updated & Modified 2004-12-30, Yuichi SATO <ysato444@yahoo.co.jp>
42 .\" Updated 2008-08-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
43 .\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
44 .\"
45 .TH GETGROUPS 2 2014\-08\-19 Linux "Linux Programmer's Manual"
46 .SH 名前
47 getgroups, setgroups \- 補助グループ ID のリストを取得/設定する
48 .SH 書式
49 \fB#include <sys/types.h>\fP
50 .br
51 \fB#include <unistd.h>\fP
52 .sp
53 \fBint getgroups(int \fP\fIsize\fP\fB, gid_t \fP\fIlist\fP\fB[]);\fP
54 .sp
55 \fB#include <grp.h>\fP
56 .sp
57 \fBint setgroups(size_t \fP\fIsize\fP\fB, const gid_t *\fP\fIlist\fP\fB);\fP
58 .sp
59 .in -4n
60 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
61 .in
62 .sp
63 \fBsetgroups\fP(): _BSD_SOURCE
64 .SH 説明
65 .PP
66 \fBgetgroups\fP()  は呼び出し元プロセスの補助グループ (supplementary group) ID を \fIlist\fP に返す。
67 \fIsize\fP 引き数には、 \fIlist\fP により参照されるバッファーに格納できる要素の最大数を設定すべきである。 呼び出し元プロセスが
68 \fIsize\fP 個より多くの補助グループのメンバの場合には、エラーとなる。 この関数を呼び出したプロセスの実効グループ ID が、
69 返されるリストに含まれるかどうかは規定されていない (したがって、アプリケーションは \fBgetegid\fP(2)
70 を呼び出し、その結果の値を追加・削除すべきである)。
71
72 \fIsize\fP が 0 ならば、 \fIlist\fP は修正されないが、そのプロセスの補助グループ ID の合計数が返される。 これを使うことで、それ以降の
73 \fBgetgroups\fP()  の呼び出しで必要となる動的割り当てバッファー \fIlist\fP のサイズを、呼び出し元が決定することができる。
74 .PP
75 \fBsetgroups\fP()  は、呼び出し元プロセスの補助グループ ID を設定する。 適切な特権 (Linux では \fBCAP_SETGID\fP
76 ケーパビリティ (capability)) が必要である。 \fIsize\fP 引き数には、 \fIlist\fP
77 により参照されるバッファーに格納された補助グループ ID の数を指定する。
78 .SH 返り値
79 \fBgetgroups\fP()  は、成功すると補助グループ ID の数を返す。 エラーの場合 \-1 を返し、 \fIerrno\fP を適切に設定する。
80
81 \fBsetgroups\fP()  は、成功すると 0 を返す。 エラーの場合 \-1 を返し、 \fIerrno\fP を適切に設定する。
82 .SH エラー
83 .TP 
84 \fBEFAULT\fP
85 \fIlist\fP が不正なアドレスである。
86 .PP
87 \fBgetgroups\fP()  は、上記に加えて以下のエラーで失敗する可能性がある。
88 .TP 
89 \fBEINVAL\fP
90 \fIsize\fP が補助グループ ID の数より小さいが 0 でない。
91 .PP
92 \fBsetgroups\fP()  は、上記に加えて以下のエラーで失敗する可能性がある。
93 .TP 
94 \fBEINVAL\fP
95 \fIsize\fP が \fBNGROUPS_MAX\fP より大きい (\fBNGROUPS_MAX\fP は Linux 2.6.4 より前では 32、Linux
96 2.6.4 以降では 65536)。
97 .TP 
98 \fBENOMEM\fP
99 メモリー不足。
100 .TP 
101 \fBEPERM\fP
102 呼び出し元プロセスが十分な特権を持っていない。
103 .SH 準拠
104 SVr4, 4.3BSD.  \fBgetgroups\fP()  関数は POSIX.1\-2001 に準拠している。 \fBsetgroups\fP()
105 は特権を必要とするため、POSIX.1\-2001 に従っていない。
106 .SH 注意
107 プロセスは、実効グループ ID に加え、最大 \fBNGROUPS_MAX\fP までの補助グループ ID を持つことができる。 定数
108 \fBNGROUPS_MAX\fP は \fI<limits.h>\fP で定義されている。 補助グループ ID の集合は親プロセスから継承され、
109 \fBexecve\fP(2)  の前後で保持される。
110
111 補助グループ ID の最大数は、実行時に \fBsysconf\fP(3)  を使って以下のようにして調べることができる:
112 .nf
113
114     long ngroups_max;
115     ngroups_max = sysconf(_SC_NGROUPS_MAX);
116
117 .fi
118 \fBgetgroups\fP() の返り値の最大値は、この値より大きくなることはない。 Linux 2.6.4 以降では、補助グループ ID の最大数も
119 Linux 固有の読み込み専用のファイル \fI/proc/sys/kernel/ngroups_max\fP 経由で公開されている。
120
121 元々の Linux の \fBgetgroups\fP() システムコールは 16 ビットのグループ ID だけ
122 に対応していた。その後、Linux 2.4 で、32 ビットの ID に対応した
123 \fBgetgroups\fP() が追加された。glibc の \fBgetgroups\fP のラッパー関数はカーネル
124 バージョンによるこの違いを吸収している。
125 .SH 関連項目
126 \fBgetgid\fP(2), \fBsetgid\fP(2), \fBgetgrouplist\fP(3), \fBgroup_member\fP(3),
127 \fBinitgroups\fP(3), \fBcapabilities\fP(7), \fBcredentials\fP(7)
128 .SH この文書について
129 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
130 である。プロジェクトの説明とバグ報告に関する情報は
131 http://www.kernel.org/doc/man\-pages/ に書かれている。