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
SETRESUID(2)						     Linux Programmer's Manual						      SETRESUID(2)

NAME
setresuid, setresgid - set real, effective and saved user or group ID SYNOPSIS
#define _GNU_SOURCE #include <unistd.h> int setresuid(uid_t ruid, uid_t euid, uid_t suid); int setresgid(gid_t rgid, gid_t egid, gid_t sgid); DESCRIPTION
setresuid() sets the real user ID, the effective user ID, and the saved set-user-ID of the calling process. Unprivileged user processes may change the real UID, effective UID, and saved set-user-ID, each to one of: the current real UID, the cur- rent effective UID or the current saved set-user-ID. Privileged processes (on Linux, those having the CAP_SETUID capability) may set the real UID, effective UID, and saved set-user-ID to arbi- trary values. If one of the arguments equals -1, the corresponding value is not changed. Regardless of what changes are made to the real UID, effective UID, and saved set-user-ID, the file system UID is always set to the same value as the (possibly new) effective UID. Completely analogously, setresgid() sets the real GID, effective GID, and saved set-group-ID of the calling process (and always modifies the file system GID to be the same as the effective GID), with the same restrictions for unprivileged processes. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EAGAIN uid does not match the current UID and this call would bring that user ID over its RLIMIT_NPROC resource limit. EPERM The calling process is not privileged (did not have the CAP_SETUID capability) and tried to change the IDs to values that are not permitted. VERSIONS
These calls are available under Linux since Linux 2.1.44. CONFORMING TO
These calls are nonstandard; they also appear on HP-UX and some of the BSDs. NOTES
Under HP-UX and FreeBSD the prototype is found in <unistd.h>. Under Linux the prototype is provided by glibc since version 2.3.2. SEE ALSO
getresuid(2), getuid(2), setfsgid(2), setfsuid(2), setreuid(2), setuid(2), capabilities(7), credentials(7), feature_test_macros(7) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2007-07-26 SETRESUID(2)
All times are GMT -4. The time now is 08:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy