Skip to content
Closed
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ from sonic_py_common.general import check_output_pipe
from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table
from swsscommon import swsscommon
from sonic_installer import bootloader
from sonic_py_common.security_cipher import master_key_mgr

# FILE
PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic"
Expand Down Expand Up @@ -75,7 +76,6 @@ DEFAULT_FIPS_RESTART_SERVICES = ['ssh', 'telemetry.service', 'restapi']
CFG_DB = "CONFIG_DB"
STATE_DB = "STATE_DB"


def signal_handler(sig, frame):
if sig == signal.SIGHUP:
syslog.syslog(syslog.LOG_INFO, "HostCfgd: signal 'SIGHUP' is caught and ignoring..")
Expand Down Expand Up @@ -500,6 +500,17 @@ class AaaCfg(object):
server = tacplus_global.copy()
server['ip'] = addr
server.update(self.tacplus_servers[addr])
if 'key_encrypt' in server:
secure_cipher = master_key_mgr()
if server['key_encrypt'] == 'True':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value depends on how 'key_encrypt' was set. It can also be 'true' instead of 'True' (it's actually more correct to use 'true'). there's an is_true() function you can use if you don't want to worry about which format you might get.

output, errs = secure_cipher.decrypt_passkey("TACPLUS", server['passkey'])
if not errs:
server['passkey'] = output
else:
syslog.syslog(syslog.LOG_ERR, "{}: decrypt_passkey failed.".format(addr))
else:
# Delete the cipher_pass file if exist
secure_cipher.del_cipher_pass()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will delete the whole file, probably not what we want. it should be enough just to remove the TACACS entry, or set the passkey to ""

servers_conf.append(server)
servers_conf = sorted(servers_conf, key=lambda t: int(t['priority']), reverse=True)

Expand Down