.\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%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 .\" .\" [should really be seteuid.3] .\" Modified, 27 May 2004, Michael Kerrisk .\" Added notes on capability requirements .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2001, 2005 Yuichi SATO .\" all rights reserved. .\" Translated 2001-06-04, Yuichi SATO .\" Updated & Modified 2005-01-04, Yuichi SATO .\" Updated 2010-04-23, Akihiro MOTOKI , LDP v3.24 .\" Updated 2013-05-06, Akihiro MOTOKI .\" .TH SETEUID 2 2017\-09\-15 Linux "Linux Programmer's Manual" .SH 名前 seteuid, setegid \- 実効ユーザー ID や 実効グループ ID を設定する .SH 書式 \fB#include \fP .br \fB#include \fP .PP \fBint seteuid(uid_t \fP\fIeuid\fP\fB);\fP .br \fBint setegid(gid_t \fP\fIegid\fP\fB);\fP .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP .ad l \fBseteuid\fP(), \fBsetegid\fP(): .RS 4 _POSIX_C_SOURCE\ >=\ 200112L || /* glibc 2.19 以前: */ _BSD_SOURCE .RE .ad .SH 説明 \fBseteuid\fP() は呼び出し元のプロセスの実効ユーザー ID を設定する。 非特権プロセスの場合、実効ユーザー ID に設定できるのは、 実ユーザー ID・実効ユーザー ID・保存 set\-user\-ID のいずれかだけである。 .PP .\" When .\" .I euid .\" equals \-1, nothing is changed. .\" (This is an artifact of the implementation in glibc of seteuid() .\" using setresuid(2).) \fBsetegid\fP() は「ユーザー」ではなく「グループ」に対して全く同じことを行う。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .PP \fI注意\fP: 呼び出し元が UID 0 であっても \fBseteuid\fP() が失敗する場合がある。 \fBseteuid\fP() からのリターンが失敗かどうかの確認を省略することは重大なセキュリティ上のエラーとなる。 .SH エラー .TP \fBEINVAL\fP 対象のユーザー ID かグループ ID がこのユーザー名前空間では有効ではない。 .TP \fBEPERM\fP In the case of \fBseteuid\fP(): the calling process is not privileged (does not have the \fBCAP_SETUID\fP capability in its user namespace) and \fIeuid\fP does not match the current real user ID, current effective user ID, or current saved set\-user\-ID. .IP In the case of \fBsetegid\fP(): the calling process is not privileged (does not have the \fBCAP_SETGID\fP capability in its user namespace) and \fIegid\fP does not match the current real group ID, current effective group ID, or current saved set\-group\-ID. .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, 4.3BSD. .SH 注意 実効ユーザー (グループ) ID を保存 set\-user\-ID (保存 set\-group\-ID) に 設定できるのは、Linux 1.1.37 (1.1.38) 以降である。 全てのシステムにおいて \fB_POSIX_SAVED_IDS\fP をチェックすべきである。 .PP glibc 2.0 では、 \fBseteuid(\fP\fIeuid\fP\fB)\fP は \fBsetreuid(\-1,\fP\fI euid\fP\fB)\fP と等価であり、保存 set\-user\-ID を変更するかもしれない。 glibc 2.1 では、 \fBsetresuid(\-1,\fP\fI euid\fP\fB, \-1)\fP と等価であり、保存 set\-user\-ID 変更しない。 同様のことが \fBsetegid\fP() にも言えるが、 glibc 2.2 か 2.3 で、 実装が \fBsetregid(\-1,\fP\fI egid\fP\fB)\fP から \fBsetresgid(\-1,\fP\fI egid\fP\fB, \-1)\fP へ変更された点だけが違う (どの glibc バージョンで変更が行われたかは、ハードウェアアーキテクチャーによって異なる)。 .PP POSIX.1 では、 \fBseteuid\fP() (\fBsetegid\fP()) で、 \fIeuid\fP (\fIegid\fP) として現在の実効ユーザー (グループ) ID と同じ値を指定可能である 必要はないとされており、いくつかの実装では \fIeuid\fP (\fIegid\fP) として現在の実効ユーザー (グループ) ID と同じ値を 指定することができない。 .SS "C ライブラリとカーネルの違い" Linux では、 \fBseteuid\fP() と \fBsetegid\fP() は、それぞれ \fBsetreuid\fP(2) と \fBsetregid\fP(2) を呼び出すライブラリ関数として実装されている。 .SH 関連項目 \fBgeteuid\fP(2), \fBsetresuid\fP(2), \fBsetreuid\fP(2), \fBsetuid\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/ に書かれている。