Several user IDs of linux processes and their conversion

Source: Internet
Author: User
Linux Process user IDs and their conversion-Linux general technology-Linux programming and kernel information. The following is a detailed description. Linux sets three IDs for each process: the actual user ID, valid and user id, and saved settings ID.

Pay attention to the following aspects for these three IDs:

1. Only the root user can change the actual user ID of the process. For example, if you log on from the login program of the terminal, all three IDs of the login program are root. After the username and password are entered correctly, the login program then setuid to the registered id. Therefore, all three IDs are changed to the registered user id. Then exec shell program. After a non-root user registers for the shell, his actual user ID will never be changed. Unless you register the shell again after logging out. Some su operations to change users are actually to change the valid user ID of the shell process, not the actual user ID of the shell process.

2.exe c program, the executable file has a set id bit. The setting of this bit is closely related to the valid user id of the process and the saved setting id. You can run the ll command to check whether the s Mark is set. Otherwise, no. If no value is set, the three IDs will not change the same as the IDs of the caller's process. The actual user id remains unchanged. The valid user id is set as the owner of the executable file. The saved settings are the same as the valid user id. There are many such programs, such as passwd and su. For example, in the passwd program, a common user foo executes passwd through shell. First, the shell process fork generates a sub-process, and then the sub-process exec passwd program. Because passwd sets the id bit, and passwd belongs to the root user. The sub-process sets the valid user ID as root, and the saved user ID as root. When passwd is executed, change the valid user ID and save the Set User ID to the previous actual user id value.

3. Saved settings-user-ID is copied by exec from valid user I D. After exec sets the valid user I d by file user I D, this replication is performed and the copy is saved.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.