OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / draft / 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 .TH GETGROUPS 2 2010\-11\-22 Linux "Linux Programmer's Manual"
37 .SH 名前
38 getgroups, setgroups \- 補助グループ ID のリストを取得/設定する
39 .SH 書式
40 \fB#include <sys/types.h>\fP
41 .br
42 \fB#include <unistd.h>\fP
43 .sp
44 \fBint getgroups(int \fP\fIsize\fP\fB, gid_t \fP\fIlist\fP\fB[]);\fP
45 .sp
46 \fB#include <grp.h>\fP
47 .sp
48 \fBint setgroups(size_t \fP\fIsize\fP\fB, const gid_t *\fP\fIlist\fP\fB);\fP
49 .sp
50 .in -4n
51 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
52 .in
53 .sp
54 \fBsetgroups\fP(): _BSD_SOURCE
55 .SH 説明
56 .PP
57 \fBgetgroups\fP()  は呼び出し元プロセスの補助グループ (supplementary group) ID を \fIlist\fP に返す。
58 \fIsize\fP 引き数には、 \fIlist\fP により参照されるバッファに格納できる要素の最大数を設定すべきである。 呼び出し元プロセスが \fIsize\fP
59 個より多くの補助グループのメンバの場合には、エラーとなる。 この関数を呼び出したプロセスの実効グループ ID が、
60 返されるリストに含まれるかどうかは規定されていない (したがって、アプリケーションは \fBgetegid\fP(2)
61 を呼び出し、その結果の値を追加・削除すべきである)。
62
63 \fIsize\fP が 0 ならば、 \fIlist\fP は修正されないが、そのプロセスの補助グループ ID の合計数が返される。 これを使うことで、それ以降の
64 \fBgetgroups\fP()  の呼び出しで必要となる動的割り当てバッファ \fIlist\fP のサイズを、呼び出し元が決定することができる。
65 .PP
66 \fBsetgroups\fP()  は、呼び出し元プロセスの補助グループ ID を設定する。 適切な特権 (Linux では \fBCAP_SETGID\fP
67 ケーパビリティ (capability)) が必要である。 \fIsize\fP 引き数には、 \fIlist\fP
68 により参照されるバッファに格納された補助グループ ID の数を指定する。
69 .SH 返り値
70 \fBgetgroups\fP()  は、成功すると補助グループ ID の数を返す。 エラーの場合 \-1 を返し、 \fIerrno\fP を適切に設定する。
71
72 \fBsetgroups\fP()  は、成功すると 0 を返す。 エラーの場合 \-1 を返し、 \fIerrno\fP を適切に設定する。
73 .SH エラー
74 .TP 
75 \fBEFAULT\fP
76 \fIlist\fP が不正なアドレスである。
77 .PP
78 \fBgetgroups\fP()  は、上記に加えて以下のエラーで失敗する可能性がある。
79 .TP 
80 \fBEINVAL\fP
81 \fIsize\fP が補助グループ ID の数より小さいが 0 でない。
82 .PP
83 \fBsetgroups\fP()  は、上記に加えて以下のエラーで失敗する可能性がある。
84 .TP 
85 \fBEINVAL\fP
86 \fIsize\fP が \fBNGROUPS_MAX\fP より大きい (\fBNGROUPS_MAX\fP は Linux 2.6.4 より前では 32、Linux
87 2.6.4 以降では 65536)。
88 .TP 
89 \fBENOMEM\fP
90 メモリ不足。
91 .TP 
92 \fBEPERM\fP
93 呼び出し元プロセスが十分な特権を持っていない。
94 .SH 準拠
95 SVr4, 4.3BSD.  \fBgetgroups\fP()  関数は POSIX.1\-2001 に準拠している。 \fBsetgroups\fP()
96 は特権を必要とするため、POSIX.1\-2001 に従っていない。
97 .SH 注意
98 プロセスは、実効グループ ID に加え、最大 \fBNGROUPS_MAX\fP までの補助グループ ID を持つことができる。 補助グループ ID
99 の集合は親プロセスから継承され、 \fBexecve\fP(2)  の前後で保持される。
100
101 補助グループ ID の最大数は \fBsysconf\fP(3)  を使って以下のようにして調べることができる:
102 .nf
103
104     long ngroups_max;
105     ngroups_max = sysconf(_SC_NGROUPS_MAX);
106
107 .fi
108 \fBgetgroups\fP()  の返り値の最大値は、この値より 1 大きい値より大きくなることはない。
109
110 元々の Linux の \fBgetgroups\fP() システムコールは 16 ビットのグループ ID だけ
111 に対応していた。その後、Linux 2.4 で、32 ビットの ID に対応した
112 \fBgetgroups\fP() が追加された。glibc の \fBgetgroups\fP のラッパー関数はカーネル
113 バージョンによるこの違いを吸収している。
114 .SH 関連項目
115 \fBgetgid\fP(2), \fBsetgid\fP(2), \fBgetgrouplist\fP(3), \fBinitgroups\fP(3),
116 \fBcapabilities\fP(7), \fBcredentials\fP(7)
117 .SH この文書について
118 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
119 である。プロジェクトの説明とバグ報告に関する情報は
120 http://www.kernel.org/doc/man\-pages/ に書かれている。