Add support for multi-token management in SmartCardUtils#239
Add support for multi-token management in SmartCardUtils#239krishnavema wants to merge 1 commit intoSSSD:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly extends the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for managing multiple smart card tokens by introducing initialize_additional_token to create new tokens without wiping existing ones, and register_for_p11_child to make them visible to p11_child. The add_cert and add_key methods are also updated to allow targeting a specific token. The changes are logical, but I have a couple of suggestions to improve maintainability and security. I've identified some code duplication that could be refactored and an instance of overly permissive file permissions that should be tightened.
| args: CLIBuilderArgs = { | ||
| "label": (self.cli.option.VALUE, label), | ||
| "free": (self.cli.option.SWITCH, True), | ||
| "so-pin": (self.cli.option.VALUE, so_pin), | ||
| "pin": (self.cli.option.VALUE, user_pin), | ||
| } | ||
| self.host.conn.run( | ||
| self.cli.command("softhsm2-util --init-token", args), env={"SOFTHSM2_CONF": self.SOFTHSM2_CONF_PATH} | ||
| ) |
There was a problem hiding this comment.
The logic for building arguments and calling softhsm2-util --init-token in this new method is identical to the one in the initialize_card method (lines 69-77). This code duplication should be avoided by extracting the common logic into a private helper method. This will improve code maintainability.
| f"> /etc/systemd/system/sssd.service.d/softhsm.conf" | ||
| ) | ||
| self.host.conn.run("systemctl daemon-reload") | ||
| self.host.conn.run("chmod -R o+rX /opt/test_ca/") |
There was a problem hiding this comment.
The command chmod -R o+rX /opt/test_ca/ grants read permissions to all files under /opt/test_ca/ to all users on the system, which is overly permissive. While this is a test environment, it's better to apply the principle of least privilege. A more precise command would only grant the necessary permissions, for example by only allowing traversal of the directory and read access to the configuration file.
| self.host.conn.run("chmod -R o+rX /opt/test_ca/") | |
| self.host.conn.run(f"chmod o+x /opt/test_ca && chmod o+r {conf}") |
No description provided.