.\" Copyright (C) 1997 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 .\" .\" Modified, 2003-05-26, Michael Kerrisk, .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated 1997-08-30, HANATAKA Shinya .\" Updated & Modified 2004-05-22, Yuichi SATO .\" Updated & Modified 2005-01-04, Yuichi SATO .\" Updated & Modified 2005-09-03, Akihiro MOTOKI .\" Updated & Modified 2005-11-04, Akihiro MOTOKI .\" Updated 2012-04-30, Akihiro MOTOKI .\" .TH SETRESUID 2 2014\-09\-21 Linux "Linux Programmer's Manual" .SH 名前 setresuid, setresgid \- ユーザーやグループの 実、実効、保存 ID を設定する .SH 書式 \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ .br \fB#include \fP .sp \fBint setresuid(uid_t \fP\fIruid\fP\fB, uid_t \fP\fIeuid\fP\fB, uid_t \fP\fIsuid\fP\fB);\fP .br \fBint setresgid(gid_t \fP\fIrgid\fP\fB, gid_t \fP\fIegid\fP\fB, gid_t \fP\fIsgid\fP\fB);\fP .SH 説明 \fBsetresuid\fP() は呼び出し元のプロセスの実 (real) ユーザーID、実効 (effective) ユーザーID、 保存 set\-user\-ID を設定する。 非特権ユーザーのプロセスは、その実 UID、実効 UID、保存 set\-user\-ID を、 現在の実 UID、現在の実効 UID、現在の保存 set\-user\-ID のどれかに変更することができる: 特権プロセス (Linux では \fBCAP_SETUID\fP ケーパビリティ (capability) を持つ プロセス) は、実 UID、実効 UID、保存 set\-user\-ID を任意の値に設定できる。 引き数のどれかが \-1 の場合はその値は変更されずに残される。 実 UID、実効 UID、保存 set\-user\-ID にどんな変更が行われたかに関わらず、 ファイルシステム UID は常に実効 UID (可能であれば変更後の新しい実効 UID) と同じ値に設定される。 全く同じように、 \fBsetresgid\fP() は呼び出し元のプロセスの実 GID、実効 GID、保存 set\-group\-ID を設定する (さらにファイルシステム GID を実効 GID と同じ値に修正する)。 非特権プロセスは同様の制限を受ける。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 \fI注意\fP: 呼び出し元が UID 0 であっても \fBsetresuid\fP() が失敗する場合がある。 \fBsetresuid\fP() からのリターンが失敗かどうかの確認を省略することは重大なセキュリティ上のエラーとなる。 .SH エラー .TP \fBEAGAIN\fP この呼び出しで呼び出し元の実 UID が変更されるはずだったが (つまり、 \fIruid\fP が呼び出し元の実 UID と一致していない)、 必要なカーネルのデータ構造体の割り当てで一時的な失敗があった。 .TP \fBEAGAIN\fP \fIruid\fP は呼び出し元の実 UID と一致しておらず、 この呼び出しで実ユーザー ID \fIruid\fP に属するプロセス数が呼び出し元の \fBRLIMIT_NPROC\fP リソース上限を超過するところであった。 Linux 3.1 以降では、このエラーはもはや発生することはない (しかし、堅牢性が求められるアプリケーションではこのエラーを確認すべきである)。 \fBexecve\fP(2) の \fBEAGAIN\fP の説明を参照。 .TP \fBEINVAL\fP 対象のユーザー ID やグループ ID のうち 1 つ以上がこのユーザー名前空間で有効ではない。 .TP \fBEPERM\fP 呼び出したプロセスが特権を持たないのに (\fBCAP_SETUID\fP ケーパビリティを持たないのに)、 ID を許されていない値に変更しようとした。 .SH バージョン Linux ではバージョン 2.1.44 より利用可能になった。 .SH 準拠 これらのコールは非標準である。 HP\-UX や BSD 系のいくつかにも存在する。 .SH 注意 HP\-UX や FreeBSD では \fI\fP にプロトタイプが存在する。 Linux では、glibc 2.3.2 以降で プロトタイプが提供されている。 元々の Linux の \fBsetresuid\fP() と \fBsetresgid\fP() システムコールは 16 ビットのグループ ID だけに対応していた。 その後、Linux 2.4 で、32 ビットの ID に対応した \fBsetresuid32\fP() と \fBsetresgid32\fP() が追加された。 glibc の \fBsetresuid\fP() と \fBsetresgid\fP() のラッパー関数は カーネルバージョンによるこの違いを吸収している。 .SH 関連項目 \fBgetresuid\fP(2), \fBgetuid\fP(2), \fBsetfsgid\fP(2), \fBsetfsuid\fP(2), \fBsetreuid\fP(2), \fBsetuid\fP(2), \fBcapabilities\fP(7), \fBcredentials\fP(7), \fBuser_namespaces\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。