Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not a c programmer - need a c wrapper to pass CLI parameters

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
After spending a day on trying to make something I decided I'd ask to see if anyone has already done this and is willing to share.

On Ubuntu I need to execute a bash script as another user (using suid). Therefore I need a c program with SUID set to execute my shell script.
I was able to get one from the examples available but I need to be able to take and pass a half-dozen options and their values.

If anyone has done this before you please be willing to post the code here as a learning example?

Thanks all -
 
Why not just make the bash script setuid?
Code:
$ chown bob:bobsgroup bobscript.sh
$ chmod 6755 bobscript.sh
$ ls bobscript.sh
-rwsr-sr-x   1 bob      bobsgroup     89 Jan 16 10:19 bobscript.sh
Now, anyone that runs that script runs it as "bob" and "bobsgroup".

You can also make a user specific copy of the bash shell that will run as any user.
Code:
$ cp /bin/bash ./bashAsBob
$ chown bob:bobsgroup bashAsBob
$ chmod 6755 bashAsBob
$ bashAsBob anyscript.sh
That way you can run any script as "bob". You can also type "bashAsBob" by itself and be in a shell as the user "bob".

For security reasons, you might want to make sure the setuid scripts and shells are protected and hidden, otherwise you are may be opening up some huge security holes.

 
Anyway, that seems a lot easier to create and maintain than writing a C wrapper.

 
ya. i also tried by above code . it working well :) thanks for the solution

SHRIKANT BADIGER
SJCE MYSORE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top