LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-18-2009, 07:46 PM   #1
ValkaTR
LQ Newbie
 
Registered: May 2009
Posts: 5

Rep: Reputation: 0
Correct way to startup user applications after restart?


Hello everybody. I'm stuck at specific problem and I can't find solution anywhere. Please help me.

I installed Debian on some old Pentium II and some users (without root access) have access to the server. Some installed BNC, other eggdrop and other custom daemons. There is no X11 on server.

The problem is that when I restart the computer (or it restarts it self after power failure), then all daemons which users run will not rerun. Everyone has to login and rerun them manually. This happens very rare, about every 100 days, but it happens.

They could install own initscripts in /etc, but that would require a root access to the system. I, ofcourse, don't want to give everybody root access.

Question: How users may able to make their daemons rerun on startup without giving root access to the server?

Thank you.
 
Old 05-18-2009, 08:06 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
There are a few ways you could do it, but the one that makes the most sense to me would be running them from per-user cron. You could write a script that runs every few minutes to check if the various daemons are up, and starts them if they aren't.

Actually starting them at boot time is going to require integrating with the boot scripts, which would take root-level access to do directly. Alternately you could have a function in your boot scripts that loaded scripts from each /home directory, but that would be exceptionally insecure as a user could put anything they wanted in there and have it run as root.
 
Old 05-19-2009, 06:15 AM   #3
ValkaTR
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Ok, i checked three implementations of cron:
* Vixie cron: it sure would help, but it seems that you need to run "crontab ~/.crontab" from user;
* anacron: only the system administrator can configure anacron tasks;
* fcron: this is too advanced.

And /etc/init.d/cron does'nt load /home/*/.crontab files at startup.

Seems like I need to do some scripting. I think I can, I have same basic skills, but I'm sure that it will be 100% exploitable and also I want to make sure that I'm not reinventing a wheel.
 
Old 05-19-2009, 10:35 AM   #4
al_b
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
Lightbulb

http://www.linuxquestions.org/questi...t-user-323020/

Works like a charm.

Al.
 
Old 05-19-2009, 11:52 AM   #5
ValkaTR
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
That's an interesting solution. But adding new users would be a pain. I will try to make script and post it here later then.
 
Old 05-19-2009, 12:46 PM   #6
ValkaTR
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
So I put this in /etc/rc.local:

Code:
find /home/ -maxdepth 2 -type f -name .startup | sed 's/\/home\/\(\w*\).*/echo -e \"=== \\0033[36mExecuting \\0033[32m\/home\/\1\/.startup\\0033[0m ===" \&\& su \1 -c \"sh \/home\/\1\/.startup\"/' | sh
Now users create ~/.startup file, put their stuff there and on boot these scripts will be ran.

Last edited by ValkaTR; 05-19-2009 at 01:00 PM. Reason: +eyecandy
 
Old 05-19-2009, 02:05 PM   #7
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
You can do that, but again, this means any user could run any command as root.

So they could put a line in there that copied a shell with root permissions into their /home directory, and get a root shell without needing to crack the password. Or they could simply put in a "rm -rf" line to delete everything on the server.

If you are going to go this route, you really need to set it up so that any .startup scripts are run as a different user with minimal permissions, definitely not root.
 
Old 05-19-2009, 02:15 PM   #8
ValkaTR
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Look at this part:
Code:
su \1 -c \"sh \/home\/\1\/.startup\"
\1 - is username, so in the end this is executed:
Code:
su user -c "sh /home/user/.startup"
 
  


Reply

Tags
init, initd, multiuser, startup



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
How to restart X without having to close connected applications 10110111 Linux - Desktop 3 12-12-2008 06:19 AM
Don't want to restart open applications from the tool bar swamprat SUSE / openSUSE 2 10-16-2007 03:18 PM
how does system-config-services know the correct order for service startup ? jtmoon Linux - Software 2 06-17-2006 01:16 AM
Problems getting a startup script starting at the correct time BrianK SUSE / openSUSE 3 11-13-2005 05:15 AM
Correct way to run daemon at startup robbiemorgan Linux - Newbie 8 09-20-2004 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:04 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