Re: Creating Daemons: Best Practice?
From: Menno Duursma (menno_at_desktop.lan)
Date: 09/21/04
- Next message: Ian Northeast: "Re: sndmail worth learning?"
- Previous message: Davorin Vlahovic: "Re: I am new to here ^_^"
- In reply to: Herr Fieldmarshall: "Creating Daemons: Best Practice?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 21 Sep 2004 19:11:53 GMT
On Tue, 21 Sep 2004 17:00:34 +0200, Herr Fieldmarshall wrote:
> Hello,
>
> I've created a program that runs as a daemon, but my question now is, what
> is the best practice concerning distributing and installing it.
That depends, "man hier" ie:
If it's a binary blob - a tarball for extraction under /opt .
If it's source - default to /usr/local prefix.
If you plan on providing TGZ/RPM/DEB packages, stick with disro guidelines.
In either case put some INSTALL and README files in the archive, and
create MD5 checksum(s) - and preverably GPG signature too - of that.
> The executable needs access to some config file, and some other data files.
> I assume it's best practice to place the executable in /usr/local/bin and
> all the rest in /usr/local/etc.
Read above, or better yet:
http://www.pathname.com/fhs/
> My question now is, how can I assure that
> the executable will always find the config file? (I don't like hard-coding
> ../etc/configfile.conf).
Parce command-line option, and/or environment variable, before trying any
hardcoded path, ie: getenv() , getopt() - err out on failing all.
> I've also read that it is for security reasons best to use chroot to run the
> deamon,
Yes. However i'd leave it up to the administrator to actually set it up
that way. You'd do good providing the option - and some documentation on
how to go about running it that way though.
Be sure to drop privileges - ie: suid() , setgid() - after doing what
you need root for ie: chroot() , chdir("/") , etc.
And/or have a read through "man capabilities" (which i haven't used, but
read someware "pureftpd" and "named" use that, to drop anything but:
CAP_NET_BIND_SERVICE after start-up.)
> but how do I do this in such a way that my data and config files
> remain accessible?
They have to reside inside the jail, allong with anything else your deamon
needs to properly function ( such as /dev/log , /var/run , or whatever. )
> My last point is how do I get the daemon neatly installed in init.d ? Is
> there some script for it?
I'd just base my script(s) on the ones provided with given distro for
start/stop/restart of other services. Note, on some distros (like
Slackware) they reside in /etc/rc.d/ .
> Briefly said, my question is: I've created a daemon application, but what
> now?
Have a look at how others packaged something like it?
http://freshmeat.net/
-- -Menno.
- Next message: Ian Northeast: "Re: sndmail worth learning?"
- Previous message: Davorin Vlahovic: "Re: I am new to here ^_^"
- In reply to: Herr Fieldmarshall: "Creating Daemons: Best Practice?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|