Real, effective and saved user id in C program


 
Thread Tools Search this Thread
Top Forums Programming Real, effective and saved user id in C program
# 1  
Old 04-01-2019
Real, effective and saved user id in C program

I figured it out by now.

Last edited by Ralph; 04-02-2019 at 02:26 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Regarding real example of user of semicolon(;) and + in find/exec command.

Hello All, Was recently working on an requirement where we have to search files more than a specific number, following is the example on same. Let's say file names are test_40000.txt,test_40001.txt and so on till test_99999.txt. Now requirement was to search from find command only those... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

2. UNIX for Dummies Questions & Answers

[Solved] effective user id upon exec

Hello all. Despite the exec man page, the exec system call seems to turn my effective-user-id into my real-user-id. I coded and compiled 2 very simple c programs as user 1 (uid=501) The first one (A) prints real and effective user IDs and then execs the second one (B), which in turn prints... (7 Replies)
Discussion started by: oviv
7 Replies

3. UNIX for Dummies Questions & Answers

Real and Effective IDs

Can anyone explain me in details of Real and Effective IDs (6 Replies)
Discussion started by: kkalyan
6 Replies

4. Solaris

Help with who am i . Not displaying real user

Hi I'm trying to get the real username of any user running as root on my server. On one of my server running Sol 10, if I su to root and run who am i, it displays my username. which is what I want. But when I run it on another server, this time on Sol 8, it displays root as the user. Is... (9 Replies)
Discussion started by: wisdom
9 Replies

5. Shell Programming and Scripting

In real time - what user connects or disconnect

Write a tool that will be displayed in real time, what user connects or disconnects from a system that uses this tool :)) Maybe anyone can help me? (2 Replies)
Discussion started by: titasas
2 Replies

6. Shell Programming and Scripting

how to get real user name

I know that in order to get a real user name I should use the following command: cut -d: -f5 /etc/passwd. But how can I get the real user name for those users who are currently logged in to the system??? :confused: Can somebody help me??? (3 Replies)
Discussion started by: aga
3 Replies

7. Post Here to Contact Site Administrators and Moderators

I'm need effective program for advertising internet-projects

Anybody can recomend me websites for purchase professional software for website advertising? It's really important to me. Please, help. Thanks P.S. Also I need for advertising soft that can break CAPTHA's, can mass posting, can sort sites by Google PageRank (PR) and others. Also, I'm interested... (1 Reply)
Discussion started by: WebPromoters
1 Replies

8. Cybersecurity

Changing effective user

I would like to give execution rights for a script to one user. (that's the easy part...) When that user is running the script, I would like the effective user ID to be that of the file-owner. Is this possible? (6 Replies)
Discussion started by: hilmel
6 Replies
Login or Register to Ask a Question
setuid(2)							   System Calls 							 setuid(2)

NAME
setuid, setegid, seteuid, setgid - set user and group IDs SYNOPSIS
#include <sys/types.h> #include <unistd.h> int setuid(uid_t uid); int setgid(gid_t gid); int seteuid(uid_t euid); int setegid(gid_t egid); DESCRIPTION
The setuid() function sets the real user ID, effective user ID, and saved user ID of the calling process. The setgid() function sets the real group ID, effective group ID, and saved group ID of the calling process. The setegid() and seteuid() functions set the effective group and user IDs respectively for the calling process. See Intro(2) for more information on real, effective, and saved user and group IDs. At login time, the real user ID, effective user ID, and saved user ID of the login process are set to the login ID of the user responsible for the creation of the process. The same is true for the real, effective, and saved group IDs; they are set to the group ID of the user responsible for the creation of the process. When a process calls one of the exec(2) family of functions to execute a file (program), the user and/or group identifiers associated with the process can change. If the file executed is a set-user-ID file, the effective and saved user IDs of the process are set to the owner of the file executed. If the file executed is a set-group-ID file, the effective and saved group IDs of the process are set to the group of the file executed. If the file executed is not a set-user-ID or set-group-ID file, the effective user ID, saved user ID, effective group ID, and saved group ID are not changed. If the {PRIV_PROC_SETID} privilege is asserted in the effective set of the process calling setuid(), the real, effective, and saved user IDs are set to the uid argument. If the uid argument is 0 and none of the saved, effective or real UID is 0, additional restrictions apply. See privileges(5). If the {PRIV_PROC_SETID} privilege is not asserted in the effective set, but uid is either the real user ID or the saved user ID of the calling process, the effective user ID is set to uid. If the {PRIV_PROC_SETID} privilege is asserted in the effective set of the process calling setgid(), the real, effective, and saved group IDs are set to the gid argument. If the {PRIV_PROC_SETID} privilege is not asserted in the effective set, but gid is either the real group ID or the saved group ID of the calling process, the effective group ID is set to gid. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The setuid() and setgid() functions will fail if: EINVAL The value of uid or gid is out of range. EPERM For setuid() and seteuid(), the {PRIV_PROC_SETID} privilege is not asserted in the effective set of the calling process and the uid argument does not match either the real or saved user IDs, or an attempt is made to change to UID 0 and none of the existing UIDs is 0, in which case additional privileges are required. For setgid() and setegid(), the {PRIV_PROC_SETID} privilege is not asserted in the effective set and the gid argument does not match either the real or saved group IDs. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
Intro(2), exec(2), getgroups(2), getuid(2), stat.h(3HEAD), attributes(5), privileges(5), standards(5) SunOS 5.11 20 Jan 2003 setuid(2)