From d83ebb09ed6ddc3468d6c8b07316a6f13ad6899f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 28 May 2019 11:52:47 +0200 Subject: [PATCH 1/3] Escalate privileges when writing to an unauthorized file also on Linux --- spec/text-buffer-io-spec.js | 2 +- src/text-buffer.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/text-buffer-io-spec.js b/spec/text-buffer-io-spec.js index ec4e518283..0816a58d4d 100644 --- a/spec/text-buffer-io-spec.js +++ b/spec/text-buffer-io-spec.js @@ -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 diff --git a/src/text-buffer.js b/src/text-buffer.js index 37b44d5d2a..127ac82d55 100644 --- a/src/text-buffer.js +++ b/src/text-buffer.js @@ -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()) From 1273f0349076c940335c7b1d5ca303149c98da2a Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 29 May 2019 13:44:56 +0200 Subject: [PATCH 2/3] Upgrade fs-admin to v0.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3bc754db80..0d23cfaf26 100644 --- a/package.json +++ b/package.json @@ -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", From bd5a80ea2e7ecec770c04aa85e827e3342747615 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 29 May 2019 14:08:51 +0200 Subject: [PATCH 3/3] 13.15.4-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d23cfaf26..9a4196eb81 100644 --- a/package.json +++ b/package.json @@ -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": {