diff options
author | Christian Breunig <christian@breunig.cc> | 2023-07-12 00:23:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-12 00:23:28 +0200 |
commit | 7b68812cd775226c3a05c3dbca75343362bef1f4 (patch) | |
tree | df6b9a8b849e6d29e77e26c8449279919c6106fa /python/vyos | |
parent | 484259af7d2530601faacf7ad741523c5f93622a (diff) | |
parent | 01c47cf00572cd3037845a3dd7a6de3a649cf62c (diff) | |
download | vyos-1x-7b68812cd775226c3a05c3dbca75343362bef1f4.tar.gz vyos-1x-7b68812cd775226c3a05c3dbca75343362bef1f4.zip |
Merge pull request #2086 from jestabro/config-archive
config-mgmt: T5347: set logrotate conf permissions correctly for system update
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/config_mgmt.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py index 26114149f..e1870aa0a 100644 --- a/python/vyos/config_mgmt.py +++ b/python/vyos/config_mgmt.py @@ -21,6 +21,8 @@ import logging from typing import Optional, Tuple, Union from filecmp import cmp from datetime import datetime +from textwrap import dedent +from pathlib import Path from tabulate import tabulate from vyos.config import Config @@ -456,19 +458,18 @@ Proceed ?''' return ConfigTree(c) def _add_logrotate_conf(self): - conf = f"""{archive_config_file} {{ - su root vyattacfg - rotate {self.max_revisions} - start 0 - compress - copy -}}""" - mask = os.umask(0o133) - - with open(logrotate_conf, 'w') as f: - f.write(conf) - - os.umask(mask) + conf: str = dedent(f"""\ + {archive_config_file} {{ + su root vyattacfg + rotate {self.max_revisions} + start 0 + compress + copy + }} + """) + conf_file = Path(logrotate_conf) + conf_file.write_text(conf) + conf_file.chmod(0o644) def _archive_active_config(self) -> bool: mask = os.umask(0o113) |