2

I know I could modify /etc/profile.. but is there a better way? I know /etc/profile will affect terminals but I want all processes to be affected. crontab, service manager, startup scripts, etc..

Edit: I have an answer to edit the PATH for cron.. but still want one for startup scripts and executables that are called by service management.

700 Software
  • 2,233
  • 10
  • 49
  • 77

2 Answers2

2

You have to consider the environment in which some of your applications above are running. There are security implications to running theses types of commands with PATHs that they are not expecting. A malicious user who has access to a directory early in the PATH may be able to substitute their own commands and gain access etc.

Startup scripts generally use full paths to the commands they want to run (some may set a restricted PATH) - this ensures that the expected commands are executed.

When invoking a service, the SCM doesn't use PATHS it uses manifests ( /var/svc/manifest/... ). Manifests are xml files and contain all the information required to define how to interact with a given service. Again, full paths to commands are used to ensure the expected commands are executed.

You can set a default PATH (normal users) or SUPATH (for root) in /etc/default/cron. Again you should consider the security implications of doing so - it is much better to use full paths to commands and have the commands define their own PATH if required.

I believe that the default PATH that init passes to SMF and the init scripts is compiled into the init binary and cannot be changed. It is explicitly not read from /etc/default/init.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • All the directories in all the PATHs will only be editable by root. You have mentioned how to change the path for the cron,, but I still want to change the path for the service executables. I know the path to the executable is absolute.. but I want to control the PATHs that the executables themselves use. I am aware that I should be careful when changing which executable will run for a given command. I will probably add all my new PATHs to the end. – 700 Software Jan 08 '11 at 21:23
0

I Agree with @lain that you really should just use full paths to the commands you want. that said, most smf methods source /lib/svc/share/smf_include.sh. You could change the PATH variable there, but I would say that is generally a bad idea.

cwebber
  • 491
  • 3
  • 7