LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-10-2003, 04:10 PM   #1
wampfler
Member
 
Registered: Nov 2003
Location: switzerland
Distribution: Fedora Core 1.0/Gentoo
Posts: 35

Rep: Reputation: 15
boot script execute command as non-root user


boot script are executed as root user (tell me if i am wrong...).
but i would like to start a process from another user for security reasons. how can i do that? i tried to make a "su www" in the script, but then the console hangs....
thx for help!!
 
Old 12-10-2003, 04:19 PM   #2
RolledOat
Member
 
Registered: Feb 2003
Location: San Antonio
Distribution: Suse 9.0 Professional
Posts: 843

Rep: Reputation: 30
Create the script, stick in /usr/bin,
Make sure the last line of the script contains
exit

then add this to /etc/rc.local
su - <userid> -c <scriptname>

root can change to userid transparently, the -c tells it to execute a command, and the exit in the script will exit the su and the rc.local will continue processing or exit itself. When you su'ed, it did, then was simply waiting for something to do.

R.O.
 
Old 12-10-2003, 05:47 PM   #3
wampfler
Member
 
Registered: Nov 2003
Location: switzerland
Distribution: Fedora Core 1.0/Gentoo
Posts: 35

Original Poster
Rep: Reputation: 15
then i have to make two scripts: one to start and one with the content. isnt it possible in just one?
 
Old 12-10-2003, 07:34 PM   #4
RolledOat
Member
 
Registered: Feb 2003
Location: San Antonio
Distribution: Suse 9.0 Professional
Posts: 843

Rep: Reputation: 30
No, you append the command to /etc/rc.local
It is a script that is the last to execute regardless of whether you start at runlevel 3 or 5. So, edit the existing /etc/rc.local and add

su - <userid> -c <scriptname>

To the end of it. The only script you need is <scriptname>

R.O.
 
Old 12-11-2003, 12:13 PM   #5
aqoliveira
Member
 
Registered: Dec 2001
Location: Portugal
Distribution: /Red Hat/Fedora/Solaris
Posts: 622

Rep: Reputation: 30
Howzit

u could place the script under the .bashrc which is found in user home dir. Each user has a .bashrc which exec a certain cmds and settings for that user. could place the script in user home dir and under user home dir edit .bashrc file and add path of script in this file donīt forget to add exec perms to script u created with the right ownership.

chow
 
Old 12-11-2003, 12:30 PM   #6
RolledOat
Member
 
Registered: Feb 2003
Location: San Antonio
Distribution: Suse 9.0 Professional
Posts: 843

Rep: Reputation: 30
agoliveira, that would work, but not at boot, only at login. .bashrc is execute at login, not at boot. I think wampfler wants it to start at boot before login, but if not, then .bashrc is a good place to put it.

R.O.
 
Old 12-11-2003, 01:49 PM   #7
wampfler
Member
 
Registered: Nov 2003
Location: switzerland
Distribution: Fedora Core 1.0/Gentoo
Posts: 35

Original Poster
Rep: Reputation: 15
exactly, i want to start services on a web server, and there is no login with a bash console
 
Old 09-24-2004, 05:56 AM   #8
jwallace
LQ Newbie
 
Registered: Sep 2004
Posts: 1

Rep: Reputation: 0
Pay attention to use su command, it only works if user you specified after it has an enabled shell!
 
  


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
Execute script as user sbassett Fedora 1 04-06-2005 11:30 AM
execute a script as a different user JordanH Linux - Software 3 02-08-2005 03:47 PM
Execute a command as another user mpgram Linux - Newbie 6 06-09-2004 12:45 AM
load script during boot not as user root? ziggie216 Linux - General 1 11-20-2003 12:30 PM
execute command as different user kilobravo Linux - General 2 06-02-2003 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:32 PM.

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