Skip to content

Fish Running as Root Fails to Suggest All Executable Commands in PATH #9699

@timkite

Description

@timkite

In fish 3.6.1 as well as 3.3.1 at least, when running as root, commands (scripts or binaries) that are in $PATH, not owned by user root and/or group root, and are not world-executable will not be offered as completions, even though they are executable by root. This appears to affect Enterprise Linux (RHEL, CentOS, and Oracle Linux) 7 and 8, but does not affect macOS (any version). This happens whether ssh-ing to the Linux system via Apple Terminal or connecting directly to the machine's console. Running without third-party customizations does not affect the behavior.

How to reproduce:

  1. Ensure your user account on the Linux system can sudo to root and that /usr/local/bin is in your $PATH
  2. Create /usr/local/bin/testprog, using sudo if needed, containing something that could execute. An example:
#!/usr/bin/env fish
echo "Hello World"
  1. Set the owner and group of testprog to something OTHER than root:root. For full effect, make sure your user account is either the owner or belongs to the group.
  2. Set the permissions of testprog to 0550, 0750, or 0770
  3. Attempt to auto-complete or tab-complete the command testprog (without typing it fully) and notice that fish will happily
  4. Change to a root session running fish and ensure that /usr/local/bin is in your path as root
  5. Attempt to auto-complete or tab-complete the command testprog (without typing it fully) and notice that fish will not
  6. Run the command testprog (notice that fish will color the command as valid once it's typed fully)
  7. Attempt to auto-complete or tab-complete the command testprog (without typing it fully) and notice that fish will now suggest it, since it's in your command history, but will not tab-complete it.
  8. Switch to a root shell running bash
  9. Attempt to tab-complete the command testprog (without typing it fully) and notice that bash will happily
  10. Do any one of the following: change the owner of testprog to root, change the group of testprog to root, or set testprog's permissions to 0555, 0750, 0775, or 0777
  11. Switching back to a fish root prompt, try tab-completing testprog again. Note that fish will happily tab-complete it now.

What should happen:

  • If a command is executable at all, it's executable by root, and should be offered as a completion

What does happen:

  • Fish only seems to offer commands for completion when the following are true: it is executable by anyone OR it is executable specifically by you OR it is executable by a group you belong to OR it's in your command history

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions