SETFSUID

Section: Linux Programmer's Manual (2)
Updated: 2019-05-09
Index JM Home Page
 

名前

setfsuid - ファイルシステムのチェックに用いられるユーザー ID を設定する  

書式

#include <sys/fsuid.h>

int setfsuid(uid_t fsuid);  

説明

On Linux, a process has both a filesystem user ID and an effective user ID. The (Linux-specific) filesystem user ID is used for permissions checking when accessing filesystem objects, while the effective user ID is used for various other kinds of permissions checks (see credentials(7)).

Normally, the value of the process's filesystem user ID is the same as the value of its effective user ID. This is so, because whenever a process's effective user ID is changed, the kernel also changes the filesystem user ID to be the same as the new value of the effective user ID. A process can cause the value of its filesystem user ID to diverge from its effective user ID by using setfsuid() to change its filesystem user ID to the value given in fsuid.

Explicit calls to setfsuid() and setfsgid(2) are (were) usually used only by programs such as the Linux NFS server that need to change what user and group ID is used for file access without a corresponding change in the real and effective user and group IDs. A change in the normal user IDs for a program such as the NFS server is (was) a security hole that can expose it to unwanted signals. (However, this issue is historical; see below.)

setfsuid() は、スーパーユーザーによって呼び出された場合か、 fsuid が呼び出し元の実ユーザーID、実効ユーザーID、 保存セットユーザーID (saved set-user-ID)、現在のファイルシステムグループ ID の値のいずれかに一致する場合にのみ成功する。  

返り値

成功時も失敗時も、 この呼び出しは直前の呼び出し元のファイルシステムユーザー ID の値を返す。  

バージョン

このシステムコールはバージョン 1.2 以降の Linux に存在する。  

準拠

setfsuid() は Linux 特有であり、移植を想定したプログラムで使用してはいけない。  

注意

このシステムコールが導入された当時、 あるプロセスは同じ実効ユーザー ID を持つ別のプロセスにシグナルを送信できた。 これは、 特権プロセスがファイルのアクセス許可をチェックするために自身の実効ユーザー ID を変更すると、 同じユーザー ID を持つ別の (非特権) プロセスが送信したシグナルを受け取るようになってしまうことを意味する。そのため、 プロセスが、 受け取りたくないシグナルを受信する状態にならずに、 ファイルのアクセス許可をチェックするために自身のユーザー ID を変更できるように、 ファイルシステムユーザー ID 属性が追加された。 Linux 2.0 以降では、 シグナルの送信許可の扱いは異なり (kill(2) 参照)、 プロセスは、 望まないプロセスからシグナルを受信してしまう状態にならずに、 自身の実効ユーザー ID を変更することができる。 したがって、 setfsuid() は今日では不要であり、 新規のアプリケーションでは使用すべきではない (setfsgid(2) も同様)。

元々の Linux の setfsuid() システムコールは 16 ビットのグループ ID だけに対応していた。 その後、Linux 2.4 で、32 ビットの ID に対応した setfsuid32() が追加された。 glibc の setfsuid() のラッパー関数は カーネルバージョンによるこの違いを吸収している。  

C ライブラリとカーネルの違い

In glibc 2.15 and earlier, when the wrapper for this system call determines that the argument can't be passed to the kernel without integer truncation (because the kernel is old and does not support 32-bit user IDs), it will return -1 and set errno to EINVAL without attempting the system call.  

バグ

いかなる種類のエラーメッセージも返さず、 成功した場合も失敗した場合も呼び出しは同じ値を返すため、 呼び出しが成功したか失敗したかを直接判定することはできない。 その代わり、 直前の setfsuid() の呼び出しがファイルシステムグループ ID を変更したかどうかを判定するために、 呼び出し元はこの後に setfsuid(-1) などを呼び出して返り値を見なければならない (setfsuid(-1) は常に失敗する)。 最低でも、失敗した場合は EPERM くらいは返すべきである (呼び出し元には CAP_SETUID ケーパビリティがなかったのだから)。  

関連項目

kill(2), setfsgid(2), capabilities(7), credentials(7)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

user, setfsuid, ユーザー, 呼び出し, プロセス, effective, filesystem, SETFSUID, シグナル, 失敗

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
バージョン
準拠
注意
C ライブラリとカーネルの違い
バグ
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:46 GMT, June 11, 2022