Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Create consumer cert & key, when chown failed #3466

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jirihnidek
Copy link
Contributor

  • When it wasn't possible to change group of consumer key.pem, due to missing SELinux rule, then consumer cert.pem was not created. rhsm.service should write only error log message to rhsm.log in this case

* When it wasn't possible to change group of consumer key.pem,
  due to missing SELinux rule, then consumer cert.pem was not
  created. rhsm.service should write only error log message
  to rhsm.log in this case
@cnsnyder cnsnyder requested review from a team and ptoscano and removed request for a team October 18, 2024 10:37
Copy link

Coverage

Coverage (computed on Fedora latest) •
FileStmtsMissCoverMissing
subscription_manager
   identity.py1556657%31, 58–61, 65, 69–76, 79, 82–83, 86–87, 91, 95, 98, 106–107, 115, 117–121, 123, 125–126, 129, 133–137, 139–140, 143–148, 151–156, 159–161, 164, 197, 221–223, 238–240, 244, 247
TOTAL17682455974% 

Tests Skipped Failures Errors Time
2471 14 💤 0 ❌ 0 🔥 33.023s ⏱️

Copy link
Contributor

@ptoscano ptoscano left a comment

Choose a reason for hiding this comment

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

Should the same checks be added to managerlib.check_identity_cert_perms() as well?

Comment on lines +130 to +136
# Changing of owner can fail due to e.g. SELinux. When this
# operation fails, then we should only write error message,
# and we should create consumer cert.pem too
try:
os.chown(self.keypath(), 0, rhsm_group.gr_gid)
except OSError as err:
log.error(f"Unable to chown permissions of {self.keypath()}: {err}")
Copy link
Contributor

Choose a reason for hiding this comment

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

worth to factorize this to a small helper, as it is used in two places

try:
os.chown(self.keypath(), 0, rhsm_group.gr_gid)
except OSError as err:
log.error(f"Unable to chown permissions of {self.keypath()}: {err}")
os.chmod(self.keypath(), managerlib.ID_CERT_PERMS)
Copy link
Contributor

Choose a reason for hiding this comment

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

# Expected permissions for identity certificates:
ID_CERT_PERMS: int = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP

considering ID_CERT_PERMS also makes this group-readable: shouldn't this chmod() be done only if the chown() succeeds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants