Skip to content

Commit

Permalink
Fix file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed May 23, 2024
1 parent 894a435 commit 47ec480
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/middlewared/middlewared/etc_files/systemd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
import os

from middlewared.service import CallError
from middlewared.utils import run
Expand Down Expand Up @@ -39,3 +40,4 @@ async def render(service, middleware):
# Write out a user enabled services to json file which shows which services user has enabled/disabled
with open('/data/user-services.json', 'w') as f:
f.write(json.dumps(services_enabled))
os.chmod('/data/user-services.json', 0o600)
2 changes: 2 additions & 0 deletions src/middlewared/middlewared/plugins/system/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def license_update(self, license_):
SystemService.PRODUCT_TYPE = None
if self.middleware.call_sync('system.is_enterprise'):
Path('/data/truenas-eula-pending').touch(exist_ok=True)
# We don't do it in touch func because it won't update mode if the file already exists
os.chmod('/data/truenas-eula-pending', 0o600)

self.middleware.call_sync('alert.alert_source_clear_run', 'LicenseStatus')
self.middleware.call_sync('failover.configure.license', dser_license)
Expand Down
7 changes: 4 additions & 3 deletions src/middlewared/middlewared/plugins/truenas.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def get_eula(self):
@accepts(roles=['READONLY_ADMIN'])
@returns(Bool('system_eula_accepted'))
@cli_private
async def is_eula_accepted(self):
def is_eula_accepted(self):
"""
Returns whether the EULA is accepted or not.
"""
return not os.path.exists(EULA_PENDING_PATH)

@accepts()
@returns()
async def accept_eula(self):
def accept_eula(self):
"""
Accept TrueNAS EULA.
"""
Expand All @@ -111,9 +111,10 @@ async def accept_eula(self):
raise

@private
async def unaccept_eula(self):
def unaccept_eula(self):
with open(EULA_PENDING_PATH, "w"):
pass
os.chmod(EULA_PENDING_PATH, 0o600)

# TODO: Document this please
@accepts()
Expand Down

0 comments on commit 47ec480

Please sign in to comment.