Difference between setuid () and seteuid ()

Source: Internet
Author: User

Tag: setuid seteuid

Header file: # include <unistd. h>

Define the function: int setuid (uid_t UID );

Function Description:
Setuid () is used to reset the user identification code for executing the current process. however, for this function to be useful, the valid user ID must be 0 (Root ). in Linux, when the root user uses setuid () to convert it to another user identification code, the root permission is discarded and fully converted to the user identity. That is to say, this process will no longer have the setuid () permission in the future. If you only temporarily discard the root permission and want to retrieve the permission again later, you must use seteuid ().


Returned value: if the execution is successful, 0 is returned. If the execution fails,-1 is returned. The error code is stored in errno.

Note: When compiling a program with setuid root, we recommend that you run setuid (getuid () immediately after the root permission is used to reduce the system security risks caused by this program ()); to discard the root permission. in addition, the Linux system will not generate core dump when the process UID and EUID are inconsistent.

Difference between setuid () and seteuid ()

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.