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

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

Merged
merged 3 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}

// 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