Skip to content

You are not allowed to run sudo #95

Open

Description

@chuacw

Sudo for Windows version

1.0.0

Windows build number

10.0.20348.2582

Other Software

No response

Steps to reproduce

On Windows Server 2022, in an Administrator cmd.exe window,

sudo c:\windows\system32\cmd.exe

image

Expected Behavior

Expect cmd to run

Actual Behavior

Got "You are not allowed to run sudo" instead.

Activity

  1. added
    Issue-BugSomething isn't working
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Jul 28, 2024
  2. zadjii-msft commented on Jul 31, 2024

    @zadjii-msft
    Member

    That error message is specific to when the user is not a member of the admins group:

    sudo/sudo/src/helpers.rs

    Lines 181 to 185 in 5fd6a79

    pub fn can_current_user_elevate() -> Result<bool> {
    let current_token = current_process_token()?;
    let elevation_type: TOKEN_ELEVATION_TYPE = get_token_info(*current_token)?;
    Ok(elevation_type == TokenElevationTypeFull || elevation_type == TokenElevationTypeLimited)
    }

    sudo/sudo/src/main.rs

    Lines 343 to 347 in 5fd6a79

    if !can_current_user_elevate()? {
    // Bail out with an error. main(0) will then print the error message to
    // the user to let them know they aren't allowed to run sudo.
    return Err(ERROR_REQUEST_REFUSED.into());
    }

    sudo/sudo/src/main.rs

    Lines 311 to 313 in 5fd6a79

    _ if hr == HRESULT::from_win32(ERROR_REQUEST_REFUSED.0) => {
    eprintln!("{}", r::IDS_SUDO_DISALLOWED.get());
    }

    Are you either:

    • running with over-the-shoulder elevation (where your local user account isn't an admin, and you're running cmd as another admin user)?
    • Running with UAC entirely disabled?
  3. chuacw commented on Aug 1, 2024

    @chuacw
    Author

    As mentioned, this was the "Administrator" account, and it's a member of Administrators.
    UAC is totally disabled, set at "Never notify"

  4. added
    Needs-AttentionThe core contributors need to come back around and look at this ASAP.
    and removed
    Needs-Author-FeedbackThe original author of the issue/PR needs to come back and respond to something
    on Aug 1, 2024
  5. zadjii-msft commented on Aug 1, 2024

    @zadjii-msft
    Member

    UAC is totally disabled, set at "Never notify"

    I'm betting that's what it is. I'd guess what's happening here is the same thing Terminal had to deal with - there's a difference between running elevated with a split token, vs the "UAC entirely disabled" scenario. Heck, right above that, there's even:

    sudo/sudo/src/helpers.rs

    Lines 116 to 124 in 5fd6a79

    pub fn is_running_elevated() -> Result<bool> {
    // TODO!
    // Do the thing Terminal does to see if UAC is entirely disabled:
    // Which is basically (from Utils::CanUwpDragDrop)
    // const auto elevationType = wil::get_token_information<TOKEN_ELEVATION_TYPE>(processToken.get());
    // const auto elevationState = wil::get_token_information<TOKEN_ELEVATION>(processToken.get());
    // if (elevationType == TokenElevationTypeDefault && elevationState.TokenIsElevated)
    //

    Looks like that check doesn't happen till after the can_current_user_elevate one. That should be easy enough for someone to rearrange the ordering of.

  6. added
    Help WantedContributions welcome here!
    and removed
    Needs-AttentionThe core contributors need to come back around and look at this ASAP.
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Aug 1, 2024
  7. riverar commented on Aug 17, 2024

    @riverar

    Mike Griese (@zadjii-msft) Is this a supported OS target?

  8. zadjii-msft commented on Aug 19, 2024

    @zadjii-msft
    Member

    I dunno if I can comment on the big-picture "is UAC disabled supported". I suppose it should be, at least from the perspective of sudo. Seems like it'd be easy enough for us to just shortcut the "can you elevate" and just do the thing (even tho you don't need sudo at all at that point)

  9. riverar commented on Aug 19, 2024

    @riverar

    Mike Griese (@zadjii-msft) Was referring to sudo running on Windows Server 2022. I thought sudo was only targeting newer versions.

  10. zadjii-msft commented on Aug 20, 2024

    @zadjii-msft
    Member

    Oh yea I don't see why not. Sudo might be "targeting" newer versions, but it should work all the way back to, like, windows 7:

    All it really needs is ConDrv, and that's been there for a loooong time now. Only reason we haven't backported it to win10 yet is because backporting takes a lot of paperwork to fill out 🤷

  11. riverar commented on Aug 20, 2024

    @riverar

    Cool thanks! I was looking to pitch in a fix here but wanted to verify running in this config was supported before I spun my wheels.

  12. CberYellowstone commented on Dec 12, 2024

    @CberYellowstone

    Is there any progress on this issue?

  13. trueuto commented on Dec 17, 2024

    @trueuto
  14. riverar commented on Dec 17, 2024

    @riverar

    That discussion was had in #23 and is unrelated to this issue.

  15. kndxhz commented on Jun 2, 2025

    @kndxhz

    I encountered the same situation:
    I used the administrator account created when installing Windows to open PowerShell (even if it was an administrator's PowerShell)
    Still prompting that you are not allowed to run sudo

  16. gabsoftware commented on Apr 20, 2026

    @gabsoftware

    Really, what's the point of running sudo if your user must be in the local admins group?
    In most environments there is an unprivileged user and running elevated commands necessitate an admin account.
    This is what we have in my case. Unprivileged Azure AD user, and a admin Azure AD user.
    Typing sudo from unprivileged user should show UAC prompt. It doesn't. It just shows "You are not allowed to run sudo". Completely useless in current state!

  17. robang74 commented on Apr 20, 2026

    @robang74

    Typing sudo from unprivileged user should show UAC prompt. It doesn't. It just shows "You are not allowed to run sudo". Completely useless in current state!

    This is the expected behaviour for sudo. If you are not the admin of your own laptop/PC, that's entirely your problem. Instead, for a corporate laptop/PC, you are just an unprivileged user. The advantage of sudo is that an user that has the admin credential can execute commands as admin (or another user, if allowed) without log-out from the current session and log-in as 'admin`. It is also useful for hackers that should not anymore disclose to you that they are moving your mouse but using a ssh text-terminal console in the background. Now, you can be hacked without stopping to work or any distraction... :-D

  18. fxc223 commented on Jun 20, 2026

    @fxc223

    hi i know how to fix this react with a rocket and an eye emoji so i could give it to chall

  19. xmha97 commented on Sep 24, 2026

    @xmha97

    I enabled the built-in Administrator account in Windows and used it to change my main user account from Administrator to Standard User.

    As a result, my main account is no longer a member of the Administrators group and now runs with standard user privileges. Therefore, when I launch an application or perform an operation that requires administrative privileges, User Account Control (UAC) asks for the credentials of an Administrator account instead of simply asking me to approve the elevation.

    This means that my main account is used for everyday tasks with standard user privileges, and the password for the separate Administrator account is only entered when administrative privileges are required.

    In this configuration, running the sudo command from the standard user account is also not permitted, and it displays the message “You are not allowed to run sudo.”

  20. xmha97 commented on Sep 24, 2026

    @xmha97

    I also found gsudo, which provides a sudo-like experience on Windows.

    In this setup, where my main account is a Standard User and administrative credentials are required for elevation, gsudo works correctly and provides the expected behavior.

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

    Help WantedContributions welcome here!Issue-BugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions