mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Migrate user's password-store
if they are gnome
or gnome-keyring
(#204553)
* Migrate user's `password-store` if they are `gnome` or `gnome-keyring` True fix for https://github.com/microsoft/vscode/issues/204318 * add import
This commit is contained in:
parent
8a98afa440
commit
29e000b1e5
28
src/main.js
28
src/main.js
|
@ -233,25 +233,25 @@ function configureCommandlineSwitchesSync(cliArgs) {
|
|||
|
||||
// Append Electron flags to Electron
|
||||
if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) !== -1) {
|
||||
|
||||
if (
|
||||
// Color profile
|
||||
argvKey === 'force-color-profile' ||
|
||||
// Password store
|
||||
argvKey === 'password-store'
|
||||
) {
|
||||
if (argvValue) {
|
||||
app.commandLine.appendSwitch(argvKey, argvValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Others
|
||||
else if (argvValue === true || argvValue === 'true') {
|
||||
if (argvValue === true || argvValue === 'true') {
|
||||
if (argvKey === 'disable-hardware-acceleration') {
|
||||
app.disableHardwareAcceleration(); // needs to be called explicitly
|
||||
} else {
|
||||
app.commandLine.appendSwitch(argvKey);
|
||||
}
|
||||
} else if (argvValue) {
|
||||
if (argvKey === 'force-color-profile') {
|
||||
// Color profile
|
||||
app.commandLine.appendSwitch(argvKey, argvValue);
|
||||
} else if (argvKey === 'password-store') {
|
||||
// Password store
|
||||
// TODO@TylerLeonhardt: Remove this migration in 3 months
|
||||
let migratedArgvValue = argvValue;
|
||||
if (argvValue === 'gnome' || argvValue === 'gnome-keyring') {
|
||||
migratedArgvValue = 'gnome-libsecret';
|
||||
}
|
||||
app.commandLine.appendSwitch(argvKey, migratedArgvValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ export interface ICommonEncryptionService {
|
|||
export const enum PasswordStoreCLIOption {
|
||||
kwallet = 'kwallet',
|
||||
kwallet5 = 'kwallet5',
|
||||
gnome = 'gnome',
|
||||
gnomeKeyring = 'gnome-keyring',
|
||||
gnomeLibsecret = 'gnome-libsecret',
|
||||
basic = 'basic'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { stripComments } from 'vs/base/common/stripComments';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
|
||||
class EncryptionContribution implements IWorkbenchContribution {
|
||||
constructor(
|
||||
@IJSONEditingService private readonly jsonEditingService: IJSONEditingService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IStorageService private readonly storageService: IStorageService
|
||||
) {
|
||||
this.migrateToGnomeLibsecret();
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate the user from using the gnome or gnome-keyring password-store to gnome-libsecret.
|
||||
* TODO@TylerLeonhardt: This migration can be removed in 3 months or so and then storage
|
||||
* can be cleaned up.
|
||||
*/
|
||||
private async migrateToGnomeLibsecret(): Promise<void> {
|
||||
if (!isLinux || this.storageService.getBoolean('encryption.migratedToGnomeLibsecret', StorageScope.APPLICATION, false)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const content = await this.fileService.readFile(this.environmentService.argvResource);
|
||||
const argv = JSON.parse(stripComments(content.value.toString()));
|
||||
if (argv['password-store'] === 'gnome' || argv['password-store'] === 'gnome-keyring') {
|
||||
this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['password-store'], value: 'gnome-libsecret' }], true);
|
||||
}
|
||||
this.storageService.store('encryption.migratedToGnomeLibsecret', true, StorageScope.APPLICATION, StorageTarget.USER);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EncryptionContribution, LifecyclePhase.Eventually);
|
|
@ -173,6 +173,8 @@ import 'vs/workbench/contrib/remoteTunnel/electron-sandbox/remoteTunnel.contribu
|
|||
import 'vs/workbench/contrib/chat/electron-sandbox/chat.contribution';
|
||||
import 'vs/workbench/contrib/inlineChat/electron-sandbox/inlineChat.contribution';
|
||||
|
||||
// Encryption
|
||||
import 'vs/workbench/contrib/encryption/electron-sandbox/encryption.contribution';
|
||||
|
||||
//#endregion
|
||||
|
||||
|
|
Loading…
Reference in a new issue