- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to prevent a file being execute by sh ?
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
Forums
Discussions
Discussions
Discussions
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
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
05-31-2006 03:17 PM
05-31-2006 03:17 PM
I hv a file, how to disable the file being using execute using sh ?
kenneth...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 03:36 PM
05-31-2006 03:36 PM
Re: How to prevent a file being execute by sh ?
Now, the way to prevent this is to make the file executable only by members of a certain group and to then disable the other execute and/or read bits. Another approach is to really restrict the permissions and then only allow execution under the control of sudo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 04:00 PM
05-31-2006 04:00 PM
Re: How to prevent a file being execute by sh ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 07:39 PM
05-31-2006 07:39 PM
Re: How to prevent a file being execute by sh ?
of course you can put a statement
exit 0
at the beginning of this script or flag it
#!/bin/false
but this would make the script useless and to refuses changes back would require restricting access rights - which better fit for simply disallowing execution and reading without having to change the content of the script.
If you really do not want to have a script executed, crypt it or better remove it.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 06:09 AM
06-01-2006 06:09 AM
Re: How to prevent a file being execute by sh ?
The only real method I can think of is to add a LOGNAME and PPID (with according awk checks) check (both should match and someone didn't just change their LOGNAME variable to whatever your script would allow).
Other than simplistic checks like that, which can be bypassed, I'd take the advice of the previous posters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 12:46 PM
06-01-2006 12:46 PM
Re: How to prevent a file being execute by sh ?
#!/usr/bin/ksh
All scripts should have this line. Otherwise, when you run a script without the directive, the current shell (whatever it is) will run the script.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 06:33 PM
06-01-2006 06:33 PM
Re: How to prevent a file being execute by sh ?
shell=`ps -fp $$|tail -1|awk '{print $(NF-1)}'`
if [ "$shell" = "sh" ]
then
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 06:58 PM
06-01-2006 06:58 PM
SolutionJust wondering why do you need this kind of settings. You can use restricted shell rsh , and can use # chmod ugo-x filename to remove the executaion flag.
Cheers,
Raj.