Skip to content

hostcfgd passwd_aging_expire_modify always logs error even when chage succeeds #397

Description

@b39b332d

Description

In PasswHardening.passwd_aging_expire_modify(), a spurious error is always logged to
syslog on every invocation — even when chage executes successfully.

Steps to reproduce

  1. Configure password hardening policy with expiration days in CONFIG_DB
  2. Observe syslog output

Actual behavior

Syslog always contains the following error regardless of whether chage succeeded:

Suggested fix

Replace Popen + poll() with wait() to block until the child process exits, then
check the actual return code:

chage_p_m = subprocess.Popen(
    ('chage', chage_flag + str(curr_expiration), normal_account),
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
)
chage_p_m.wait()
return_code_chage_p_m = chage_p_m.returncode
if return_code_chage_p_m != 0:
    syslog.syslog(syslog.LOG_ERR, "failed: return code - {}".format(return_code_chage_p_m))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions