setuid | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

setuid

UNIX for Advanced & Expert Users


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-15-2002
sanjay92
Guest
 
Posts: n/a
Question setuid

I have a C wrapper programme which basically execute a shell script. The shell script has 700 as permission and oracle is owner of the shell script.
The C execuatble has 4711 permission so that means that it has setuid bit set and group and others can execute the C executable.
The reason why I am doing is, I don't want to give read access to my shell script to others and group and owner will have rw access to the script file.

When I execute my C execuatble as different user, it works great but I want some enhancement. When my script is being executed, it is executed as oracle user so every line in the script is executed as oracle user but there are certain things which I want to run as the real user not the effective user. e.g. my shell script calls sqlplus , so when sqlplus is being run , it is run under oracle user but what I want is , it should run under the name of real user.
Is there any easy way to do this ?

Thanks
Sanjay
Sponsored Links
    #2  
Old 04-15-2002
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 30 September 2014, 1:20 PM EDT
Location: Asia pacific region
Posts: 13,023
Thanks: 522
Thanked 875 Times in 402 Posts
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.

Sponsored Links
    #3  
Old 04-15-2002
sanjay92
Guest
 
Posts: n/a
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 07:22 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Please explain setuid bit clearly! all4cfa Linux 6 02-24-2012 05:51 PM
setuid & sticky bit kkalyan UNIX for Dummies Questions & Answers 3 11-30-2011 02:58 PM
Need help with setuid. rama krishna Solaris 6 10-04-2011 05:36 AM
setuid Prem UNIX for Dummies Questions & Answers 1 02-16-2007 06:19 PM
Using setuid and setgid crispy UNIX for Dummies Questions & Answers 1 04-16-2005 07:58 AM



All times are GMT -4. The time now is 01:53 PM.