.\" Copyright (c) 1983, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" %%%LICENSE_END .\" .\" @(#)setregid.2 6.4 (Berkeley) 3/10/91 .\" .\" Modified Sat Jul 24 09:08:49 1993 by Rik Faith .\" Portions extracted from linux/kernel/sys.c: .\" Copyright (C) 1991, 1992 Linus Torvalds .\" May be distributed under the GNU General Public License .\" Changes: 1994-07-29 by Wilf .\" 1994-08-02 by Wilf due to change in kernel. .\" 2004-07-04 by aeb .\" 2004-05-27 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Fri Dec 12 00:18:45 JST 1997 .\" by HANATAKA Shinya .\" Updated & Modified Mon Jun 4 19:11:44 JST 2001 .\" by Yuichi SATO .\" Updated & Modified Wed Jan 5 00:37:49 JST 2005 .\" by Yuichi SATO .\" Updated 2010-04-23, Akihiro MOTOKI , LDP v3.24 .\" Updated 2012-04-30, Akihiro MOTOKI .\" .TH SETREUID 2 2013\-12\-12 Linux "Linux Programmer's Manual" .SH 名前 setreuid, setregid \- 実 (real) と実効 (effective) ユーザー (グループ) ID を設定する .SH 書式 \fB#include \fP .br \fB#include \fP .sp \fBint setreuid(uid_t \fP\fIruid\fP\fB, uid_t \fP\fIeuid\fP\fB);\fP .br \fBint setregid(gid_t \fP\fIrgid\fP\fB, gid_t \fP\fIegid\fP\fB);\fP .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBsetreuid\fP(), \fBsetregid\fP(): .RS 4 .ad l _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .ad .RE .SH 説明 \fBsetreuid\fP() は呼び出し元のプロセスの実 (real) ユーザー ID と 実効 (effective) ユーザー ID を設定する。 実ユーザー ID や実効ユーザー ID に \-1 を与えた場合、 システムはその ID を変更しない。 非特権プロセスは実効ユーザー ID を実ユーザー ID または実効ユーザー ID または 保存 set\-user\-ID にしか設定できない。 非特権ユーザーは、実ユーザー ID を実ユーザー ID または 実効ユーザー ID にしか設定できない。 実ユーザーID が設定されたり (\fIruid\fP が \-1 ではない)、実効ユーザーID が前の実ユーザーID と 異った値に設定された場合、保存 set\-user\-ID には新しい実効ユーザーID の値が設定される。 これと全く同様に、 \fBsetregid\fP() は呼び出し元のプロセスの実グループ ID と実効グループ ID を設定し、 上記の説明で「ユーザー」を「グループ」に読み替えたことが成り立つ。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEPERM\fP 呼び出し元のプロセスに特権がなく (Linux では \fBsetreuid\fP() の場合に \fBCAP_SETUID\fP ケーパビリティ (capability) がなく、 \fBsetregid\fP() の場合に \fBCAP_SETGID\fP ケーパビリティがない)、 以下のいずれでもない変更が指定された: (i) 実効ユーザー (グループ) ID と実ユーザー (グループ) ID を入れ換える。 (ii) 片方の値を他方に設定する。 (iii) 実効ユーザー (グループ) ID に保存 set\-user\-ID (保存 set\-group\-ID) の値を設定する。 .SH 準拠 POSIX.1\-2001, 4.3BSD (\fBsetreuid\fP() と \fBsetregid\fP() 関数コールは 4.2BSD で登場した)。 .SH 注意 実効ユーザー (グループ) ID を保存ユーザー (グループ) ID に 設定することが、Linux 1.1.37 (1.1.38) から可能になった。 POSIX.1 では、非特権プロセスに対して Linux 上で認められている ID の変更の 全パターンを規定しているわけではない。 \fBsetreuid\fP() では、実効ユーザ ID を実ユーザ ID もしくは保存 set\-user\-ID と 同じ値にすることができるが、 非特権プロセスが実ユーザ ID を実ユーザ ID、実効ユーザ ID、 保存 set\-user\-ID のどの値にも設定できるかは規定されていない。 \fBsetregid\fP() では、実グループ ID を保存 set\-group\-ID と同じ値に変更でき、 実効グループ ID を実グループ ID や保存 set\-group\-ID と同じ値に変更できる。 どのような ID の変更が認められているかの正確な詳細は 実装ごとに異なる。 POSIX.1 では、これらのシステムコールが保存 set\-user\-ID や 保存 set\-group\-ID に与える影響については規定していない。 元々の Linux の \fBsetreuid\fP() と \fBsetregid\fP() システムコールは 16 ビットのグループ ID だけに対応していた。 その後、Linux 2.4 で、32 ビットの ID に対応した \fBsetreuid32\fP() と \fBsetregid32\fP() が追加された。 glibc の \fBsetreuid\fP() と \fBsetregid\fP() のラッパー関数は カーネルバージョンによるこの違いを吸収している。 .SH 関連項目 \fBgetgid\fP(2), \fBgetuid\fP(2), \fBseteuid\fP(2), \fBsetgid\fP(2), \fBsetresuid\fP(2), \fBsetuid\fP(2), \fBcapabilities\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。