PATH environment variable is truncated at service scripts does anybody know why?
When I run:
on command line I get PATH environment variable which contains:
but when starting a service from the command line using service command (I put an echo $PATH to the the service script, just after shebang and before any command) like following:
service openvpn onestart
the openvpn service is starting with a truncated list of PATH variable as below:
which is obviously truncated. This is not happening with FreeBSD 11.x.
Can anybody help me why is this happening?
It turns out that
is overriding PATH environment variable before starting/stopping related service.
But I have not found out yet why the same package and service could be started on freebsd without any error but not on pfsense.
I'll make an update for the latter issue.
Security reasons. Any script run like that should never have anything more than the trusted directories in its $PATH and those are by convention /sbin:/bin:/usr/sbin:/usr/bin. This means that when writing scripts the scripts should use full paths to executables located outside the trusted $PATH.