- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: run script as root
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
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
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
тАО08-20-2001 12:10 PM
тАО08-20-2001 12:10 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:28 PM
тАО08-20-2001 12:28 PM
Re: run script as root
If it is acceptable to your users, I would set up a cron job by root that would run your script at certain times on a regular basis.
Regards ... Mladen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:29 PM
тАО08-20-2001 12:29 PM
Re: run script as root
you can use "sudo". You can set it up such that regular users can run scripts/commands as other users/root without having suid/sgid scripts and also it logs all the commands run.
You can download the source from
ftp://ftp.courtesan.com/pub/sudo
or download sudo in swinstall format from
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.2b1/
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:32 PM
тАО08-20-2001 12:32 PM
Re: run script as root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:33 PM
тАО08-20-2001 12:33 PM
Re: run script as root
chmod u+s has NO effect on shell scripts !!
so, other options:
- write a little C-program to do your stuff (possibly by only using host commands) and "chmod u+s" the executable file.
- use sudo
- launch the script from root's crontab every n minutes
- ...
good luck,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 12:33 PM
тАО08-20-2001 12:33 PM
Re: run script as root
Try setting SUID bit on the script to be run as root or other user id.
-rws-r-xr-x 1 root users 18667 Aug 26 2000 check-lg-space.ksh
Everybody will be able to run above script as root.
-rws-r-xr-- 1 dmcapp1 users 18667 Aug 26 2000 start-dm-app.ksh
Members of users group will be able to run above script as user dmcapp1.
Prashant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 06:47 PM
тАО08-20-2001 06:47 PM
Re: run script as root
main ()
{
system ("your_script_name");
}
Compile and give suid to the executable.
SUID on script won't work.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2001 11:02 PM
тАО08-20-2001 11:02 PM
Re: run script as root
however you can actually execute "chmod +s" on any file, and see its result with ll : "rws------" : a shell script will NOT be influenced by the set owner bit, it will still be executed by the executing user, not by the owner of the file. I agree with Sridhar on this.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2001 06:43 AM
тАО08-21-2001 06:43 AM
Re: run script as root
As others have said, suid on a script doesn't work (though I seen different results on different flavors of UNIX). I've included a C program you can modify to call a script and run it as root. The executable will need to be suid but the script itself could have 0 perms.
Also, notice I use setuid(0) within the program. That's because I've had some programs called from a script that didn't work without it even though the suid bit was on the executable.
Though I don't use this anymore, here's how I set it up:
Assuming mis group needs to run "script"
/var/adm/local 550 root:mis
/var/adm/local/src 000 root:sys
/var/adm/local/src/runner.c 000 root:sys
/var/adm/local/bin 010 root:mis
/var/adm/local/bin/runner 4010 root:mis
/var/adm/local/scripts 000 root:sys
/var/adm/local/scripts/script 000 root:sys
As always, use at your own risk.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2001 07:17 AM
тАО08-21-2001 07:17 AM
Re: run script as root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2001 03:57 PM
тАО08-21-2001 03:57 PM
Re: run script as root
well, SUID really *does* work on Scripts, BUT you have
to write your scripts in a slighty different way (you
should do all your scripts that way):
- the first line MUST contain the interpreter-path, e.g.:
#!/bin/sh
- the next lines should set the $PATH to *trusted* dirs
only, or you call all commands with absolute paths
- the script should NOT have read-permissions for the
group NOR for the world, but only for the owner
- the script MUST have read and execute and SUID
permission for the owner, but ONLY execute permission
for group and world
HTH,
Wodisch