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

Run with internal flag when saving with sudo on Windows #3578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niten94
Copy link
Contributor

@niten94 niten94 commented Dec 16, 2024

An internal flag is used, because there is no program available by default on Windows that can be used in place of the dd command.

I was running micro -encoding shift_jis C:\test.txt then saving with ファイル内容 as content when testing. There should be no text corruption when running the command again to check how file is written.

The methods below were considered:

  • ShellExecute: data cannot be written to the standard input of the process
  • PowerShell: script with around 10 lines has to be used

All programs below except runas worked when used as sucmd:

  • runas
    • available by default in Windows 2000 and newer but standard input was read as password when testing
    • user to run command as needs to be specified
    • command and arguments are specified in one string
  • Sudo for Windows
    • source code is on GitHub but there are only official builds on Windows 11
  • gsudo
    • seems to be known in recent years when searching programs like sudo on Windows
    • wrapper with sudo name can be enabled using installer
    • saving only worked in TokenSwitch mode (current default)
      • .NET objects used in the code of other modes probably handle data in standard input as text

Closes #3541

@niten94 niten94 changed the title Save using PowerShell script when using sudo on Windows Run with internal flag when saving with sudo on Windows Dec 18, 2024
@@ -246,6 +263,14 @@ func main() {
defer pprof.StopCPUProfile()
}

if *flagWrite != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better if the use is explained in a comment. I'll still have to check sometime if programs running with an internal flag and privileges is considered fine on Windows.

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

Successfully merging this pull request may close these issues.

[Feature Request] Add Sudo Support on Windows
1 participant