Skip to content

vscode: Fix "Save as Admin" #49643 #102010

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

Closed
wants to merge 1 commit into from
Closed

vscode: Fix "Save as Admin" #49643 #102010

wants to merge 1 commit into from

Conversation

kode54
Copy link

@kode54 kode54 commented Oct 29, 2020

Motivation for this change

I decided to fix something that I found was broken, and saw in the relevant issue that a fix was already applied to another package in a similar fashion, but had not made its way to this package yet.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@@ -69,6 +69,16 @@ in
dontBuild = true;
dontConfigure = true;

patchPhase =
if system != "x86_64-darwin" then ''
Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate why this is not required on darwin?

Copy link
Author

@kode54 kode54 Oct 30, 2020

Choose a reason for hiding this comment

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

Does the darwin flavor of sudo-prompt even use the same scripts to achieve administrator access? How does nix even handle sandboxing shell commands on an OS like that?

Copy link
Author

@kode54 kode54 Oct 30, 2020

Choose a reason for hiding this comment

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

As I suspected:

https://github.com/jorangreef/sudo-prompt/blob/master/index.js

sudo-prompt uses a completely different code path on macOS/Darwin to achieve the sudo prompt, going as far as bundling a special program in a zip file, unpacking it, and running it, to elevate the requested command.

The above patch for /bin/bash and /usr/bin/pkexec processes only applies to NixOS, and any other Linux system adhering to Nix file paths for these two utilities.

I wasn't sure if this was the correct way to limit it, though. I took the hint from the install process, which gates Darwin specific install process from everything else, since only Darwin will be installing a single .app bundle.

I'm just going to guess Nix doesn't target native Windows? If it does, then this check should specifically apply only to Linux versions.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if we apply this unconditionally to prevent bit rot as long as it does not break something not already broken on darwin.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, you can apply it unconditionally, but upstream only supplies binary packages for x86_64 anyway.

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 102010 run on x86_64-linux 1

3 packages built:
  • vscode
  • vscode-with-extensions
  • vscodium

@berbiche
Copy link
Member

Friendly bump 😃

@Synthetica9
Copy link
Member

Synthetica9 commented Jan 13, 2021 via email

@@ -69,6 +69,16 @@ in
dontBuild = true;
dontConfigure = true;

patchPhase =
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
patchPhase =
postPatch =

@@ -69,6 +69,16 @@ in
dontBuild = true;
dontConfigure = true;

patchPhase =
if system != "x86_64-darwin" then ''
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if system != "x86_64-darwin" then ''
lib.optionalString (system != "x86_64-darwin") ''

sed -i 's|/bin/bash|${bash}/bin/bash|' tmp/sudo-prompt/index.js
${nodePackages.asar}/bin/asar pack tmp ./resources/app/node_modules.asar
rm -rf tmp
'' else '''';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'' else '''';
'';

@kode54
Copy link
Author

kode54 commented Feb 12, 2021

I'm just gonna close this, as I don't intend to use Nix again any time in the future anyway.

@kode54 kode54 closed this Feb 12, 2021
@berbiche
Copy link
Member

@kode54 sorry for the cc, the situation is unfortunate, thanks for the groundwork in any event 👍 .
Surely someone else will pick it up at some point in time!

@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants