Sponsored Content
Full Discussion: setuid
Top Forums UNIX for Advanced & Expert Users setuid Post 19706 by sanjay92 on Monday 15th of April 2002 06:36:19 PM
Old 04-15-2002
Neo,
Thanks for reply.
Can you please give me example how to do exec process with the UID, you want.

Please see my test case below :-

[IPLAY] $ ls -al a.ksh
-rwx------ 1 oracle dba 46 Apr 15 15:54 a.ksh

Where a.ksh is as follows :-

#!/usr/bin/ksh
# There are more lines of code here that should be executed
# as oracle user.
# but the line below (sqlplus) should be executed as the calling user i.e. real user.
sqlplus system/cub4@idev1


*************************************

This is C Wrapper script.
[IPLAY] $ cat a.c

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**********************************************
This is the wrapper script

***********************************************/

int main(int argc, char *argv[]) {
int i;
i=system("/local1/USERS/oracle/a.ksh");
if ( i == 0 )
return 0;
else
return 1;
}

I have compiled gcc a.c -o a

Now, I have changed permission of a as 4711

So when I will execute a as some other user e.g. sanjay,
the sqlplus session is started but I want to start the sqlplus session as the sanjay user which is the real user, oracle is the effective user in this case.



Thanks


Quote:
Originally posted by Neo
One suggestion is to fork() and perhaps exec() a process with the UID you want. Then have the new process make the system call with the UID you gave it.......

You can't change the UID of a running process..... but you can fork new processes and give UIDs to the new processes.


Last edited by sanjay92; 04-15-2002 at 08:22 PM..
sanjay92
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using setuid and setgid

Hi, I have been looking at setuid and setgid. I understand that setuid determines who owns the file and setgid determines which group of people can access the file... yeah?! But i need to know how to actually use setuid and setgid. I'm guessing chmod will feature somewhere.. Any help... (1 Reply)
Discussion started by: crispy
1 Replies

2. UNIX for Advanced & Expert Users

cc, setuid, and LD_LIBRARY_PATH

Hi, This question deals with Solaris 2.8 and setuid programs. From research I've done so far, setuid programs ignore LD_LIBRARY_PATH; I've proven this and am OK with it. The thing I am not certain of how the C compiler is supposed to behave when it is invoked via a setuid program. Basically,... (0 Replies)
Discussion started by: WolfBoy
0 Replies

3. UNIX for Dummies Questions & Answers

setuid

could u plz give me clear idea of spcial permissions setuid,getuid and striky bit . (1 Reply)
Discussion started by: Prem
1 Replies

4. Solaris

setuid and guid

Hi All, Can someone give me some info about setuid or guid topic? Also about sticky bit. Thanks in advance, itik (9 Replies)
Discussion started by: itik
9 Replies

5. UNIX Desktop Questions & Answers

find setuid files

I would like to list files with setuid and setgid set up. I used the find command, but I got a lot of permission denied error. I tried to redirect the error to the hole it does not work. I used the command string below find . -type f \( -perm -4000 -o -perm -2000 \) -exec ls {} \; 2>/dev/null... (3 Replies)
Discussion started by: Pouchie1
3 Replies

6. AIX

sudo must be setuid root.

Guy's I'm trying to add some lines in sudo by useing this command visudo # User privilege specification root ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL #... (5 Replies)
Discussion started by: ITHelper
5 Replies

7. HP-UX

Disable Setuid in HP-UX

Hi All, How to prevent root user from doing setuid(). In otherwords, if the root(any user) is trying to do setuid in a program it should fail. (5 Replies)
Discussion started by: guru13
5 Replies

8. Solaris

Need help with setuid.

Hi Gurus, I need your suggestions,to implement setuid. Here is the situation. I have a user xyz on a solaris zone.He needs to install a package using a pkgadd command but i guess only a root can run that .Is there any way I can set the setuid bit on the pkgadd which is in the location... (6 Replies)
Discussion started by: rama krishna
6 Replies

9. UNIX for Beginners Questions & Answers

What keeps me from abusing setuid(0) and programs with setuid bit set?

Just learning about the privilege escalation method provided by setuid. Correct me if I am wrong but what it does is change the uid of the current process to whatever uid I set. Right ? So what stops me from writing my own C program and calling setuid(0) within it and gaining root privileges ? ... (2 Replies)
Discussion started by: sreyan32
2 Replies

10. Shell Programming and Scripting

Setuid usage

I'm trying - as an ordinary user - to create a file in the root directory of my system. For that purpose I wrote a simple script that echoes a string into a file. I made the file executable, used sudo to change ownership to root. Like this: $ cat hello #!/bin/bash echo hello > /hello $... (5 Replies)
Discussion started by: Ralph
5 Replies
USER-SESSION-KEYRING(7) 				     Linux Programmer's Manual					   USER-SESSION-KEYRING(7)

NAME
user-session-keyring - per-user default session keyring DESCRIPTION
The user session keyring is a keyring used to anchor keys on behalf of a user. Each UID the kernel deals with has its own user session keyring that is shared by all processes with that UID. The user session keyring has a name (description) of the form _uid_ses.<UID> where <UID> is the user ID of the corresponding user. The user session keyring is associated with the record that the kernel maintains for the UID. It comes into existence upon the first attempt to access either the user session keyring, the user-keyring(7), or the session-keyring(7). The keyring remains pinned in existence so long as there are processes running with that real UID or files opened by those processes remain open. (The keyring can also be pinned indefinitely by linking it into another keyring.) The user session keyring is created on demand when a thread requests it or when a thread asks for its session-keyring(7) and that keyring doesn't exist. In the latter case, a user session keyring will be created and, if the session keyring wasn't to be created, the user ses- sion keyring will be set as the process's actual session keyring. The user session keyring is searched by request_key(2) if the actual session keyring does not exist and is ignored otherwise. A special serial number value, KEY_SPEC_USER_SESSION_KEYRING, is defined that can be used in lieu of the actual serial number of the call- ing process's user session keyring. From the keyctl(1) utility, '@us' can be used instead of a numeric key ID in much the same way. User session keyrings are independent of clone(2), fork(2), vfork(2), execve(2), and _exit(2) excepting that the keyring is destroyed when the UID record is destroyed when the last process pinning it exits. If a user session keyring does not exist when it is accessed, it will be created. Rather than relying on the user session keyring, it is strongly recommended--especially if the process is running as root--that a session- keyring(7) be set explicitly, for example by pam_keyinit(8). NOTES
The user session keyring was added to support situations where a process doesn't have a session keyring, perhaps because it was created via a pathway that didn't involve PAM (e.g., perhaps it was a daemon started by inetd(8)). In such a scenario, the user session keyring acts as a substitute for the session-keyring(7). SEE ALSO
keyctl(1), keyctl(3), keyrings(7), persistent-keyring(7), process-keyring(7), session-keyring(7), thread-keyring(7), user-keyring(7) Linux 2017-03-13 USER-SESSION-KEYRING(7)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy