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

Commit

Permalink
Merge pull request #311 from atom/as/escalate-privileges-on-linux
Browse files Browse the repository at this point in the history
Escalate privileges when writing to an unauthorized file also on Linux
  • Loading branch information
Antonio Scandurra authored May 29, 2019
2 parents 3b67cea + bd5a80e commit 7363039
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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

0 comments on commit 7363039

Please # to comment.