"system" users' environmental variables

Hi everybody.

I've been using FreeBSD for many years now, and since almost the start I had this question, that never bothered me soooo much so as to have to resolve it:

Is there a specific way (conventional I mean) to set environmental variables for daemon-users? If so, how do we know if it is honored by a specific user? The only "trick" I remember having used so far was to edit the daemon's related /usr/local/etc/rc.d/daemon script, and to be honest I think it didn't work :).

Thank you all for your time in advance,

mamalos
 
Could you give a example? Some values can be set through _flags variables in /etc/rc.conf, but that might not be what you are asking.
 
rc.conf is sourced by /etc/rc.subr, you can inject code that exports environment variables for all or a specific rc.d script.

An example for net-p2p/transmission-daemon:
Code:
transmission_enable=YES

# hide tracker requests but not actual p2p traffic behind privoxy+tor
case [highlight]$name[/highlight] in
    transmission) export http_proxy=http://127.0.0.1:8118
    ;;
esac
By the time load_rc_config reads /etc/rc.conf variable $name contains the name of the rc.d script.
 
Thank you both guys,

dandelion I think that your solution is what I need. I will just rephrase it to see that I have understood it correctly: I can write whatever /bin/sh code in /etc/rc.conf and /etc/rc.subr will run it. That's great! Where can I see more info regarding this procedure? The porter's handbook?

thanx again.
 
Back
Top