setreuidのヘルプ・マニュアル
日本語 英語
setreuid --help
man setreuid
SETREUID(2) Linux Programmer’s Manual SETREUID(2)
名前
setreuid, setregid - 実 (real) と実効 (effective) ユーザー (グループ)
ID を設定する
書式
#include
#include
int setreuid(uid_t ruid, uid_t euid);
int setregid(gid_t rgid, gid_t egid);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
setreuid(), setregid(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
説明
setreuid() は呼び出し元のプロセスの実 (real) ユーザー ID と実効 (effec-
tive) ユーザー ID を設定する。
実 ユ ーザー ID や実効ユーザー ID に -1 を与えた場合、システムはその ID
を変更しない。
非特権プロセスは実効ユーザー ID を実ユーザー ID または実効ユーザ ー ID
または保存 set-user-ID にしか設定できない。
POSIX: 非特権プロセスが実ユーザー ID を実ユーザー ID または実効ユーザー
ID または保存実効ユーザーID に設定できるか否かは、指定されていない。
Linux: 非特権ユーザーは実ユーザー ID を実ユーザー ID または実効ユーザー
ID にしか設定できない。
Linux: 実ユーザーID が設定されたり、実効ユーザーID が前の実ユーザーID
と異った値に設定された場合、保存 set-user-ID には新しい実効ユー ザ ーID
の値が設定される。
こ れと全く同様に、 setregid() は呼び出し元のプロセスの実グループ ID と
実効グループ ID を設定し、上記の説明で「ユーザー」を「グループ」に読 み
替えたことが成り立つ。
返り値
成 功した場合は 0 が返される。エラーの場合は -1 が返され、 errno が適切
に設定される。
エラー
EPERM 呼び出し元のプロセスに特権がなく (Linux では setreuid() の場合に
CAP_SETUID ケーパビリティ (capability) がなく、 setregid() の場
合に CAP_SETGID ケーパビリティがない)、以下のいずれでもない変 更
が 指定された: (i) 実効ユーザー (グループ) ID と実ユーザー (グル
ープ) ID を入れ換える。 (ii) 片方の値を他方に設定する。 (iii) 実
効 ユーザー (グループ) ID に保存 set-user-ID (保存 set-group-ID)
の値を設定する。
準拠
POSIX.1-2001, 4.3BSD (setreuid() と setregid() 関数コールは 4.2BSD で登
場した)。
注意
実 効ユーザー (グループ) ID を保存ユーザー (グループ) ID に設定すること
が、Linux 1.1.37 (1.1.38) から可能になった。
関連項目
getgid(2), getuid(2), seteuid(2), setgid(2), setresuid(2), setuid(2),
capabilities(7)
Linux 2007-07-26 SETREUID(2)
SETREUID(2) Linux Programmer’s Manual SETREUID(2)
NAME
setreuid, setregid - set real and/or effective user or group ID
SYNOPSIS
#include
#include
int setreuid(uid_t ruid, uid_t euid);
int setregid(gid_t rgid, gid_t egid);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
setreuid(), setregid(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
DESCRIPTION
setreuid() sets real and effective user IDs of the calling process.
Supplying a value of -1 for either the real or effective user ID forces
the system to leave that ID unchanged.
Unprivileged processes may only set the effective user ID to the real
user ID, the effective user ID or the saved set-user-ID.
POSIX: It is unspecified whether unprivileged processes may set the
real user ID to the real user ID, the effective user ID or the saved
set-user-ID.
Linux: Unprivileged users may only set the real user ID to the real
user ID or the effective user ID.
Linux: If the real user ID is set or the effective user ID is set to a
value not equal to the previous real user ID, the saved set-user-ID
will be set to the new effective user ID.
Completely analogously, setregid() sets real and effective group ID’s
of the calling process, and all of the above holds with "group" instead
of "user".
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
ERRORS
EPERM The calling process is not privileged (Linux: does not have the
CAP_SETUID capability in the case of setreuid(), or the CAP_SET-
GID capability in the case of setregid()) and a change other
than (i) swapping the effective user (group) ID with the real
user (group) ID, or (ii) setting one to the value of the other
or (iii) setting the effective user (group) ID to the value of
the saved set-user-ID (saved set-group-ID) was specified.
CONFORMING TO
POSIX.1-2001, 4.3BSD (the setreuid() and setregid() function calls
first appeared in 4.2BSD).
NOTES
Setting the effective user (group) ID to the saved set-user-ID (saved
set-group-ID) is possible since Linux 1.1.37 (1.1.38).
SEE ALSO
getgid(2), getuid(2), seteuid(2), setgid(2), setresuid(2), setuid(2),
capabilities(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2007-07-26 SETREUID(2)