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

'Retry as sudo' doesnt work #234311

Open
paul0ss opened this issue Nov 20, 2024 · 3 comments
Open

'Retry as sudo' doesnt work #234311

paul0ss opened this issue Nov 20, 2024 · 3 comments
Assignees
Labels
confirmation-pending file-io File I/O info-needed Issue requires more information from poster workbench-run-as-admin Issues concerning running as administrator

Comments

@paul0ss
Copy link

paul0ss commented Nov 20, 2024

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.95.3 x64
  • OS Version: Kali Linux 6.11.2-amd64
  • VS Code source: Microsoft Repository

Steps to Reproduce:

  1. Open a file that is not writable by the user
  2. Edit the file
  3. Try to save it
  4. Error pops up stating that not enough permissions
  5. Retry as Sudo option appears
  6. Enter password
  7. Saving process freezes up

People discussing this issue here: #70403
Given information from the above-mentioned source I was able to debug the problem.

According to the developer the write a file with sudo goes through following process:

  1. we write the desired contents into a temp file (here)
  2. we import sudo-prompt (here)
  3. we ask it to run "code --file-write tmpfile target"

After running VSCode with --verbose flag I have noticed the target file is not set:
[sudo-prompt] running command: "/usr/share/code/bin/code" --file-write "/home/paul0ss/.config/Code/code-elevated-DYqaVPH4"

This is probably the reason why the file write doesnt succeed but also doesnt throw any exception stating that permission was denied.

@bpasero
Copy link
Member

bpasero commented Nov 21, 2024

We changed the solution to only require 1 file, so the execution looks fine.

Are there more errors in the full logs?

@bpasero bpasero added info-needed Issue requires more information from poster confirmation-pending labels Nov 21, 2024
@bpasero bpasero added workbench-run-as-admin Issues concerning running as administrator file-io File I/O labels Nov 21, 2024
@paul0ss
Copy link
Author

paul0ss commented Nov 21, 2024

We changed the solution to only require 1 file, so the execution looks fine.

Are there more errors in the full logs?

No other errors. Here is bigger a snippet from the log beginning with the initial permission denied error:

[225780:1121/122623.787264:INFO:CONSOLE(35)] "%c  ERR color: #f33 [text file model] handleSaveError(10) - exit - resulted in a save error: Error: Unable to write file '/home/paul0ss/myfile.txt' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/paul0ss/myfile.txt') file:///home/paul0ss/myfile.txt", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[225780:1121/122623.789529:INFO:CONSOLE(3086)] "Failed to save 'myfile.txt': Insufficient permissions. Select 'Retry as Sudo' to retry as superuser.", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (3086)
[225780:1121/122623.791898:INFO:CONSOLE(35)] "%cTRACE color: #888 [text file model] save() - exit file:///home/paul0ss/myfile.txt", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[225780:1121/122625.149757:INFO:CONSOLE(35)] "%cTRACE color: #888 [text file model] save() - enter file:///home/paul0ss/myfile.txt", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[225780:1121/122625.149971:INFO:CONSOLE(35)] "%cTRACE color: #888 [text file model] doSave(10) - enter with versionId 10 file:///home/paul0ss/myfile.txt", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[225780:1121/122625.161301:INFO:CONSOLE(35)] "%cTRACE color: #888 [text file model] doSave(10) - before write() file:///home/paul0ss/myfile.txt", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[main 2024-11-21T11:26:25.175Z] [sudo-prompt] running command: "/usr/share/code/bin/code" --file-write "/home/paul0ss/.config/Code/code-elevated-PacaoCZO"
[225780:1121/122625.264863:INFO:CONSOLE(35)] "%cDEBUG background: #eee; color: #888 Comments: URIs of continue on comments to add to storage .", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[main 2024-11-21T11:26:29.248Z] menubarService#updateMenubar 1
[225780:1121/122632.503243:INFO:CONSOLE(35)] "%cDEBUG background: #eee; color: #888 Comments: URIs of continue on comments to add to storage .", source: vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (35)
[main 2024-11-21T11:26:33.616Z] update#checkForUpdates, state =  idle
[main 2024-11-21T11:26:33.618Z] update#setState checking for updates
[main 2024-11-21T11:26:33.620Z] resolveShellEnv(): skipped (VSCODE_CLI is set)
[main 2024-11-21T11:26:33.620Z] [network] #2: https://update.code.visualstudio.com/api/update/linux-x64/stable/f1a4fb101478ce6ec82fe9627c43efbf9e98c813 - begin undefined Xy { b: {}, a: [Object: null prototype] {} }
[main 2024-11-21T11:26:33.638Z] [network] #2: https://update.code.visualstudio.com/api/update/linux-x64/stable/f1a4fb101478ce6ec82fe9627c43efbf9e98c813 - end undefined 204 {
  'access-control-allow-origin': '*',
  date: 'Thu, 21 Nov 2024 11:26:30 GMT',
  'request-context': 'appId=cid-v1:8109e553-6232-492a-afca-b78cea9b431c',
  'strict-transport-security': 'max-age=31536000; includeSubDomains',
  'x-azure-ref': '20241121T112630Z-179d85bf68cp9sr2hC1FRAfyv40000000250000000022uwr',
  'x-cache': 'CONFIG_NOCACHE',
  'x-content-type-options': 'nosniff',
  'x-powered-by': 'Express',
  'x-source-commit': 'ec889288e272a7cf2166c86c73aa9424bf003814'
}

VS Codes behavior:
Image

Full log file:
runas.log

PS: The Apparmor is turned off to cut off any third party interference and the bug was replicated on a fresh Kali install on another computer as well to exclude the possibility of the bug occurring in my specific environment.

@bpasero
Copy link
Member

bpasero commented Nov 21, 2024

Thanks, this line is relevant:

�[90m[main 2024-11-21T11:26:25.175Z]�[0m [sudo-prompt] running command: "/usr/share/code/bin/code" --file-write "/home/paul0ss/.config/Code/code-elevated-PacaoCZO"

Curious when you try this again, can you check the contents of this file and if it exists on disk? It would have a different name each time you try, so you need to get it from the logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmation-pending file-io File I/O info-needed Issue requires more information from poster workbench-run-as-admin Issues concerning running as administrator
Projects
None yet
Development

No branches or pull requests

2 participants