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

Escalate privileges when writing to an unauthorized file also on Linux #311

Merged
merged 3 commits into from
May 29, 2019
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "text-buffer",
"version": "13.15.3",
"version": "13.15.4-0",
"description": "A container for large mutable strings with annotated regions",
"main": "./lib/text-buffer",
"scripts": {
Expand Down Expand Up @@ -48,7 +48,7 @@
"diff": "^2.2.1",
"emissary": "^1.0.0",
"event-kit": "^2.4.0",
"fs-admin": "^0.1.7",
"fs-admin": "^0.5.0",
"fs-plus": "^3.0.0",
"grim": "^2.0.2",
"mkdirp": "^0.5.1",
Expand Down
2 changes: 1 addition & 1 deletion spec/text-buffer-io-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ describe('TextBuffer IO', () => {
})

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

beforeEach(() => {
const save = NativeTextBuffer.prototype.save
Expand Down
3 changes: 2 additions & 1 deletion src/text-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,8 @@ class TextBuffer {
try {
await this.buffer.save(destination, this.getEncoding())
} catch (error) {
if (error.code === 'EACCES' && destination === filePath && process.platform === 'darwin') {
const canEscalate = process.platform === 'darwin' || process.platform === 'linux'
if (error.code === 'EACCES' && destination === filePath && canEscalate) {
const fsAdmin = require('fs-admin')
try {
await this.buffer.save(fsAdmin.createWriteStream(filePath), this.getEncoding())
Expand Down