rc.d and environment variables

Polytropon freebsd at edvax.de
Thu Dec 23 19:54:58 UTC 2010


On Thu, 23 Dec 2010 14:14:43 -0500, Jerry McAllister <jerrymc at msu.edu> wrote:
> On Thu, Dec 23, 2010 at 08:12:49PM +0100, Polytropon wrote:
> 
> > On Thu, 23 Dec 2010 23:27:52 +0600, Victor Sudakov <vas at mpeks.tomsk.su> wrote:
> > > Colleagues,
> > > 
> > > The svnserve daemon is started from /usr/local/etc/rc.d/svnserve. I need to
> > > pass the environment variable KRB5_KTNAME=/home/svn/svn.keytab to the
> > > daemon on start. How do I do that?
> > 
> > If the user corresponding to the svnservice has a login
> > shell, which would usually be the system's default
> > dialog shell, the C shell, you could edit /etc/csh.cshrc
> > and put
> > 
> > 	setenv KRB5_KTNAME /home/svn/svn.keytab
> > 
> > to make it a system-wide setting (or use the user's
> > ~/.cshrc for a user-only setting).
> > 
> > In case the user does NOT have a default shell, I think
> > you should be able to also define a system-wide environmental
> > variable by coding
> > 
> > 	KRB5_KTNAME=/home/svn/svn.keytab; export KRB5_KTNAME
> > 
> > into /etc/rc.local (which will be executed at system startup).
> > See "man rc.local" for details.
> > 
> 
> Put it in /etc/rc.conf and have your script read up rc.conf and
> set any of the stuff in there it is interested in, such as KRB5_KINAME.
> 
> I think that is the officially sanctioned way of doing such things.

I'm not sure this will work. The initial question was about
how to obtain an environmental variable. If the rc.d script
of svnserve sources /etc/rc.conf and/or /etc/rc.conf.local,
it is okay, but what if a binary wants to read the variable
by the standard way, i. e.

	int main(int argc, char *argv[], char *envp[])

then there will be no access to files like /etc/rc.conf.
This means the variable will have to be a validly set
environmental variable that can be output by

	% env

or a similar program (or mechanism). Settings from /etc/rc.conf
do NOT show up as environmental variables.

Anyway, if svnserve is able to be passed a command string
to, a setting like

	svnserve_flags="... -k /home/svn/svn.keytab ..."

coded in /etc/rc.conf or /etc/rc.conf.local would work,
and would also be the preferred method for such things.
In fact, I've not come across the need to have an environmental
variable to store a configuration setting for an additional
program, as such kind of variables is mainly for "low level"
system use, mostly.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list