From 67c4072ff7586a3677df7ca129de2550cc5519bc Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Thu, 29 Mar 2018 21:33:20 +0200 Subject: [PATCH] Respect ownership on code command installation Fixes #46754 --- .../parts/cli/electron-browser/cli.contribution.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts index 5e754fb953dee..fb2293d8434c8 100644 --- a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts +++ b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts @@ -78,8 +78,7 @@ class InstallAction extends Action { return createSymlink().then(null, err => { if (err.code === 'EACCES' || err.code === 'ENOENT') { - return this.createBinFolder() - .then(() => createSymlink()); + return this.createBinFolderAndSymlink(); } return TPromise.wrapError(err); @@ -101,14 +100,14 @@ class InstallAction extends Action { .then(null, ignore('ENOENT', false)); } - private createBinFolder(): TPromise { + private createBinFolderAndSymlink(): TPromise { return new TPromise((c, e) => { const buttons = [nls.localize('ok', "OK"), nls.localize('cancel2', "Cancel")]; this.dialogService.show(Severity.Info, nls.localize('warnEscalation', "Code will now prompt with 'osascript' for Administrator privileges to install the shell command."), buttons, { cancelId: 1 }).then(choice => { switch (choice) { case 0 /* OK */: - const command = 'osascript -e "do shell script \\"mkdir -p /usr/local/bin && chown \\" & (do shell script (\\"whoami\\")) & \\" /usr/local/bin\\" with administrator privileges"'; + const command = 'osascript -e "do shell script \\"mkdir -p /usr/local/bin && ln -sf \'' + getSource() + '\' \'' + this.target + '\'\\" with administrator privileges"'; nfcall(cp.exec, command, {}) .then(null, _ => TPromise.wrapError(new Error(nls.localize('cantCreateBinFolder', "Unable to create '/usr/local/bin'."))))