Skip to content

Commit

Permalink
[Hardening] Avoid "backup.py" failing while trying to set "w" perms o…
Browse files Browse the repository at this point in the history
…n the GeoServer catalog file

(cherry picked from commit bc8b432)
  • Loading branch information
afabiani committed Oct 19, 2022
1 parent df73651 commit afa0638
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions geonode/br/management/commands/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,13 @@ def create_geoserver_backup(self, config, settings, target_folder, ignore_errors
if gs_bk_exec_status == 'FAILED':
raise ValueError(error_backup.format(url, r.status_code, r.text))
_permissions = 0o777
os.chmod(geoserver_bk_file, _permissions)
status = os.stat(geoserver_bk_file)
if oct(status.st_mode & 0o777) != str(oct(_permissions)):
raise Exception(f"Could not update permissions of {geoserver_bk_file}")
try:
os.chmod(geoserver_bk_file, _permissions)
status = os.stat(geoserver_bk_file)
if oct(status.st_mode & 0o777) != str(oct(_permissions)):
raise Exception(f"Could not update permissions of {geoserver_bk_file}")
except Exception as e:
logger.warning(e)
else:
raise ValueError(error_backup.format(url, r.status_code, r.text))

Expand Down

0 comments on commit afa0638

Please sign in to comment.