The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
switching user from root to ordinary user sasia Shell Programming and Scripting 3 01-25-2008 07:25 PM
How to hide user inputted text for interactive unix shell script? patrickpang Shell Programming and Scripting 1 04-04-2006 05:42 PM
SFTP- Non-interactive user authentication dheeruchakri Shell Programming and Scripting 1 03-10-2006 09:14 AM
switch user inside a script nimo Shell Programming and Scripting 2 11-04-2005 04:51 AM
Other than root user .Normal user is unable to create files mallesh UNIX for Advanced & Expert Users 1 06-22-2005 09:18 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-19-2007
Registered User
 

Join Date: Aug 2005
Posts: 111
Non-interactive user switch to root

Is is possible switch user from a non-root user to root user without entering the password interactively inside a korn shell script which is run by a non-root user?

e.g. I have a non-root user called infodba who is in dba group and I want to create a shell script which is executed by infodba user and inside the script I want to switch to root user without getting prompted for the password and run chmod 777 command against a directory then switch back to infodba and create a file inside the directory. I like to perform the below in one script run by infodba without getting prompted for password.

(1) TEST_DIR exists with the access below
ls -ld TEST_DIR
drwxrwxr-x 2 root sys 80 Nov 20 10:45 TEST_DIR

(2) Give full access to TEST_DIR by root
chmod 777 TEST_DIR
ls -ld TEST_DIR
drwxrwxrwx 2 root sys 80 Nov 20 10:46 TEST_DIR

(3) Create a file inside TEST_DIR using infodba
touch TEST_DIR/test.txt

Cheers
Steve

Unix version : HP-UX 11.11
Reply With Quote
Forum Sponsor
  #2  
Old 11-19-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
sudo looks like the tool for you (or RBAC if HPUX supports it).

BTW, I would suggest that you don't set world permisions If you absolutely must give world permissions (and there's hardly ever a good time to do this), the sticky bit to protect the files within it.
Reply With Quote
  #3  
Old 11-19-2007
Read Only
 

Join Date: Jul 2007
Posts: 15
I agree that you need sudo. This way you don't need to switch user, you can give that user permissions to run xxx program with yz switches. The command then turns into

sudo chmod 777 /some/directory

This prevents that user from running it with any other perms and allows you to keep the root password sacred.

Here it is from the software porting place:
sudo-1.6.8p12

You'll need to edit the config file.

Enjoy!
Reply With Quote
  #4  
Old 11-20-2007
Registered User
 

Join Date: Aug 2005
Posts: 111
Smiling Dragon,
Thanks for your advice.

Is there a way to do this only using standard HP-UX commands without using any tools?

Steve
Reply With Quote
  #5  
Old 11-20-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Sorry, I'm not familiar enough with HPUX to know, sudo is widely used though (and is included with some unix distributions) , you don't need to fear that it's too wierd or unsupported for use in an enterprise environment.
Reply With Quote
  #6  
Old 11-20-2007
Read Only
 

Join Date: Nov 2007
Posts: 165
You can download Sudo from HP rather than going outside. It's in the HP-UX Internet Express for HP-UX 11i v1 product, available off Hewlett-Packard Co..
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0