Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-26-2005, 08:55 PM
|
#1
|
|
LQ Newbie
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16
Rep:
|
how to change user in bash script
Hi guys,can you help me with my problem? I have a script that is supposed to run as a different user. My problem is when I include su - user in my bash script,it always asks the password of the user which should not be the case because the script would be interrupted. Im running my script on a Solaris based server. Thanks in advance.
|
|
|
|
07-26-2005, 10:33 PM
|
#2
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
Well, the ideal mechanism would be to use the sudo package for this.
|
|
|
|
07-27-2005, 12:57 AM
|
#3
|
|
LQ Newbie
Registered: Nov 2004
Location: Philippines
Distribution: Red Hat Advanced Server
Posts: 16
Original Poster
Rep:
|
Ok Matir,I'll try your suggestion. Thanks.
|
|
|
|
07-27-2005, 01:27 AM
|
#4
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
"su - user" is not prompting for a password if you run the script as root.
|
|
|
|
07-27-2005, 08:46 AM
|
#5
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
I believe his intent is to go user1 -> user2, neither user being root. But I could be wrong.
|
|
|
|
07-27-2005, 11:22 AM
|
#6
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
Sure, he certainly goes as you believe, as he got the prompt, I was just suggesting a different way.
As the script is looking like being non interactive, it would perhaps be easy to have it primarily run as root and switching to users on demand.
On the other hand, running scripts as root induce a security risk, so sudo (or Solaris RBAC) are probably a better option.
|
|
|
|
07-27-2005, 11:34 AM
|
#7
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
My biggest worry (as you say) with running scripts as root is a security risk. They are PARTICULARLY prone to symlink attacks. (i.e., putting values into /tmp/scriptname.tmp or some similar predictable file)
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:46 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|