-
Notifications
You must be signed in to change notification settings - Fork 27
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
Clean up and expand tests #115
base: master
Are you sure you want to change the base?
Changes from all commits
dbd1eb7
9d8418e
8ffcf4d
cefa483
fd2b192
95ce1e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
out | ||
**/*.rpm | ||
Cargo.lock | ||
!test_assets/* | ||
!tests/assets/** | ||
dnf-cache | ||
.idea | ||
.idea |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ use std::{ | |
use super::*; | ||
use crate::{constants::*, errors::*, Timestamp}; | ||
|
||
#[derive(Debug, PartialEq)] | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct Header<T: Tag> { | ||
pub(crate) index_header: IndexHeader, | ||
pub(crate) index_entries: Vec<IndexEntry<T>>, | ||
|
@@ -395,8 +395,8 @@ pub struct FileOwnership { | |
|
||
#[derive(Debug, Clone, Hash, Eq, PartialEq)] | ||
pub struct FileDigest { | ||
digest: String, | ||
algo: DigestAlgorithm, | ||
pub digest: String, | ||
pub algo: DigestAlgorithm, | ||
} | ||
|
||
impl FileDigest { | ||
|
@@ -508,7 +508,7 @@ fn parse_binary_entry( | |
} | ||
|
||
/// A header keeping track of all other header records. | ||
#[derive(Debug, PartialEq)] | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub(crate) struct IndexHeader { | ||
/// rpm specific magic header | ||
pub(crate) magic: [u8; 3], | ||
|
@@ -575,7 +575,7 @@ impl IndexHeader { | |
} | ||
|
||
/// A single entry within the [`IndexHeader`](self::IndexHeader) | ||
#[derive(PartialEq)] | ||
#[derive(Clone, PartialEq, Eq)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add these unless necessary, particularly because the type is internal. For external types I think they're valid addenda |
||
pub(crate) struct IndexEntry<T: num::FromPrimitive> { | ||
pub(crate) tag: u32, | ||
pub(crate) data: IndexData, | ||
|
@@ -678,7 +678,7 @@ impl<T: Tag> fmt::Display for IndexEntry<T> { | |
} | ||
|
||
/// Data as present in a [`IndexEntry`](self::IndexEntry) . | ||
#[derive(Debug, PartialEq, Eq)] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub(crate) enum IndexData { | ||
Null, | ||
Char(Vec<u8>), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,50 @@ pub const REGULAR_FILE_TYPE: u16 = 0o100000; // bit representation = "100000000 | |
pub const DIR_FILE_TYPE: u16 = 0o040000; // bit representation = "0100000000000000" | ||
pub const SYMBOLIC_LINK_FILE_TYPE: u16 = 0o120000; // bit representation = "1010000000000000" | ||
|
||
// @todo: <https://github.com/rpm-rs/rpm/issues/52> | ||
use bitflags::bitflags; | ||
|
||
// typedef enum rpmFileTypes_e { | ||
// = 1, /*!< pipe/fifo */ | ||
// CDEV = 2, /*!< character device */ | ||
// XDIR = 4, /*!< directory */ | ||
// BDEV = 6, /*!< block device */ | ||
// REG = 8, /*!< regular file */ | ||
// LINK = 10, /*!< hard link */ | ||
// SOCK = 12 /*!< socket */ | ||
// } rpmFileTypes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we represent this as another bitfield? |
||
|
||
bitflags! { | ||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] | ||
pub struct FileModeFlags: u16 { | ||
const PERMISSIONS_BIT_MASK = 0b0000111111111111; // 0o007777 | ||
|
||
const SUID_BIT_MASK = 0b0000100000000000; // 0o007777 | ||
const SGID_BIT_MASK = 0b0000010000000000; // 0o007777 | ||
const STICKY_BIT_MASK = 0b0000001000000000; // 0o007777 | ||
|
||
const USER_PERM_BIT_MASK = 0b0000000111000000; // 0o007777 | ||
const GROUP_PERM_BIT_MASK = 0b0000000000111000; // 0o007777 | ||
const OTHER_PERM_BIT_MASK = 0b0000000000000111; | ||
|
||
// The set-user-ID bit (setuid bit). | ||
|
||
// On execution, set the process’s effective user ID to that of the file. For directories on a few systems, give files created in the directory the same owner as the directory, no matter who creates them, and set the set-user-ID bit of newly-created subdirectories. | ||
// The set-group-ID bit (setgid bit). | ||
|
||
// On execution, set the process’s effective group ID to that of the file. For directories on most systems, give files created in the directory the same group as the directory, no matter what group the user who creates them is in, and set the set-group-ID bit of newly-created subdirectories. | ||
// The restricted deletion flag or sticky bit. | ||
|
||
// Prevent unprivileged users from removing or renaming a file in a directory unless they own the file or the directory; this is commonly found on world-writable directories like /tmp. For regular files on some older systems, save the program’s text image on the swap device so it will load more quickly when run, so that the image is “sticky”. | ||
|
||
const FILE_TYPE_BIT_MASK = 0b1111000000000000; // 0o170000 | ||
const REGULAR_FILE_TYPE = 0b1000000000000000; // 0o100000 | ||
const DIR_FILE_TYPE = 0b0100000000000000; // 0o040000 | ||
const SYMBOLIC_LINK_FILE_TYPE = 0b1010000000000000; // 0o120000 | ||
} | ||
} | ||
|
||
|
||
|
||
impl From<u16> for FileMode { | ||
fn from(raw_mode: u16) -> Self { | ||
// example | ||
|
@@ -522,7 +565,6 @@ impl<W: std::io::Write> std::io::Write for Sha256Writer<W> { | |
} | ||
|
||
/// Type-alias for a tuple containing index tags for a scriptlet type, | ||
/// | ||
pub(crate) type ScriptletIndexTags = (IndexTag, IndexTag, IndexTag); | ||
|
||
/// Description of a scriptlet as present in a RPM header record | ||
|
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.
Please provide accessor methods and mark these as
pub(crate)