SETGID

Section: Linux Programmer's Manual (2)
Updated: 2019-03-06
Index JM Home Page
 

名前

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/ に書かれている。

関連キーワード

SETGID, setgid, グループ, process, user, group, gid, credentials, プロセス, エラー

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
エラー
準拠
注意
C ライブラリとカーネルの違い
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:47 GMT, June 11, 2022