summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-07-11 11:31:29 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-07-11 11:37:02 -0500
commit01c47cf00572cd3037845a3dd7a6de3a649cf62c (patch)
tree6c1234f875b77906dbdf6458593be394ae0f8969 /python
parent16f7d593e841b73b2fa4b8120f4bb8e66c4321b3 (diff)
downloadvyos-1x-01c47cf00572cd3037845a3dd7a6de3a649cf62c.tar.gz
vyos-1x-01c47cf00572cd3037845a3dd7a6de3a649cf62c.zip
config-mgmt: T5347: correct logrotate conf permissions on system update
Diffstat (limited to 'python')
-rw-r--r--python/vyos/config_mgmt.py27
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)