aboutsummaryrefslogtreecommitdiff
path: root/documentation/manual-pages/ja/man2/setuid.2
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/manual-pages/ja/man2/setuid.2')
-rw-r--r--documentation/manual-pages/ja/man2/setuid.2189
1 files changed, 189 insertions, 0 deletions
diff --git a/documentation/manual-pages/ja/man2/setuid.2 b/documentation/manual-pages/ja/man2/setuid.2
new file mode 100644
index 0000000000..6dd2140f73
--- /dev/null
+++ b/documentation/manual-pages/ja/man2/setuid.2
@@ -0,0 +1,189 @@
+.\" Copyright (c) 1983, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" 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.
+.\"
+.\" @(#)setuid.2 8.1 (Berkeley) 6/4/93
+.\" %FreeBSD: src/lib/libc/sys/setuid.2,v 1.23 2004/07/05 17:12:52 ru Exp %
+.\"
+.\" $FreeBSD$
+.Dd June 4, 1993
+.Dt SETUID 2
+.Os
+.Sh 名称
+.Nm setuid ,
+.Nm seteuid ,
+.Nm setgid ,
+.Nm setegid
+.Nd ユーザ ID とグループ ID を設定する
+.Sh ライブラリ
+.Lb libc
+.Sh 書式
+.In sys/types.h
+.In unistd.h
+.Ft int
+.Fn setuid "uid_t uid"
+.Ft int
+.Fn seteuid "uid_t euid"
+.Ft int
+.Fn setgid "gid_t gid"
+.Ft int
+.Fn setegid "gid_t egid"
+.Sh 解説
+.Fn setuid
+システムコールは、現在のプロセスの実ユーザ ID と実効ユーザ ID と
+退避ユーザ ID を指定した値に設定します。
+.\" Comment out next block for !_POSIX_SAVED_IDS
+.\" The real user ID and the saved set-user-ID are changed only if the
+.\" effective user ID is that of the super user.
+.\" I.e.
+.\" .Fn setuid
+.\" system call is equal to
+.\" .Fn seteuid
+.\" system call if the effective user ID is not that of the super user.
+.\" End of block
+.Fn setuid
+システムコールが許容されるのは、指定の ID がプロセスの実ユーザ ID
+または実効ユーザ ID に等しい場合、
+または実効ユーザ ID がスーパユーザのものと等しい場合です。
+.\" Comment out next line for !_POSIX_SAVED_IDS
+.\" or the saved set-user-ID
+.\" Next line is for Appendix B.4.2.2 case.
+.Pp
+.Fn setgid
+システムコールは、現在のプロセスの実グループ ID と実効グループ ID と
+退避グループ ID を指定した値に設定します。
+.\" Comment out next block for !_POSIX_SAVED_IDS
+.\" The real group ID and the saved set-group-ID are changed only if the
+.\" effective user ID is that of the super user.
+.\" I.e.
+.\" .Fn setgid
+.\" system call is equal to
+.\" .Fn setegid
+.\" system call if the effective user ID is not that of the super user.
+.\" End of block
+.Fn setgid
+システムコールが許容されるのは、指定の ID がプロセスの実グループ ID
+または実効グループ ID に等しい場合、
+または実効ユーザ ID がスーパユーザのものと等しい場合です。
+.\" Comment out next line for !_POSIX_SAVED_IDS
+.\" or the saved set-group-ID
+.\" Next line is for Appendix B.4.2.2 case.
+.Pp
+.Fn seteuid
+システムコール
+.Pq Fn setegid
+は、現在のプロセスの実効ユーザ (グループ ID) を設定します。
+実効ユーザ ID は実ユーザ ID または退避ユーザ ID (
+.Xr intro 2
+と
+.Xr execve 2
+を参照 ) の値に設定できます。
+これを利用し、ユーザ ID 設定された実行可能ファイルの実効ユーザ ID を
+実ユーザ ID に切り替えた後に、ユーザ ID 設定の値に戻ることで、
+元の権限を得ることができます。
+同じように、実効グループ ID は、
+実グループ ID または退避グループ ID の値に設定できます。
+.Sh 戻り値
+.Rv -std
+.Sh エラー
+本システムコールは次の場合に失敗します:
+.Bl -tag -width Er
+.It Bq Er EPERM
+ユーザがスーパユーザでない場合、または指定された uid がその実 ID、
+実効 ID、または退避 ID でない場合。
+.El
+.Sh セキュリティに関する考察
+ファイルへの読取りと書込み許可は、
+.Xr open 2
+が呼ばれた時に判断されます。
+一度ファイル記述子がオープンされると、権限を落してもそのプロセスの
+読取りまたは書込み許可には影響しません。
+指定されたユーザ ID に、そのファイルへの読取りまたは書込み許可が
+なくともです。
+通常これらのファイルは、新しいプロセスの実行時にオープンされたままとなり、
+その結果、ユーザがもしかすると要注意であるデータを読んだり修正したり
+できてしまいます。
+.Pp
+これらのファイルが
+.Xr exec 3
+呼び出しの後でもオープンされたままにされるのを防ぐには、
+close-on-exec フラグを設定するようにしてください:
+.Bd -literal
+void
+pseudocode(void)
+{
+ int fd;
+ /* ... */
+
+ fd = open("/path/to/sensitive/data", O_RDWR);
+ if (fd == -1)
+ err(1, "open");
+
+ /*
+ * close-on-exec フラグの設定; さらなる情報は fcntl(2) を参照。
+ */
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+ err(1, "fcntl(F_SETFD)");
+ /* ... */
+ execve(path, argv, environ);
+}
+.Ed
+.Sh 関連項目
+.Xr getgid 2 ,
+.Xr getuid 2 ,
+.Xr issetugid 2 ,
+.Xr setregid 2 ,
+.Xr setreuid 2
+.Sh 規格
+.Fn setuid
+システムコールと
+.Fn setgid
+システムコールは
+.St -p1003.1-90
+仕様と互換性があります。
+ただし、
+.Li _POSIX_SAVED_IDS
+.\" Uncomment next line for !_POSIX_SAVED_IDS
+は付録 B.4.2.2 の許可された拡張で定義されていません。
+.Fn seteuid
+システムコールと
+.Fn setegid
+システムコールは、
+.Li _POSIX_SAVED_IDS
+の
+.Tn POSIX
+コンセプトを基礎にして拡張してあり、規格の将来の改定用に提案されています。
+.Sh 歴史
+.Fn setuid
+関数と
+.Fn setgid
+関数は
+.At v7
+で登場しました。