Skip to content

Commit

Permalink
Try to prevent update of user-type Windows installation when running …
Browse files Browse the repository at this point in the history
…as admin (#148428) (#155631)

* Try to prevent update of user-type Windows installation when running as admin (#148428)

* update win32: detect admin mode in initialize

Co-authored-by: João Moreno <joao.moreno@microsoft.com>
  • Loading branch information
gjsjohnmurray and joaomoreno authored Jul 22, 2022
1 parent 3558758 commit 8b7a0d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ export class CodeApplication extends Disposable {
// Initialize update service
const updateService = accessor.get(IUpdateService);
if (updateService instanceof Win32UpdateService || updateService instanceof LinuxUpdateService || updateService instanceof DarwinUpdateService) {
updateService.initialize();
await updateService.initialize();

This comment has been minimized.

Copy link
@bpasero

bpasero Sep 6, 2022

Member

Why does this now block all code that runs after 😱

}

// Start to fetch shell environment (if needed) after window has opened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
* optimization, to avoid using extra CPU cycles before first window open.
* https://github.com/microsoft/vscode/issues/89784
*/
initialize(): void {
async initialize(): Promise<void> {
if (!this.environmentMainService.isBuilt) {
return; // updates are never enabled when running out of sources
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/update/electron-main/updateService.darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class DarwinUpdateService extends AbstractUpdateService {
super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService);
}

override initialize(): void {
super.initialize();
override async initialize(): Promise<void> {
await super.initialize();
this.onRawError(this.onError, this, this.disposables);
this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables);
this.onRawUpdateDownloaded(this.onUpdateDownloaded, this, this.disposables);
Expand Down
9 changes: 9 additions & 0 deletions src/vs/platform/update/electron-main/updateService.win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export class Win32UpdateService extends AbstractUpdateService {
super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService);
}

override async initialize(): Promise<void> {
if (this.productService.target === 'user' && await this.nativeHostMainService.isAdmin(undefined)) {
this.logService.info('update#ctor - updates are disabled due to running as Admin in user setup');
return;
}

super.initialize();
}

protected buildUpdateFeedUrl(quality: string): string | undefined {
let platform = 'win32';

Expand Down

0 comments on commit 8b7a0d8

Please sign in to comment.