getresuid() 和 setresuid() 有什么作用?

What do getresuid() and setresuid() do?

函数 getresuid(&arg1,&arg2,&arg3) 和 setresuid(arg1,arg2,arg3) 有什么作用?

如果能对这些函数进行真正基本的解释就更好了。

来自credentials(7) man page(删节):

On Linux, each process has the following user and group identifiers:

  • Real user ID and real group ID. These IDs determine who owns the process.

  • Effective user ID and effective group ID. These IDs are used by the kernel to determine the permissions that the process will have when accessing shared resources such as message queues, shared memory, and semaphores. On most UNIX systems, these IDs also determine the permissions when accessing files. However, Linux uses the file system IDs for this task.

  • Saved set-user-ID and saved set-group-ID. These IDs are used in set-user-ID and set-group-ID programs to save a copy of the corresponding effective IDs that were set when the program was executed. A set-user-ID program can assume and drop privileges by switching its effective user ID back and forth between the values in its real user ID and saved set-user-ID.

这些函数在一次调用中获取并设置所有三个 UID。与往常一样,请参阅完整的手册页以获取完整的详细信息。