Skip to content

Commit b3babbd

Browse files
committed
Change the access permission of cipher_pass file from 644 to 640 (-rw-r-----)
1 parent 014a0d4 commit b3babbd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sonic-py-common/sonic_py_common/security_cipher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self):
3737
with open(self._file_path, 'w') as file:
3838
file.writelines("#Auto generated file for storing the encryption passwords\n")
3939
file.writelines("TACPLUS : \nRADIUS : \nLDAP :\n")
40+
os.chmod(self._file_path, 0o640)
4041
self._initialized = True
4142

4243
# Write cipher_pass file
@@ -52,8 +53,10 @@ def __write_passwd_file(self, feature_type, passwd):
5253
# Update the password for given feature
5354
lines[self._feature_list.index(feature_type)] = feature_type + ' : ' + passwd + '\n'
5455

56+
os.chmod(self._file_path, 0o777)
5557
with open(self._file_path, 'w') as file:
5658
file.writelines(lines)
59+
os.chmod(self._file_path, 0o640)
5760
except FileNotFoundError:
5861
syslog.syslog(syslog.LOG_ERR, "__write_passwd_file: File {} no found".format(self._file_path))
5962
except PermissionError:
@@ -69,12 +72,13 @@ def __read_passwd_file(self, feature_type):
6972

7073
if feature_type in self._feature_list:
7174
try:
75+
os.chmod(self._file_path, 0o644)
7276
with open(self._file_path, "r") as file:
7377
lines = file.readlines()
7478
for line in lines:
7579
if feature_type in line:
7680
passwd = line.split(' : ')[1]
77-
81+
os.chmod(self._file_path, 0o640)
7882
except FileNotFoundError:
7983
syslog.syslog(syslog.LOG_ERR, "__read_passwd_file: File {} no found".format(self._file_path))
8084
except PermissionError:

0 commit comments

Comments
 (0)