#include <sys/fsuid.h> [[deprecated]] int setfsuid(uid_t fsuid);
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 を持つ別のプロセスにシグナルを送信できた。 これは、 特権プロセスがファイルのアクセス許可をチェックするために自身の実効ユーザー 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() のラッパー関数は カーネルバージョンによるこの違いを吸収している。