This commit is contained in:
Benjamin Pasero
2017-12-20 16:57:40 +01:00
parent 6bac0e2235
commit 549cda29da
5 changed files with 13 additions and 13 deletions

View File

@@ -3,11 +3,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# If root, ensure that --user-data-dir or --sudo-write is specified
# If root, ensure that --user-data-dir or --file-write is specified
if [ "$(id -u)" = "0" ]; then
for i in $@
do
if [[ $i == --user-data-dir=* || $i == --sudo-write ]]; then
if [[ $i == --user-data-dir=* || $i == --file-write ]]; then
CAN_LAUNCH_AS_ROOT=1
fi
done

View File

@@ -57,8 +57,8 @@ export async function main(argv: string[]): TPromise<any> {
return mainCli.then(cli => cli.main(args));
}
// Write Elevated
else if (args['sudo-write']) {
// Write File
else if (args['file-write']) {
const source = args._[0];
const target = args._[1];
@@ -69,7 +69,7 @@ export async function main(argv: string[]): TPromise<any> {
!fs.existsSync(source) || !fs.statSync(source).isFile() || // make sure source exists as file
!fs.existsSync(target) || !fs.statSync(target).isFile() // make sure target exists as file
) {
return TPromise.wrapError(new Error('Using --sudo-write with invalid arguments.'));
return TPromise.wrapError(new Error('Using --file-write with invalid arguments.'));
}
try {
@@ -77,7 +77,7 @@ export async function main(argv: string[]): TPromise<any> {
// Check for readonly status and chmod if so if we are told so
let targetMode: number;
let restoreMode = false;
if (!!args['sudo-chmod']) {
if (!!args['file-chmod']) {
targetMode = fs.statSync(target).mode;
if (!(targetMode & 128) /* readonly */) {
fs.chmodSync(target, targetMode | 128);
@@ -106,7 +106,7 @@ export async function main(argv: string[]): TPromise<any> {
fs.chmodSync(target, targetMode);
}
} catch (error) {
return TPromise.wrapError(new Error(`Using --sudo-write resulted in an error: ${error}`));
return TPromise.wrapError(new Error(`Using --file-write resulted in an error: ${error}`));
}
return TPromise.as(null);

View File

@@ -52,8 +52,8 @@ export interface ParsedArgs {
'disable-updates'?: string;
'disable-crash-reporter'?: string;
'skip-add-to-recently-opened'?: boolean;
'sudo-write'?: boolean;
'sudo-chmod'?: boolean;
'file-write'?: boolean;
'file-chmod'?: boolean;
}
export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');

View File

@@ -57,8 +57,8 @@ const options: minimist.Opts = {
'disable-crash-reporter',
'skip-add-to-recently-opened',
'status',
'sudo-write',
'sudo-chmod'
'file-write',
'file-chmod'
],
alias: {
add: 'a',

View File

@@ -621,9 +621,9 @@ export class FileService implements IFileService {
const sudoCommand: string[] = [`"${this.options.elevationSupport.cliPath}"`];
if (options.overwriteReadonly) {
sudoCommand.push('--sudo-chmod');
sudoCommand.push('--file-chmod');
}
sudoCommand.push('--sudo-write', `"${tmpPath}"`, `"${absolutePath}"`);
sudoCommand.push('--file-write', `"${tmpPath}"`, `"${absolutePath}"`);
sudoPrompt.exec(sudoCommand.join(' '), promptOptions, (error: string, stdout: string, stderr: string) => {
if (error || stderr) {