Linux provides the setuid function and the Seteuid function to change the user ID associated with the process, and the process-related user ID has an "actual user ID, a valid user ID, and a saved settings user ID"======================================================function Prototypes:function Parameters:
return Value:
- return 0 upon successful invocation
- Return 1 if the call fails
====================================================
- When the valid user ID of the process is root, the call to the SETUID function sets the actual user ID, valid user ID, and saved settings user ID of the process to UID
- When the valid user ID of a process is an ordinary user, and the parameter uid of the setuid function is equal to the actual user ID of the process or the saved set user ID, this function sets the valid user ID of the process to UID, while the actual user ID and saved settings user ID are not changed
- The call to this function fails when neither of these cases is satisfied.
the Seteuid function and the setuid function are similar, except that only the process valid user ID is modified under the root user, and the three user IDs are not modified like the setuid function. ====================================================Here's how the saved settings User ID works:
- The saved settings user ID is used to hold a copy of the valid user ID when the process is created, and if the setuid function is used during the execution of the program to change the valid user ID, this ID can be used to restore the original valid user ID.
- The user program is not getting the saved settings user ID, and when using the setuid function to restore a valid user ID, you must give a specific euid value.
Process Control (11)---Change the user ID and group ID of the process