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

Invoking shimmed command with sudo fails #49

Closed
dotboris opened this issue Jan 20, 2019 · 0 comments
Closed

Invoking shimmed command with sudo fails #49

dotboris opened this issue Jan 20, 2019 · 0 comments
Assignees

Comments

@dotboris
Copy link
Owner

Steps to reproduce

You'll need a sacrificial command for this. In my case, I'm going to user ruby.

  1. Define command

    alt def ruby test-sys /usr/bin/ruby
  2. Make sure the shims exist

    alt shim
  3. Run your command as root

    sudo ruby --version

alt will call itself in a loop complaining that it's not configured properly.

Why is this happening?

  1. sudo invokes alt (through a shim)
  2. It passes your user's PATH env var (including your user's shim dir $HOME/.local/alt/shims)
  3. alt tries to find the system version of the command (presuming that alt is not configured for the user you're sudoing into)
  4. alt finds your original user's shim dir ($HOME/.local/alt/shims/ruby) (it didn't filter it out because it thinks the shims dir is the one for the user you sudoed into ex: /root/.local/alt/shims)
  5. alt invokes its own shim
  6. goto 1

Deeper problem

alt can invoke itself in a loop. Seems like it's pretty bad at detecting when it's calling itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant