2

I get the error xonsh: subprocess mode: permission denied: sudo.

  • Can you run sudo successfully when you're not using xonsh? – larsks Aug 12 '15 at 18:47
  • Yes. I also checked that the ownership and rights of my other shells and xonsh match. The only difference is that xonsh is in /usr/local/bin. – Emre Aug 12 '15 at 18:52
6

It's a bug in xonsh. In the build_ins.py module, xonsh attempts to determine if a file is "binary" or not by opening it and reading a few bytes:

  def _is_binary(fname, limit=80):
      with open(fname, 'rb') as f:
          for i in range(limit):
              char = f.read(1)
              if char == b'\0':
                  return True
              if char == b'\n':
                  return False
              if char == b'':
                  return False
      return False

Security sensitive programs like sudo are often executable but not readable, so this blows up.

| improve this answer | |
  • Here is a possible patch for this behavior. – larsks Aug 12 '15 at 19:11
  • Thanks. I don't understand how nobody realized sudo doesn't work. – Emre Aug 12 '15 at 20:48
  • My guess is that not many people are using xonsh. It's not something I had ever heard of until I saw your question. – larsks Aug 12 '15 at 20:49
  • 1
    To be clear, sudo does work even with this bug on many systems (which is why it was missed). Some distributions choose to make sudo unreadable-but-executable. This is not categorically true for all Linux distros. There is a PR into xonsh that fixes this. – Anthony Scopatz Aug 18 '15 at 1:11
  • 1
    The bug has now been fixed in master. Sorry about the problem in the first place. – Anthony Scopatz Aug 18 '15 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.