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

Cleanup keyutils types and api.rs #29

Merged
merged 5 commits into from
Jun 28, 2019
Merged

Conversation

josephlr
Copy link
Contributor

@josephlr josephlr commented Jun 25, 2019

This patchset makes many changes in preparation for fixing issue #24 (to no longer need libkeyutils). Doing everything in one PR would be very large, so this PR is just all of the internal cleanup that doesn't change the external API of keyutils.

Specifically:

  • libkeyutils-sys is moved to keyutils-raw (and version is updated to match keyutils)
  • Adds KEY_TYPE_KEYRING and KEY_TYPE_BIG_KEY (as they are in the kernel documentation).
  • As the key/keyring ID can never be zero, the type of a key id is changed from i32 to NonZeroI32.
  • This makes Rust 1.34 keyutils's minimal version.
  • In keyutils-raw: change key_serial_t to just be KeyringSerial, which is then just reexported by keyutils.
  • In keyutils-raw: change key_perm_t to just be KeyPermissions, which is then just reexported by keyutils.
  • Remove KEY_REQKEY_DEFL_* constants. Instead, DefaultKeyring in keyutils-raw just has enum values with these constants (it is also just reexported to keyutils).
  • Cleanup internal helper methods in api.rs to use the new types. I also simplified the internal *_impl and check_ methods. This is the largest part of the PR, but is mostly just a find/replace.

Again, note that we continue linking libkeyutils, and this only ends up with a very tiny change to the external API:

  • DefaultKeyring:
    • no longer has a serial() method
    • Implements TryFrom<libc::c_long> instead of From<i32>

@mathstuf
Copy link
Owner

Thanks for all the work this past week! Once this is rebased, I'll take a closer look at it now that the other PRs have been merged.

@josephlr
Copy link
Contributor Author

Thanks for all the work this past week! Once this is rebased, I'll take a closer look at it now that the other PRs have been merged.

Done, and let me know if you want to split this up. I've also revised the PR's description to be more accurate.

Copy link
Owner

@mathstuf mathstuf left a comment

Choose a reason for hiding this comment

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

Just worried about kernel upgrades sliding in panics without changing the code when a new default keyring value is added. Looks great otherwise.

keyutils-raw/src/types.rs Outdated Show resolved Hide resolved
src/api.rs Show resolved Hide resolved
keyutils-raw/src/functions.rs Show resolved Hide resolved
keyutils-raw/src/functions.rs Show resolved Hide resolved
@mathstuf mathstuf merged commit cbd4ba8 into mathstuf:master Jun 28, 2019
@mathstuf
Copy link
Owner

Thanks!

@josephlr josephlr deleted the type branch June 28, 2019 19:16
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