Add acl support to libpna#2671
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @ChanTsune, 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 enhances the Highlights
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 introduces support for Access Control Lists (ACLs) in libpna. A new acl module is added with data structures for representing ACLs from different platforms (POSIX, macOS, Windows, NFSv4) in a unified format. The changes include a new fACL chunk type, and integration into NormalEntry for serialization and deserialization.
The implementation is comprehensive, but I've found a few critical issues:
- The
EntryBuilderis missing a public API to add ACLs, which makes the feature unusable when building new entries. - The
AceFlagbitflags use overlapping values for different platforms, which is error-prone. - There's a potential for a panic when serializing an
Aclwith a large number of entries.
I've left specific comments with suggestions on how to address these points. Additionally, a new test file for verifying Windows ACL constant values is a great addition for ensuring correctness.
| impl Acl { | ||
| #[inline] | ||
| pub(crate) fn to_bytes(&self) -> Vec<u8> { | ||
| let entry_count = self.entries.len() as u16; |
There was a problem hiding this comment.
The conversion self.entries.len() as u16 will panic with an overflow if the number of entries exceeds 65,535. While a very large number of ACEs is unlikely, it's safer to handle this case gracefully. Since this function doesn't return a Result, an explicit check with expect is a good way to provide a more informative panic message.
| let entry_count = self.entries.len() as u16; | |
| let entry_count = u16::try_from(self.entries.len()) | |
| .expect("number of ACL entries should not exceed u16::MAX"); |
e626a43 to
1a6c195
Compare
fd14591 to
4a53c7d
Compare
Introduces the AclPlatform enum in a new acl module to represent different ACL platforms. Updates lib.rs to include the new acl module. Introduces ACL-related enums, structs, and bitflags for permissions and flags in acl.rs. Updates lib.rs to properly declare the acl module, laying groundwork for ACL support.
- Add TryFrom<u8> for AceType to allow byte conversion - Add ace_type field to Ace struct with serialization support - Add Ace::new() constructor for creating access control entries - Add Acl::new() constructor for creating access control lists - Add EntryBuilder::add_acl() method to add ACLs to entries
4a53c7d to
8d5ba8e
Compare
No description provided.