sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
804 stars 39 forks source link

Potential accidental overwrite of protected files #5946

Open JackNWhite opened 1 year ago

JackNWhite commented 1 year ago

Description of the bug

When you open a file for which you do not have read permission, ST will open a blank buffer under the name of the protected file rather than the contents of the file. If you try to save this over the existing file, a dialogue window appears asking for your password. The file will be saved if you have an admin account, overwriting the contents of the file without you ever seeing it.

No "permission denied" message appears in the general GUI when opening the protected file. Unable to open /path/to/file.ext will be printed in the console, however, this is not obvious, and I only discovered this because I tried opening a file using sudo.

Steps to reproduce

  1. Save a new text file containing dummy text image
  2. Give read permission only to root image
  3. Open the file in ST using your normal user account image
  4. Enter text in the blank buffer and save image
  5. Check the result and lament image

Expected behavior

When opening a read-protected file, ST should either

  1. Open the password dialogue to get permission to read the file (maintaining the same for any subsequent writes), or
  2. Open a dialogue denying the user read access to the file without opening a blank buffer in its name

Actual behavior

When opening a read-protected file, ST does not obviously alert the user and does not allow the user to grant permission. Instead, ST launches a blank buffer with the same name as the protected file, allowing the user to believe that the protected file is empty when it is not. ST subsequently allows the user to save the blank, or newly filled buffer, over the protected file if the user has sudo rights.

Sublime Text build number

4143

Operating system & version

Linux Mint 20.3

(Linux) Desktop environment and/or window manager

Cinnamon 5.2.7

Additional information

No response

OpenGL context information

No response

keith-hall commented 1 year ago

related: https://github.com/sublimehq/sublime_text/issues/936