Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit d83ebb0

Browse files
author
Antonio Scandurra
committed
Escalate privileges when writing to an unauthorized file also on Linux
1 parent 3b67cea commit d83ebb0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

spec/text-buffer-io-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ describe('TextBuffer IO', () => {
448448
})
449449

450450
describe('when a permission error occurs', () => {
451-
if (process.platform !== 'darwin') return
451+
if (process.platform === 'win32') return
452452

453453
beforeEach(() => {
454454
const save = NativeTextBuffer.prototype.save

src/text-buffer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ class TextBuffer {
19211921
try {
19221922
await this.buffer.save(destination, this.getEncoding())
19231923
} catch (error) {
1924-
if (error.code === 'EACCES' && destination === filePath && process.platform === 'darwin') {
1924+
const canEscalate = process.platform === 'darwin' || process.platform === 'linux'
1925+
if (error.code === 'EACCES' && destination === filePath && canEscalate) {
19251926
const fsAdmin = require('fs-admin')
19261927
try {
19271928
await this.buffer.save(fsAdmin.createWriteStream(filePath), this.getEncoding())

0 commit comments

Comments
 (0)