Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do getresuid() and setresuid() do?

Tags:

linux

unix

setuid

What do the functions getresuid(&arg1,&arg2,&arg3) and setresuid(arg1,arg2,arg3) do?

It would be great if a really basic explanation of these functions were given.

like image 485
Aswin G Avatar asked Dec 24 '15 12:12

Aswin G


1 Answers

From the credentials(7) man page (abridged):

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.

Those functions get and set all three of those UIDs in one call. And as always, see the full man page for complete details.

like image 83
Ignacio Vazquez-Abrams Avatar answered Oct 05 '22 21:10

Ignacio Vazquez-Abrams