LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 07-03-2008, 03:05 AM   #1
lqchangba
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Rep: Reputation: 0
ksh scripting


i used su - abc command in script and i dont want to pass password on the terminal. i want to pass the password from the script only (non interactive) what can i do
 
Old 07-03-2008, 03:17 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Don't use su to do this.

Typically, you run the entire script as in :

su myscript

but that brings security concerns of course. This is the time when the standard question comes up - what are you actually trying to do?
 
Old 07-03-2008, 10:19 AM   #3
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by Mr. C. View Post
Don't use su to do this.

Typically, you run the entire script as in :

su myscript

but that brings security concerns of course. This is the time when the standard question comes up - what are you actually trying to do?
MR. C is right; we need more information if you want help...

But if you want to run a process as a user use su -c

For example to start postgres as the postgres user...
Code:
#!/bin/ksh -fuh
#
su - postgres -c "/usr/local/pgsql/bin/pg_ctl -D /var/pgdata start"
#
#
-C
 
Old 07-04-2008, 06:45 AM   #4
b0redom
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
You're creating a MASSIVE security hole here. If you need root priviledges, why don't you just run the script as root, then you don't need to su at all?
 
Old 07-04-2008, 11:01 AM   #5
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by b0redom View Post
You're creating a MASSIVE security hole here. If you need root priviledges, why don't you just run the script as root, then you don't need to su at all?
What about processes that need to run as a specific user? Like postgres....mysql...?

-C
 
Old 07-04-2008, 12:48 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
System daemons that are started as root, have code built in to reduce their access rights as soon after startup as possible, whenever possible. These programs are scrutinized, and typically follow best-practices for setuid/setgid programs.

There has been several security issues with setuid/setgid Shell scripts. It has been considered a risky practice even to this day; the reason for it is simple. The shell interpreters have not generally focused on being security cautious, and programmers are not aware of all the ways a script can go awry.

Binary setuid/setgid programs (eg. from compiled C source) are inherently more secure than scripts, because the language does not have all the built in wildcarding, and other shell niceties designed for assisting humans. They have a limited, strict set of system calls that can be used, and their actions are entirely designed by the developer to permit only a single, or limited action.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting for KSH sagarbsa Programming 1 10-12-2007 05:37 AM
nautilus scripting - shh-tc.ksh schneidz Programming 1 03-05-2007 11:06 PM
Three ksh scripting questions liguorir Linux - Software 2 10-22-2005 12:40 PM
KSH Scripting case statement..... ']['HeBroken Programming 1 12-10-2004 10:38 AM
some ksh scripting nabil Programming 1 03-03-2002 10:34 PM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration