How a normal user run a script including root privileaged commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How a normal user run a script including root privileaged commands
# 1  
Old 01-16-2009
Error How a normal user run a script including root privileaged commands

Dear all
Ihave written a script in Hpux9.0, the ecript is working fine if I run it from root command prompt
But when I am running it thru /etc/profile or /user/.profile and login as a normal user, the owner of the process running the script is the normal user & hence cant run a root privileaged command
so pls help how can i run that script, so that a normal user when logs in the script should start in background with root privileages.
Thanks in advance
Nitin M
# 2  
Old 01-16-2009
I just answered this on ITRC, so here's the pasted text:

This can be done with sudo.

Run this command to edit the sudoers file:
visudo

Add something like this (for 'user1' as example):
user1 ALL = NOPASSWD: /path/to/script.sh

Then in the user1 .profile, add this:
sudo /path/to/script.sh &

This will run the command as root in the background. For more information on sudo:

Sudo Main Page
# 3  
Old 01-16-2009
Thanks dear ,
But I am using HPux 9.0 & I dont have the sudo installed & not available on for download also.
# 4  
Old 01-16-2009
You should be able to compile sudo from source on HP-UX 9.0. Check the download section on the sudo home page.
# 5  
Old 01-16-2009
Sudo download with prepared binaries. (no 9.x though)
# 6  
Old 01-16-2009
Get your system administrator to change the ownership of the file to root and then change the file permissions to add the set user-ID bit.

Code:
chown root filename
chmod u+s filename

When you 'ls' the file you'll see an output such as:

Code:
-rwsrwxrw- root    root    filename

I believe that if you then edit the script, you'll lose the s bit, as otherwise there a huge security loophole!

Hope that helps.

Jerry
# 7  
Old 01-16-2009
The safe response is to create a root cron which polls for a user-generated
flag file. On finding the flag file the root cron executes the desired script
and then removes the flag file.

We cannot endorse upgrading the privilege of shell scripts with SUID
techniques in this context.

We are slightly concerned about the motives of this post.

Sudo is irrelevant on HPUX 9.0, but remains a useful tool in modern OS.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Will Chkconfig works for normal user apart from root user

Hi, I am trying to schedule a script that starts on reboot.I came across chkconfig utility to schedule scripts on reboot. Problem here is can i how to use this chkconfig to schedule a script that runs a s normal user. Or if there is any other function to schedule on reboot as normal user... (4 Replies)
Discussion started by: praveena kotapa
4 Replies

2. UNIX for Dummies Questions & Answers

Switching from root to normal user takes me to user's home dir

Whenever i switch from root to another user, by doing su - user, it takes me to home directory of user. This is very annoying as i want to be in same dir to run different commands as root sometimes and sometimes as normal user. How to fix this? (1 Reply)
Discussion started by: syncmaster
1 Replies

3. AIX

List of AIX commands that can be run by ROOT user ONLY

Hello, I am testing sudo and I want to test it. Can anyone please let me know few commands (of course other than shutdown, reboot etc. as I can't reboot the box) on AIX that can be run by ROOT only. Thanks ---------- Post updated at 07:43 PM ---------- Previous update was at 07:38 PM... (5 Replies)
Discussion started by: prvnrk
5 Replies

4. Shell Programming and Scripting

Script to run commands as root user

Hello I have a script which is working fine so far to generate HTML file. Now i am wondering how do i include a syntax where it can change itself to root user and execute a specific commands as root user. Please help, Thanks in advance. -Siddhesh (2 Replies)
Discussion started by: Siddheshk
2 Replies

5. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

6. Solaris

java version mismatch for normal user and root user

:confused: I installed latest version of java ( jre 1.6) on Solaris Machine ......when I run java -version as root, shows the latest version but when I run java -version as normal user, shows the old / previous version What should I do to fix this ...should show the latest version... (3 Replies)
Discussion started by: frintocf
3 Replies

7. UNIX for Dummies Questions & Answers

How to allow access to some commands having root privleges to be run bu non root user

hi i am new to unix and i have abig task. i have to \run particular commands having root privileges from a non root user. i know sudo is one of the way but i need sum other approach kindly help Thanks (5 Replies)
Discussion started by: suryashikha
5 Replies

8. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

9. Shell Programming and Scripting

su root from normal user

Got a cron to run everyday under my user. this cronjob runs a script from my /home/jack/scripts/run.sh clear # # su to root and run a script, return with result # su - # passwd # run /getfile.sh # return with result # the result will copy 2 files from /prod/app/logs/ and... (0 Replies)
Discussion started by: karthikn7974
0 Replies

10. UNIX for Advanced & Expert Users

Other than root user .Normal user is unable to create files

Hi all, I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies
Login or Register to Ask a Question