.\" Copyright (c) 1980, 1991, 1993, 1994 .\" 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. .\" .\" @(#)setregid.2 8.2 (Berkeley) 4/16/94 .\" %FreeBSD: src/lib/libc/sys/setregid.2,v 1.6.2.3 2001/08/17 15:42:46 ru Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man2/setregid.2,v 1.4 2001/07/29 05:15:14 horikawa Exp $ .Dd April 16, 1994 .Dt SETREGID 2 .Os .Sh 名称 .Nm setregid .Nd 実グループ ID と実効グループ ID を設定する .Sh ライブラリ .Lb libc .Sh 書式 .Fd #include .Ft int .Fn setregid "gid_t rgid" "gid_t egid" .Sh 解説 現在のプロセスの実グループ ID と実効グループ ID を引数で 指定されたように設定します。 特権のないユーザは、実グループ ID をその実効グループ ID に、または 実効グループ ID をその実グループ ID に変更できます。スーパユーザだけが その他の変更を行えます。 .Pp 実グループ ID と実効グループ ID のどちらかに値 -1 を指定す ると、システムは -1 パラメータの代わりに現在の ID で置き換えます。 .Pp .Fn setregid 関数は、 set-group-ID プログラム内の実グループ ID と実効グループ ID を スワップし、 set-group-ID 値を一時的に放棄できるようにするために作られました。 この関数は正しく機能せず、その目的は、今では .Fn setegid 関数 ( .Xr setuid 2 を参照 ) を使用するとより良く達成できます。 .Pp 実グループ ID と実効グループ ID を同じ値に設定するときは、 標準の .Fn setgid 関数を使用してください。 .Sh 戻り値 処理が正常に完了すると、値 0 が返されます。 そうでない場合は -1 が返され、エラーを示すために .Va errno が設定されます。 .Sh エラー .Bl -tag -width Er .It Bq Er EPERM 現在のプロセスがスーパユーザでなく、その実効グループ ID をその実グループ ID に 変更する以外の変更が指定されました。 .El .Sh 関連項目 .Xr getgid 2 , .Xr issetugid 2 , .Xr setegid 2 , .Xr setgid 2 , .Xr setuid 2 .Sh 歴史 .Fn setregid システムコールは .Bx 4.2 で登場しました。