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

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.

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