[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A little daemon



It's a bad idea :)

No, really - what do you need to do that can't be done by sudo, cron, or
at?  These are well-tested tools and will probably make you happier than
your plan.

However, if you insist on doing it your way, yes, a perl script that runs
as root, listens on a socket, and runs the commands piped to it and
returns the results would be easy to write.  One caution: perl (like most
processes) doesn't release memory back to the OS, so it's a good idea to
make the loop something like:

for my $i (1..1000) {
	# wait for connect
	# do stuff
	# return result
}

exec "$FindBin::Bin/$0";

so the script renews itself every 1000 connections or so.

Let me reiterate, though: it's a BAD IDEA. How will you make sure nobody
has access to running root scripts through your daemon?

ap

----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu


On Thu, 17 Oct 2002, Raffaele Sandrini wrote:

> Hi 
>  
> I need to have a little daemon wich runs as root and receaves commands wich
> it executes and then 
> sends back the reult code of the commands. It should be very simple - no
> fancy stuff. 
>  
> I firstly thought about a little perl script sich listens to a Socket... Is
> this a good idea (please 
> don't tell me that its not a good idea to run such things as root but i need
> it and i wont be a 
> security risk :-)) )? I never did such things in perl... Can you give me
> some hints? e.g how do i 
> detach wich a perl script from the console. What is the best communication
> method to use? 
>  
> cheers, 
> Raffaele 
> 
> -- 
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 



Reply to: