- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Howto properly setuid to a shell script?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2010 02:32 PM
тАО09-27-2010 02:32 PM
Howto properly setuid to a shell script?
I just found this forum via google while searching for how to convert shell scripts to binary, but it looks more than that ;)
I've read a post here in forums , someone said theres a good way how to setuid scripts instead of converting it to binary.
I've just made a script on automating check/restart for a service called cccam, and I setuid to it, and it works well.I also attached it if you want to take a look at it.
But if there's a better way , please share :).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2010 12:21 AM
тАО09-28-2010 12:21 AM
Re: Howto properly setuid to a shell script?
There are many ways to do this; one of the simplest is to manipulate PATH or other environment variables, so that the script will run the user's malicious commands/scripts instead of the standard system commands.
Another common way would be to specify unexpected characters in script arguments or other input, but since your script takes no input from the user and uses no command line arguments, your script should be immune to that at least.
If you need to run a script as a different user, a better way is to use the "sudo" command: it will enforce a standard set of environment variables and strip away the rest, so it will be much harder to fool the script.
But I have to ask: what exactly are you trying to achieve with converting shell scripts to binary and/or with setuid scripts? What is the actual requirement you're trying to fulfill with these methods?
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2010 06:35 AM
тАО09-29-2010 06:35 AM
Re: Howto properly setuid to a shell script?
How I realized this is, I've added it to the rc.local , and while the machine was running I used : setuid script.sh .
My first try was with nohup script.sh & , but this didnt work very well for me , as the scripts generates some logs based on the service status, and nohup forces the logs to go to nohup.out.Even if I specify nohup script.sh somelogs.txt & , it still doesn't meet my requirements, because the script generates the logs on different files based on the service status.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2010 04:11 PM
тАО10-02-2010 04:11 PM
Re: Howto properly setuid to a shell script?
nohup will only redirect stdout and stderr if not already redirected. You also can have the script write directly to a log file.
>kill `pidof cccam` 2&>1 /dev/null
Is this valid bash? In a real shell you use:
kill `pidof cccam` > /dev/null 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2010 11:10 PM
тАО10-03-2010 11:10 PM
Re: Howto properly setuid to a shell script?
I did redirect the logs by this:
echo "`date +%D-%T` Check: Failed ..restarting" >> $log
If I use nohup, all will go to nohup.out instead of the log file I specified.
$log is declared at the beginning of the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2010 10:26 AM
тАО10-06-2010 10:26 AM
Re: Howto properly setuid to a shell script?
Now, I must ask you to replace everything that is setuid with setsid.Now that I cleared that up, I hope the moderators can edit my Subject of this thread too.
Thanks, and sorry for the confusion.