Commit 7d7a88cd by Sébastien Eustace

Fix permissions for configurations files

parent aeb69791
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
- Fixed duplicate entries in both sdist and wheel. - Fixed duplicate entries in both sdist and wheel.
- Fixed excluded files appearing in the `package_data` of the generated `setup.py`. - Fixed excluded files appearing in the `package_data` of the generated `setup.py`.
- Fixed transitive directory dependencies installation. - Fixed transitive directory dependencies installation.
- Fixed file permissions for configuration and authentication files.
## [0.11.5] - 2018-09-04 ## [0.11.5] - 2018-09-04
......
...@@ -93,6 +93,9 @@ class Config: ...@@ -93,6 +93,9 @@ class Config:
if current_mode != 384: if current_mode != 384:
os.remove(str(self._file)) os.remove(str(self._file))
if self._file.exists():
fd = str(self._file)
else:
umask_original = os.umask(umask) umask_original = os.umask(umask)
try: try:
fd = os.open(str(self._file), os.O_WRONLY | os.O_CREAT, mode) fd = os.open(str(self._file), os.O_WRONLY | os.O_CREAT, mode)
......
...@@ -24,3 +24,15 @@ def test_config_sets_the_proper_file_permissions(config): ...@@ -24,3 +24,15 @@ def test_config_sets_the_proper_file_permissions(config):
mode = oct(os.stat(str(config.file)).st_mode & 0o777) mode = oct(os.stat(str(config.file)).st_mode & 0o777)
assert int(mode, 8) == 384 assert int(mode, 8) == 384
def test_config_add_property(config):
config.add_property("settings.virtualenvs.create", True)
content = config.file.read()
assert content == {"settings": {"virtualenvs": {"create": True}}}
config.remove_property("settings.virtualenvs.create")
content = config.file.read()
assert content == {"settings": {"virtualenvs": {}}}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment