Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all bug

名前

       setgid - グループ識別(identity)を設定する

書式

       #include <sys/types.h>
       #include <unistd.h>

       int setgid(gid_t gid);

説明

       setgid()  sets the effective group ID of the calling process.  If the calling process is privileged (more
       precisely: has the CAP_SETGID capability in its user namespace), the real GID and saved set-group-ID  are
       also set.

       Linux   において、   setgid()   は  _POSIX_SAVED_IDS  をもった  POSIX  版のように実装されている。  これは
       set-user-ID-root でない  set-group-ID  プログラムにそのグループの  特権の全て落とし、特権の必要ない仕事を
       し、本来の実効グループID に 安全な方法で再び戻すことを許す。

返り値

       成功した場合は 0 が返される。エラーの場合は -1 が返され、 errno が適切に設定される。

エラー

       EINVAL gid で指定されたグループ ID がこのユーザー名前空間では有効ではない。

       EPERM  呼び出し元のプロセスに権限がなく  (そのプロセスのユーザー名前空間で  CAP_SETGID ケーパビリティがな
              く)、かつ gid が呼び出し元のプロセスの実グループID と保存セットグループID のどちらとも一致しない。

準拠

       POSIX.1-2001, POSIX.1-2008, SVr4.

注意

       元々の Linux の setgid() システムコールは 16 ビットのグループ ID だけに対応していた。  その後、Linux  2.4
       で、32  ビットの  ID に対応した setgid32() が追加された。 glibc の setgid() のラッパー関数は カーネルバー
       ジョンによるこの違いを吸収している。

   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 setgid())  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 nptl(7).

関連項目

       getgid(2), setegid(2), setregid(2), capabilities(7), credentials(7), user_namespaces(7)

この文書について

       この  man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告
       に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。