Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save the project data on the user settings folder by default, instead of user home folder #4

Open
evandrocoan opened this issue Jul 22, 2017 · 3 comments

Comments

@evandrocoan
Copy link

evandrocoan commented Jul 22, 2017

Currently VSCode can be launched as root/administrator, therefore all setting files written to the disk as this project setting files would be saved with root/administrator access. So when the user normally launches the VSCode he cannot read its settings saved on its home folder. This workflow is currently discussed on:

  1. Portable version! microsoft/vscode#329 Portable version!
  2. Allow user-level installations microsoft/vscode#534 Allow user-level installations
  3. Allow to save files that need user elevation microsoft/vscode#1614 Better support running Code as administrator
  4. running vscode with gksudo or sudo permission microsoft/vscode#3068 running vscode with gksudo or sudo permission
  5. Support launching VS Code from Bash on Ubuntu on Windows microsoft/vscode#13138 Support launching VS Code from Bash on Ubuntu on Windows
  6. Add "(Administrator)" suffix to window title when running as administrator in Windows microsoft/vscode#19707 Add "(Administrator)" suffix to window title when running as administrator in Window

I think this should be the cause of the issue #1 (Path does not exist ). Somehow the VSCode could be opened as root/administrator and saved this extension settings on the user folder with root/administrator. Now he is on an instance non-root, and VSCode do not have access to its own files on the home folder.

If this package saved the setting on the VSCode settings folder, it would have worked correctly as long as he specified the --user-data-dir to the root folder. For example, I am going to open VSCode as root I must to set the data settings to another folder other the user folder, therefore the user files would not have its permission elevated to the root level.

You should never use normal sudo to start graphical applications as root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=/root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by root.

What is the difference between “gksudo nautilus” and “sudo nautilus”?

@fabiospampinato fabiospampinato self-assigned this Jul 22, 2017
@fabiospampinato
Copy link
Owner

fabiospampinato commented Jul 22, 2017

Tell me if I understood this correctly:

  1. Without an explicit configPath this extensions uses 2 different paths depending on if VSC has been launched with administrator privileges or not.
  2. If an administrator instance saves the configuration it cannot be read by a non-administrator instance.

I'll investigate how to always detect the correct user path and how to write the config file in a more compatible manner.

@evandrocoan
Copy link
Author

evandrocoan commented Jul 22, 2017

Without an explicit configPath this extensions uses 2 different paths depending on if VSC has been launched with administrator privileges or not.

With a explicit config path, and you run VSCode as root, you will use the on the config path, so if you write to that file while with root powers, you cannot read it when you are normal user.

If an administrator instance saves the configuration it cannot be read by a non-administrator instance

Yes. At least should be like this. If windows respected that I do not know. But seems that on Linux the correct way of doing it is running VSCode with gksudo, therefore gksudo will set the user folder to HOME=/root then the settings files will be correctly saved on the root domain.

So, it does not seem a problem after all. I would suggest to close this, however as @t7yang mentioned, seems that putting the setting under the VSCode folder causes the sync extension able to sync the config.


Update

I am not sure whether sync the settings is a good thing because the file paths on it are absolute, so they should differ from one computer to another. But may be an dedicated user can setup the same paths on both machines, which solves the absolute linking problem.

@pksunkara
Copy link
Contributor

One thing you can do is replace {vscode} in the configPath string to be the user settings folder. That way, if I want to save my projects config in user settings folder, I will use the configPath as {vscode}/projects.json.

Btw, amazing work!!! So many good extensions by you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants