Skip to content

sudo doesn't work when "-u" flag is assigned #962

Closed

Description

@kjelly
  • A brief description

sudo command doesn't when '-u' flag is assigned.
For example, sudo -u user ls

  • Expected results

The command should be run

  • Actual results (with terminal output if applicable)

sudo: setresuid() [1000, 1000, 1000] -> [-1, 0, -1]: Operation not permitted

  • Your Windows build number

windows 10 1607 x64

  • Steps / commands required to reproduce the error

    sudo -u user ls

  • Strace of the failing command

execve("/usr/bin/sudo", ["sudo", "-u", "user", "ls"], [/* 16 vars */]) = -1 EPERM (Operation not permitted)
write(2, "strace: exec: Operation not perm"..., 38strace: exec: Operation not permitted
) = 38
exit_group(1)                           = ?
+++ exited with 1 +++
  • Required packages and commands to install

None

See our contributing instructions for assistance.

Activity

  1. changed the title [-]sudo doesn't work in some case[/-] [+]sudo doesn't work when "-u" flag is assigned[/+] on Aug 22, 2016
  2. russalex commented on Nov 16, 2016

    @russalex
    Contributor

    This should be resolved in the Insider build. Looks like it was closed out with some of our other fixes.

    Marking as fixed for insiders.

  3. russalex commented on Dec 5, 2016

    @russalex
    Contributor

    Marked as fixed for some time. Closing it out.

  4. kjelly commented on Dec 10, 2016

    @kjelly
    Author

    Which version is the bug fixed?
    I try Windows 10 Insider Preview 14986 (rs_prerelease).
    The bug still exist.
    But the error message changed.
    The new error message looks like

    $ sudo -u user ls
    sudo: unable to resolve host DESKTOP-K82BHUJ
    sudo: setresuid() [1000, 1000, 1000] -> [-1, 0, -1]: Operation not permitted
    sudo: unable to set runas group vector: Operation not permitted
    sudo: PERM_ROOT: setresuid(0, -1, 0): Operation not permitted
    user is not in the sudoers file.  This incident will be reported.
    
  5. GameKyuubi commented on Apr 1, 2017

    @GameKyuubi

    This is NOT fixed. On build 15063 sudo -u user ls returns

    sudo: setresuid() [1000, 1000, 1000] -> [-1, 0, -1]: Operation not permitted
    sudo: unable to set runas group vector: Operation not permitted
    sudo: PERM_ROOT: setresuid(0, -1, 0): Operation not permitted
    user is not in the sudoers file.  This incident will be reported.
    

    This prevents some scripts from running, impeding dev work.

  6. benhillis commented on Apr 1, 2017

    @benhillis
    Member

    Reopening because this is still broken.

  7. dingolfsson commented on Apr 13, 2017

    @dingolfsson

    Having the same issue trying to access postgres.

    > $ sudo -u postgres psql

    sudo: setresuid() [1000, 107, 1000] -> [-1, 0, -1]: Operation not permitted

  8. ArsalanDotMe commented on Apr 18, 2017

    @ArsalanDotMe

    any workaround to configure postgres till this gets fixed?

  9. GameKyuubi commented on Apr 18, 2017

    @GameKyuubi

    It sounds stupid but try sudo sudo -u

  10. ArsalanDotMe commented on Apr 18, 2017

    @ArsalanDotMe

    That doesn't seem to work

    $  sudo sudo -u postgres
    [sudo] password for arsalan:
    usage: sudo -h | -K | -k | -V
    usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
    usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
    usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p prompt] [-u user] [VAR=value] [-i|-s] [<command>]
    usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p prompt] [-u user] file ...
    
  11. 1 remaining item

  12. ArsalanDotMe commented on Apr 18, 2017

    @ArsalanDotMe
  13. aseering commented on Apr 19, 2017

    @aseering
    Contributor

    Arsalan Ahmad (@ArsalanDotMe) -- in your previous comment, you want sudo sudo -u postgres psql. (sudo is complaining that you didn't tell it what command to run :-) )

    That said, it's definitely true that getting system services like PostgreSQL working within WSL is still a pain. Fortunately, it sounds like it's being worked on.

  14. benhillis commented on Apr 19, 2017

    @benhillis
    Member

    Adam Seering (@aseering) - you're correct I've filed a bug and will be looking into this.

  15. sunilmut commented on Apr 20, 2017

    @sunilmut
    Member

    Arsalan Ahmad (@ArsalanDotMe) - Thanks for your post and patience with WSL. WSL is still a beta feature and while we have covered some ground in Creators Update, there is still more to go. And, your input here actually helps us getting there meaningfully. So, I wouldn't consider your two hours a complete waste :). Would you be willing to open a new issue for the RoR getsockopt failure (a strace would be super useful, as it will be able to exactly pinpoint the issue here). See our contributing.md for instructions.

    We are trying to get "full" compatibility with Linux and as you can imagine, that's a huge surface area. Hopefully, that explains some of the time that we are taking here to cover the ground.

  16. sebaslogen commented on May 10, 2017

    @sebaslogen

    A workaround that I used is sudo su postgres to change to the postgres user in the console and then run the rest of the commands from there, this works on Insider build 15063

  17. JohnPostlethwait commented on Jun 28, 2017

    @JohnPostlethwait

    Just ran into this myself. Thanks for the workarounds!

    Both sudo sudo -i -u postgres and sudo su postgres solutions were effective workarounds for me.

    That said, I am now hitting issues as seen in #61

  18. benhillis commented on Jul 10, 2017

    @benhillis
    Member

    Thanks to everyone for the help. I got some time to take a look at this and the issue was our driver not correctly setting the "saved-set" UID or GID on set-user-ID and set-group-ID bit binaries. I have a fix for this and it will be available in a Windows Insider build soon.

  19. benhillis commented on Jul 26, 2017

    @benhillis
    Member

    This is fixed in 16251.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions