Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passenger Depends on Shell $HOME #41

Closed
sean-horn opened this issue Dec 4, 2014 · 6 comments
Closed

Passenger Depends on Shell $HOME #41

sean-horn opened this issue Dec 4, 2014 · 6 comments

Comments

@sean-horn
Copy link
Contributor

Passenger depends on shell $HOME variable being set.

While chef-client is running in daemonized mode, the children spawned by chef-client do not include $HOME as part of the available shell environment.

As a customer, I would like a workaround for this issue chef-boneyard/chef-client#226 to be made in passenger_apache2 if it can be done sooner than in the chef-client cookbook.

@sean-horn
Copy link
Contributor Author

Is there a better workaround than setting this at some point in a recipe before passenger_apache2 runs?

ENV['HOME'] = '/somewhere'

@jtimberman
Copy link
Contributor

What actually uses $HOME? Why does it need to be set? At what point in the run is it using $HOME?

@jtimberman
Copy link
Contributor

There are some locations in the passenger codebase itself that use HOME, which appears for automatic config file location lookups, especially when using RVM.

vagrant@default-ubuntu-1204:/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/passenger-4.0.53$ grep -Rl 'HOME' *
build/packaging.rb
buildout/agents/PassengerLoggingAgent.o
buildout/agents/PassengerHelperAgent
buildout/agents/PassengerHelperAgent.o
buildout/agents/PassengerLoggingAgent
CHANGELOG
dev/ci/run_travis.sh
doc/Users guide Standalone.html
doc/users_guide_snippets/troubleshooting/default.txt
ext/libev/configure
ext/libeio/configure
ext/common/ApplicationPool2/Spawner.h
ext/common/agents/HelperAgent/Main.cpp
ext/common/agents/LoggingAgent/Main.cpp
lib/phusion_passenger.rb
lib/phusion_passenger/platform_info/ruby.rb
lib/phusion_passenger/plugin.rb
lib/phusion_passenger/packaging.rb
packaging/rpm/image/site-defaults.cfg
packaging/rpm/internal/my_init
packaging/rpm/internal/setuser

I don't think this is a cookbook specific issue. If we were to do anything it would be to explicitly set ENV['HOME'] if it's undefined, e.g.,

ENV['HOME'] = Etc.getpwuid(Process.uid).dir unless ENV.has_key?('HOME')

(this is the same thing that passenger itself does in a few places)

However, this feels like it could be problematic. As I said, it's not clear to me why this is an issue with passenger, and it appears to be difficult or inconsistent to reproduce. I think it's potentially a really bad idea to manipulate the shell environment variables in a community cookbook, as that can have unintended side effects.

Similarly, I don't think that munging it in the chef-client cookbook's startup scripts a la issue chef-boneyard/chef-client#226 is a good idea either. Maybe noting that the environment is clean/scrubbed on startup? Maybe I take it for granted that the ENV for init services is scrubbed/clean.

@sean-horn
Copy link
Contributor Author

I think this might be helpful for folks just coming into passenger_apache2 and running it as a service under init: #44
@jtimberman

@cheeseplus
Copy link

Closing this as the workaround provided seems sufficient.

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants