.\" Copyright (C), 1994, Graeme W. Wilford. (Wilf.) .\" and Copyright (C) 2010, 2015, Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Fri Jul 29th 12:56:44 BST 1994 Wilf. .\" Modified 1997-01-31 by Eric S. Raymond .\" Modified 2002-03-09 by aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sat Mar 1 16:31:56 JST 1997 .\" by HANATAKA Shinya .\" Updated Fri Feb 7 JST 2003 by Kentaro Shirakata .\" Updated 2012-04-30, Akihiro MOTOKI .\" .TH SETGID 2 2019\-03\-06 Linux "Linux Programmer's Manual" .SH 名前 setgid \- グループ識別(identity)を設定する .SH 書式 \fB#include \fP .br \fB#include \fP .PP \fBint setgid(gid_t \fP\fIgid\fP\fB);\fP .SH 説明 \fBsetgid\fP() sets the effective group ID of the calling process. If the calling process is privileged (more precisely: has the \fBCAP_SETGID\fP capability in its user namespace), the real GID and saved set\-group\-ID are also set. .PP Linux において、 \fBsetgid\fP() は \fB_POSIX_SAVED_IDS\fP をもった POSIX 版のように実装されている。 これは set\-user\-ID\-root でない set\-group\-ID プログラムにそのグループの 特権の全て落とし、特権の必要ない仕事をし、本来の実効グループID に 安全な方法で再び戻すことを許す。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEINVAL\fP \fIgid\fP で指定されたグループ ID がこのユーザー名前空間では有効ではない。 .TP \fBEPERM\fP 呼び出し元のプロセスに権限がなく (そのプロセスのユーザー名前空間で \fBCAP_SETGID\fP ケーパビリティがなく)、かつ \fIgid\fP が呼び出し元のプロセスの実グループID と保存セットグループID のどちらとも一致しない。 .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, SVr4. .SH 注意 .\" 元々の Linux の \fBsetgid\fP() システムコールは 16 ビットのグループ ID だけに対応していた。 その後、Linux 2.4 で、32 ビットの ID に対応した \fBsetgid32\fP() が追加された。 glibc の \fBsetgid\fP() のラッパー関数は カーネルバージョンによるこの違いを吸収している。 .SS "C ライブラリとカーネルの違い" At the kernel level, user IDs and group IDs are a per\-thread attribute. However, POSIX requires that all threads in a process share the same credentials. The NPTL threading implementation handles the POSIX requirements by providing wrapper functions for the various system calls that change process UIDs and GIDs. These wrapper functions (including the one for \fBsetgid\fP()) employ a signal\-based technique to ensure that when one thread changes credentials, all of the other threads in the process also change their credentials. For details, see \fBnptl\fP(7). .SH 関連項目 \fBgetgid\fP(2), \fBsetegid\fP(2), \fBsetregid\fP(2), \fBcapabilities\fP(7), \fBcredentials\fP(7), \fBuser_namespaces\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。