-
Notifications
You must be signed in to change notification settings - Fork 119
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
base: main
Are you sure you want to change the base?
Conversation
jirihnidek
commented
Oct 18, 2024
- 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
Coverage (computed on Fedora latest) •
|
There was a problem hiding this 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?
# 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}") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?