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

CLI tools are not included in PATH for non-login shells #551

Open
orasul opened this issue Apr 21, 2020 · 1 comment
Open

CLI tools are not included in PATH for non-login shells #551

orasul opened this issue Apr 21, 2020 · 1 comment

Comments

@orasul
Copy link

orasul commented Apr 21, 2020

Chef: 15.8.23
Cookbook version: 5.8.4
OS: CentOS7.7
RabbitMQ version: 3.7.25
Erlang version: 21.3
How to reproduce:
ssh user@rabbitmq-server sudo /bin/bash -c "chef-client"
ssh user@rabbitmq-server sudo chef-client

We encountered an issue using rabbitmq cookbook in our infrastructure. We deploy application software using our service which is based on remote ssh connection to server and performing sudo chef-client

rabbitmq::users recipe uses rabbitmq_user custom resource which behavior is defined in providers/user.rb. It calls rabbitmqctl executable to check users list, tags, etc.
For some reasons rabbitmqctl is located in /usr/sbin

However default /usr/sbin/sshd which comes from openssh package for CentOS has been compiled with different PATH variables for root and for non-root user:
# strings /usr/sbin/sshd | grep bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
/usr/local/bin:/usr/bin - doesn't have /usr/sbin

We can see that without login (without reading /etc/profile or /etc/bashrc, etc.) non-root user doesn't have /usr/sbin/ in PATH variable. So most of commands from providers/user.rb fail. Debug log level doesn't help to find out the root of the issue because of "sensitive" parameter. So there is zero information about why did that fail from chef output.

We can include /usr/sbin in PATH for user manually. But that's first such case. Lots of community cookbooks work fine without this adjustment.

I propose two different ways to fix it:

  1. changing rabbitmqctl to /usr/sbin/rabbitmqctl
  2. copy or symlink /usr/sbin/rabbitmqctl to /usr/bin/rabbitmqctl

Any reply is kindly appreciated.

@michaelklishin
Copy link
Member

Option 2 would be considered, please submit a PR for this cookbook that introduces a new recipe that does the symlinkin. Then those who need this behavior can add it to their run lists as opposed to it being forced on every cookbook user.

CLI tool location is not a problem we see brought up frequently, and not controlled by this cookbook. So they won't be changed without overwhelming evidence that this would be necessary.

@michaelklishin michaelklishin changed the title rabbitmqctl executable location isn't included in PATH via ssh CLI tools are not included in PATH for non-login shells Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants