Sublime Forum

Sudo behavior

#1

How to reproduce:

  1. Run sublime with normal privileges
  2. Open some files for editing
  3. run sudo subl <thisfile>
  4. Close tab with

NOW: you can File->Open and change any file on system

EXPECTED: whole instance of sublime text must not have root rights. Only this tab must have access to edit only and have no access to open others with root privileges

EXCEPTION is when whole sublime instance are run with root rights: sudo subl (eg. without file arguments)

0 Likes

Cannot start sublime under sudo
#2

This is working as designed. Privileges are a per-process notion, and Sublime Text all runs within a single process.

There’s no need to run Sublime Text as administrator on either OSX or Linux, it will prompt for permission to save any files you don’t own.

0 Likes

#3

No it do not ask. It save new files with root privileges.
Besides that it rewrite rights for files I have open before sudo subl fstab

It will be good that tabs has its own rights. If I open file as root, so privilege for this tab is root. If I open file as user, so privilege for this tab is user.

0 Likes

#4

Run the command without sudo and if you save and the file requires root permission you’ll get a prompt for entering the password.

If you do use sudo (in your current case), you won’t get a prompt for the password because sublime is now running with root permissions for every file.

0 Likes

#5

OK. seems this works.

But if you have “save_on_focus_lost”: true, and you try to save with root permission you will be ask for password.

If you try to cancel that you will be promted three times for password and also you get three error messages about that I have no permition.

EXPECTED:

  1. If I cancel saving do not ask password again
  2. If I cancel saving do not tell me that I have not permition ( becase I do not try saving )
  3. Show error only if I enter wrong password and click OK.
0 Likes