Brian Utterback wrote:
> I have a daemon (ntpd) that uses the libopts open source library
> for option processing. One feature of the library is that all command
> line options can be set using environment variables. For instance,
> by setting an environment variable NTPD_PANICGATE, I get
> the same effect as giving the command line flag --panicgate.
> 
> I set the above variable in the manifest and that works great.
> However, I have a few such flags that I would like to document
> that I do not want to default to having them set. An example
> is the environment variable NTPD_SLEW. However, try as
> I might, I am unable to get this environment variable set in
> the environment for the daemon when it starts.
> 
> I tried using various combinations of svccfg, to the point
> that I get this:
> 
> svccfg -s svc:/network/ntp4 listprop | grep environment
> start/environment             astring  "NTPD_PANICGATE=1" "NTPD_SLEW=1"
> 
> But after I enable the service, I do this:
> 
> pargs -e `pgrep ntpd`
> 
> 2576:   /usr/lib/inet/ntpd
> envp[0]: NTPD_PANICGATE=1
> envp[1]: PATH=/usr/sbin:/usr/bin
> envp[2]: SMF_FMRI=svc:/network/ntp4:default
> envp[3]: SMF_METHOD=start
> envp[4]: SMF_RESTARTER=svc:/system/svc/restarter:default
> envp[5]: SMF_ZONENAME=global
> envp[6]: TZ=US/Eastern
> 
> See? PANICGATE is there but nothing for SLEW. What am I doing wrong?
> Does the environment variable have to be predefined in the manifest? If so,
> how do I define it but not have it set?
> 

I just did this:

# svccfg -s ntp
svc:/network/ntp> setenv -m start FOO x
svc:/network/ntp> setenv -m start BAR y
# svcadm refresh ntp; svcadm restart ntp
# pargs -e `pgrep ntp`
4455:   /usr/lib/inet/xntpd
envp[0]: BAR=y
envp[1]: FOO=x
envp[2]: PATH=/usr/sbin:/usr/bin
envp[3]: SMF_FMRI=svc:/network/ntp:default
envp[4]: SMF_METHOD=start
envp[5]: SMF_RESTARTER=svc:/system/svc/restarter:default
envp[6]: SMF_ZONENAME=global
envp[7]: TZ=US/Pacific

You don't need to pre-define environment variables in the manifest. 
Sure you refreshed the service?

liane

Reply via email to