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

DISM does not work properly when run with sudo #82

Open
Stanzilla opened this issue May 24, 2024 · 15 comments
Open

DISM does not work properly when run with sudo #82

Stanzilla opened this issue May 24, 2024 · 15 comments
Labels
Issue-Bug Something isn't working Tracking-External This bug isn't resolved, but it's following an external workitem.

Comments

@Stanzilla
Copy link

Sudo for Windows version

1.0.0

Windows build number

10.0.26100.0

Other Software

Note that it does work if you don't use sudo and just run DISM in an elevated shell.

Steps to reproduce

sudo dism /Online /Cleanup-Image /RestoreHealth

sudo is set to inline mode

Expected Behavior

DISM works

Actual Behavior

❯ sudo dism /Online /Cleanup-Image /RestoreHealth

Deployment Image Servicing and Management tool
Version: 10.0.26100.1

Error: 31

An error occurred while creating the log file.
Ensure that the path to the log file exists and that you have Read/Write permissions on the folder where the log files will be created.

@Stanzilla Stanzilla added Issue-Bug Something isn't working Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 24, 2024
@zadjii-msft
Copy link
Member

Huh. I can't seem to repro this locally. That's weird. Were you using sudo to run the command as another user/?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 29, 2024
@Stanzilla
Copy link
Author

Stanzilla commented May 29, 2024

Huh. I can't seem to repro this locally. That's weird. Were you using sudo to run the command as another user/?

Nope just as normal.

image

Disclaimer: I used a backported version from Canary on my beta branch OS before, then "updated" to 24H2 via downgrading my Insider membership to Release Preview.

Here is the properties of my sudo.exe

image

(no idea why the signature date is in German, just Windows things)

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels May 29, 2024
@zadjii-msft
Copy link
Member

Well, it's real promising that there's literally no other documentation on why this might happen

image

🤷

Like, absolute dumb sanity check - does dism work from an elevated console window?

did you drop that sudo.exe into system32? or into some other path/?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels May 29, 2024
@Stanzilla
Copy link
Author

Well, it's real promising that there's literally no other documentation on why this might happen

image

🤷

Like, absolute dumb sanity check - does dism work from an elevated console window?

did you drop that sudo.exe into system32? or into some other path/?

Yeah it works from an elevated console window just fine and I did the same google search before filing the issue haha

image
image

Here's what that sudo points to, is that the correct version? I'm pretty sure I just dropped it in there yeah.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels May 29, 2024
@AvogatoWizardWhisker
Copy link

Huh. I can't seem to repro this locally. That's weird. Were you using sudo to run the command as another user/?

Nope just as normal.

image

Disclaimer: I used a backported version from Canary on my beta branch OS before, then "updated" to 24H2 via downgrading my Insider membership to Release Preview.

Here is the properties of my sudo.exe

image

(no idea why the signature date is in German, just Windows things)

About the timestamp, in my case, it uses my local language. Which is English. Do you have other languages installed on your system?

image

@AvogatoWizardWhisker
Copy link

But yeah, I also have one user on my computer, I received the same error code (31). I tested all configuration sudo offers.

@zadjii-msft
Copy link
Member

GandalfThisfoeGIF

I'm gonna reach out to the owners of dism.exe. See if they can't help me track down why this might be.

@zadjii-msft
Copy link
Member

Wait what the heck
image

In a VM: works like a charm
on my real dev box? no dice.

@zadjii-msft
Copy link
Member

Okay we may be onto a lead: on my dev box, sudo cmd, then dism /Online /Cleanup-Image /RestoreHealth from in the CMD that's now running elevated? That works.

@AvogatoWizardWhisker
Copy link

as a workaround, running the command like this sudo pwsh {dism /Online /Cleanup-Image /RestoreHealth} works normally... Is this how sudo was designed to be with pwsh?

@elijah-wright
Copy link

elijah-wright commented Jun 9, 2024

I'm not an expert at Windows programming, but from what I understand DISM calls CreateFileW to create dism.log. I can't reproduce this, though I have an unorthodox setup where I manually inserted the necessary registry keys to get sudo to work on a non-Insider build of Windows

I'm not sure why it would return error 31. I suspect that if the permissions of a directory are set to something like SYSTEM then sudo could be unable to perform actions inside of that directory, though I created a C file with CreateFileW and it worked fine inside of a directory owned by SYSTEM. could you provide the permissions on C:/Windows/Logs/DISM and anything that might be relevant in Event Viewer?

@AvogatoWizardWhisker
Copy link

AvogatoWizardWhisker commented Jun 9, 2024

I was looking around the dism.log after i run sudo and i noticed there are a lot of providers don't support does not support CreateDismImage on C:\ - CGenericImagingManager::CreateDismImage. I'll share the log when I'm free.

Edit: I can finally share the logs from dism. Each logs have specific sudo configuration.
dismForceNewWindow.log
dismInline.log
dismDisableInput.log

Although they don't provide enough details on why dism failed

@joadoumie joadoumie removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 12, 2024
@zadjii-msft
Copy link
Member

Okay this is MSFT:51791454 internally

@AvogatoWizardWhisker
Copy link

Okay we may be onto a lead: on my dev box, sudo cmd, then dism /Online /Cleanup-Image /RestoreHealth from in the CMD that's now running elevated? That works.

For some reason it doesn't work for me with this method
image

@zadjii-msft zadjii-msft added Tracking-External This bug isn't resolved, but it's following an external workitem. and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jul 1, 2024
@MolotovCherry
Copy link

MolotovCherry commented Oct 26, 2024

I've also encountered this on 24H2 (release channel). Workaround for me right now is sudo cmd then run dism commands from the new shell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Tracking-External This bug isn't resolved, but it's following an external workitem.
Projects
None yet
Development

No branches or pull requests

6 participants