Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Changing the user id or euid of the shell itself Post 302528755 by oddthingy on Wednesday 8th of June 2011 01:17:07 AM
Old 06-08-2011
Question Changing the user id or euid of the shell itself

Hi all,

Ok, bear with me on this one, I am a bit new to Unix and it might take me a little bit of time to articulate my question.

I know that every process has a user id and an effective user id. This seems to include the shell itself, because when I type 'ps', I see 'bash' listed as a process, and if I select the right options I can see that the uid and euid of 'bash' match my own uid.
user@tux:~$ ps -o "uid euid cmd"
UID EUID CMD
1000 1000 bash
1000 1000 ps -o uid euid cmd
user@tux:~$
I also know that you can user the 'su' command/script to create a new child shell with a different 'user' to the parent shell. Both the uid and euid of the new shell will be different to the old shell.

My question is, simply: is there any way of changing the effective user id of the shell you are in, instead of creating a subshell?
My (unlearned) gut feeling is that this should be possible, because I can write a 'C' program that changes its own euid 'on the run', and since c programs and shells are both processes, why shouldn't a shell be able to change its own euid (following a command from the user)?
I note that c's 'seteuid' function is called a 'system call', shouldn't it be even easier/more straightforward to make system calls straight from the shell?

Thanks in advance for any answers.

My reason for asking this question simply to deepen my understanding of unix.
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Advanced & Expert Users

Changing permissions of a user

So I need to change the permissions of my user account. I can access the root account on the server, but don't know how to change the permissions of my user account. I was advised to try 'userconf' to see if I am part of a group, but I dunno how that works. ANyone who knows how to see the... (3 Replies)
Discussion started by: achink125
3 Replies

3. AIX

changing user password

I have 02 servers: - Linux RHEL AS 3 (server1) - AIX 5.2 (server2) Running the command rsh server2 passwd derje from the server1 to change derje user password on server2, give me this error: 3004-709 Error while changing the password for "derje" Can somebody help me ? (0 Replies)
Discussion started by: mayge
0 Replies

4. UNIX for Dummies Questions & Answers

To:blowtorch - Setuid uid/euid issue

Hi, Its a shell script. rws by root, r_s by group named "other" and r_x by all others. How can i set the uid from inside a setuid program. please let me know. Also I dont have a c compiler on the system. Thanks Reply With Quote (0 Replies)
Discussion started by: 0ktalmagik
0 Replies

5. Solaris

EUID set for all non-root users

We have a Solaris box. I noticed that whenever any non-root user logins into the box and issues the command id the output is (for example) uid=42568(sam) gid=1245(sam) euid=0(root) egid=2(bin). I have not given any privileges to anyone explicitly. When I issued ls -l in the /usr/bin directory I... (1 Reply)
Discussion started by: chrisanto_2000
1 Replies

6. Red Hat

euid and egid frpm proc

hi, can anyone tell me where can i find euid and egid from /proc file system in RHEL 4? i read stat file, but i got only uid and gid, and cudnot find any entry regarding euid and egid.please suggest... thanks, sanjay (2 Replies)
Discussion started by: sanjaykhuntia
2 Replies

7. AIX

Changing User Characteristics

We use smitty to administer user accounts. Is it safe to make changes to the characteristics of a user while the user is logged in? Can I set "Is this user ACCOUNT LOCKED?" to true ? Can I set an expiration date on an account? Will this effect the user in anyway during their current... (1 Reply)
Discussion started by: andrewsc
1 Replies

8. Solaris

rbac and execution attributes (uid and euid)

Hi all, I have a question to see if I understand the euid and uid attributes correctly for rbac (/etc/security/exec_attr): All: * Audit Control: /etc/init.d/audit euid=0, egid=3 /etc/security/bsmconv uid=0 /etc/security/bsmunconv uid=0 /usr/sbin/audit euid=0 /usr/sbin/auditconfig... (6 Replies)
Discussion started by: deadeyes
6 Replies

9. AIX

AIX How to run a Shell Script by changing the User

Hi All, Currently our application is running on the server having AIX 5.3 OS. What we intend to do is to run a shell script owned by another user and needs to be run as that particular user. I was trying to create a shell script using the su command before running the actual script (which... (4 Replies)
Discussion started by: acoomer
4 Replies

10. Shell Programming and Scripting

User id who is changing the script.

can we know the user id who changed saved script in cron tab..:D (7 Replies)
Discussion started by: netdbaind
7 Replies
SETREUID(2)						      BSD System Calls Manual						       SETREUID(2)

NAME
setreuid -- set real and effective user ID's LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int setreuid(uid_t ruid, uid_t euid); DESCRIPTION
The real and effective user IDs of the current process are set according to the arguments. If ruid or euid is -1, the current uid is filled in by the system. Unprivileged users may change the real user ID to the effective user ID and vice-versa; only the super-user may make other changes. If the real user ID is changed (i.e. ruid is not -1) or the effective user ID is changed to something other than the real user ID, then the saved user ID will be set to the effective user ID. The setreuid() system call has been used to swap the real and effective user IDs in set-user-ID programs to temporarily relinquish the set- user-ID value. This purpose is now better served by the use of the seteuid(2) system call. When setting the real and effective user IDs to the same value, the standard setuid() system call is preferred. RETURN VALUES
The setreuid() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indi- cate the error. ERRORS
[EPERM] The current process is not the super-user and a change other than changing the effective user-id to the real user-id was specified. SEE ALSO
getuid(2), issetugid(2), seteuid(2), setuid(2) HISTORY
The setreuid() system call appeared in 4.2BSD. BSD
February 8, 2001 BSD
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy