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

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

Closed
kjelly opened this issue Aug 22, 2016 · 18 comments
Closed

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

kjelly opened this issue Aug 22, 2016 · 18 comments

Comments

@kjelly
Copy link

kjelly commented Aug 22, 2016

  • 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.

@kjelly kjelly changed the title sudo doesn't work in some case sudo doesn't work when "-u" flag is assigned Aug 22, 2016
@russalex russalex added the fixed label Nov 16, 2016
@russalex
Copy link
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.

@russalex
Copy link
Contributor

russalex commented Dec 5, 2016

Marked as fixed for some time. Closing it out.

@russalex russalex closed this as completed Dec 5, 2016
@kjelly
Copy link
Author

kjelly commented Dec 10, 2016

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.

@GameKyuubi
Copy link

GameKyuubi commented Apr 1, 2017

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.

@benhillis
Copy link
Member

Reopening because this is still broken.

@benhillis benhillis reopened this Apr 1, 2017
@dingolfsson
Copy link

dingolfsson commented Apr 13, 2017

Having the same issue trying to access postgres.

> $ sudo -u postgres psql

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

@ArsalanDotMe
Copy link

any workaround to configure postgres till this gets fixed?

@GameKyuubi
Copy link

It sounds stupid but try sudo sudo -u

@ArsalanDotMe
Copy link

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 ...

@dingolfsson
Copy link

A workaround for me was to create the DB in the Windows environment, create the user and access it in Bash.

It ultimately defeats the purpose of using Bash, so obviously, this isn't a solution but while it's bugged, this should work.

@ArsalanDotMe
Copy link

ArsalanDotMe commented Apr 18, 2017 via email

@aseering
Copy link
Contributor

@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.

@benhillis
Copy link
Member

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

@sunilmut
Copy link
Member

@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.

@sebaslogen
Copy link

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

@JohnPostlethwait
Copy link

JohnPostlethwait commented Jun 28, 2017

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

@benhillis
Copy link
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.

@benhillis
Copy link
Member

This is fixed in 16251.

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