Skip to content

Commit

Permalink
[#42] Add acl feature flag and deactive it by default
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Dec 15, 2023
1 parent 04e367f commit 6ac8c70
Show file tree
Hide file tree
Showing 28 changed files with 353 additions and 238 deletions.
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/eclipse-iceoryx/iceoryx2"
rust-version = "1.72.1"
version = "0.1.0"
version = "0.1.1"

[workspace.dependencies]
iceoryx2-bb-threadsafe = { version = "0.1.0", path = "iceoryx2-bb/threadsafe/" }
iceoryx2-bb-lock-free = { version = "0.1.0", path = "iceoryx2-bb/lock-free/" }
iceoryx2-bb-container = { version = "0.1.0", path = "iceoryx2-bb/container/" }
iceoryx2-bb-elementary = { version = "0.1.0", path = "iceoryx2-bb/elementary/" }
iceoryx2-bb-log = { version = "0.1.0", path = "iceoryx2-bb/log/" }
iceoryx2-bb-memory = { version = "0.1.0", path = "iceoryx2-bb/memory/" }
iceoryx2-bb-posix = { version = "0.1.0", path = "iceoryx2-bb/posix/" }
iceoryx2-bb-system-types = { version = "0.1.0", path = "iceoryx2-bb/system-types/" }
iceoryx2-bb-testing = { version = "0.1.0", path = "iceoryx2-bb/testing/" }
iceoryx2-bb-threadsafe = { version = "0.1.1", path = "iceoryx2-bb/threadsafe/" }
iceoryx2-bb-lock-free = { version = "0.1.1", path = "iceoryx2-bb/lock-free/" }
iceoryx2-bb-container = { version = "0.1.1", path = "iceoryx2-bb/container/" }
iceoryx2-bb-elementary = { version = "0.1.1", path = "iceoryx2-bb/elementary/" }
iceoryx2-bb-log = { version = "0.1.1", path = "iceoryx2-bb/log/" }
iceoryx2-bb-memory = { version = "0.1.1", path = "iceoryx2-bb/memory/" }
iceoryx2-bb-posix = { version = "0.1.1", path = "iceoryx2-bb/posix/" }
iceoryx2-bb-system-types = { version = "0.1.1", path = "iceoryx2-bb/system-types/" }
iceoryx2-bb-testing = { version = "0.1.1", path = "iceoryx2-bb/testing/" }

iceoryx2-pal-concurrency-sync = { version = "0.1.0", path = "iceoryx2-pal/concurrency-sync/" }
iceoryx2-pal-posix = { version = "0.1.0", path = "iceoryx2-pal/posix/" }
iceoryx2-pal-configuration = { version = "0.1.0", path = "iceoryx2-pal/configuration/" }
iceoryx2-pal-concurrency-sync = { version = "0.1.1", path = "iceoryx2-pal/concurrency-sync/" }
iceoryx2-pal-posix = { version = "0.1.1", path = "iceoryx2-pal/posix/" }
iceoryx2-pal-configuration = { version = "0.1.1", path = "iceoryx2-pal/configuration/" }

iceoryx2-cal = { version = "0.1.0", path = "iceoryx2-cal" }
iceoryx2-cal = { version = "0.1.1", path = "iceoryx2-cal" }

iceoryx2 = { version = "0.1.0", path = "iceoryx2/" }
iceoryx2 = { version = "0.1.1", path = "iceoryx2/" }

bindgen = { version = "0.65.1" }
bitflags = { version = "1.3.2" }
Expand Down
3 changes: 3 additions & 0 deletions iceoryx2-bb/posix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ repository = { workspace = true }
rust-version = { workspace = true }
version = { workspace = true }

[features]
acl = ["iceoryx2-pal-posix/acl"]

[dependencies]
iceoryx2-bb-container = { workspace = true }
iceoryx2-bb-system-types = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions iceoryx2-bb/posix/src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Create and read directory contents based on a POSIX api. It provides also advanced features
//! like [`Permission`] setting, use of [`crate::access_control_list::AccessControlList`] and
//! to be created from a [`FileDescriptor`]
//! like [`Permission`] setting and to be created from a [`FileDescriptor`]
//!
//! # Examples
//! ```
Expand Down
3 changes: 1 addition & 2 deletions iceoryx2-bb/posix/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Read, create, write or modify files based on a POSIX api. It provides also advanced features
//! like [`Permission`] setting, use of [`crate::access_control_list::AccessControlList`] and to
//! be created from a [`FileDescriptor`].
//! like [`Permission`] setting and to be created from a [`FileDescriptor`].
//!
//! # Examples
//! ```no_run
Expand Down
18 changes: 11 additions & 7 deletions iceoryx2-bb/posix/src/file_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
//! use iceoryx2_bb_container::semantic_string::SemanticString;
//! use iceoryx2_bb_posix::file_descriptor::*;
//! use iceoryx2_bb_posix::file::*;
//! #[cfg(feature = "acl")]
//! use iceoryx2_bb_posix::access_control_list::*;
//! use iceoryx2_bb_posix::ownership::*;
//! use iceoryx2_bb_posix::user::UserExt;
Expand All @@ -68,14 +69,18 @@
//! file.set_permission(Permission::ALL);
//!
//! // set some new ACLs
//! let mut acl = file.access_control_list().expect("failed to get acl");
//! acl.add_user("testUser2".as_user().unwrap().uid(), AclPermission::Read)
//! .expect("failed to add user");
//! file.set_access_control_list(&acl);
//! #[cfg(feature = "acl")]
//! {
//! let mut acl = file.access_control_list().expect("failed to get acl");
//! acl.add_user("testUser2".as_user().unwrap().uid(), AclPermission::Read)
//! .expect("failed to add user");
//! file.set_access_control_list(&acl);
//! }
//! ```

use std::fmt::Debug;

#[cfg(feature = "acl")]
use crate::access_control_list::*;
use crate::config::EINTR_REPETITIONS;
use crate::file::*;
Expand Down Expand Up @@ -249,9 +254,6 @@ impl FileDescriptorManagement for FileDescriptor {}
/// [`set_permission`](FileDescriptorManagement::set_permission())
/// * truncate size, [`truncate`](FileDescriptorManagement::truncate())
/// * accessing extended stats via [`Metadata`], [`metadata`](FileDescriptorManagement::metadata())
/// * access control list handling,
/// [`access_control_list`](FileDescriptorManagement::access_control_list())
/// [`set_access_control_list`](FileDescriptorManagement::set_access_control_list())
///
pub trait FileDescriptorManagement: FileDescriptorBased + Debug + Sized {
/// Returns the current user and group owner of the file descriptor
Expand Down Expand Up @@ -303,13 +305,15 @@ pub trait FileDescriptorManagement: FileDescriptorBased + Debug + Sized {
}

/// Returns the current access control list
#[cfg(feature = "acl")]
fn access_control_list(
&self,
) -> Result<AccessControlList, AccessControlListCreationFromFdError> {
AccessControlList::from_file_descriptor(unsafe { self.file_descriptor().native_handle() })
}

/// Sets a new access control list
#[cfg(feature = "acl")]
fn set_access_control_list(
&self,
acl: &AccessControlList,
Expand Down
24 changes: 24 additions & 0 deletions iceoryx2-bb/posix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

//! Abstraction of POSIX constructs with a safe API

#[cfg(feature = "acl")]
use access_control_list::AccessControlListError;
use barrier::BarrierCreationError;
use clock::ClockError;
Expand All @@ -31,6 +32,7 @@ use thread::ThreadError;
use unix_datagram_socket::UnixDatagramError;
use user::UserError;

#[cfg(feature = "acl")]
pub mod access_control_list;
pub mod access_mode;
pub mod adaptive_wait;
Expand Down Expand Up @@ -70,6 +72,7 @@ pub mod unix_datagram_socket;
pub mod unmovable_ipc_handle;
pub mod user;

#[cfg(feature = "acl")]
enum_gen! {Error
generalization:
AccessControlList <= AccessControlListError,
Expand All @@ -90,3 +93,24 @@ enum_gen! {Error
User <= UserError,
UnixDatagramSocket <= UnixDatagramError
}

#[cfg(not(feature = "acl"))]
enum_gen! {Error
generalization:
Barrier <= BarrierCreationError,
Clock <= ClockError,
Directory <= DirectoryError,
File <= FileError,
FileLock <= FileLockError,
Group <= GroupError,
MemoryLock <= MemoryLockError,
Mutex <= MutexError,
Process <= ProcessError,
ReadWriteMutex <= ReadWriteMutexError,
Semaphore <= SemaphoreError,
SharedMemory <= SharedMemoryCreationError,
Signal <= SignalError,
Thread <= ThreadError,
User <= UserError,
UnixDatagramSocket <= UnixDatagramError
}
Loading

0 comments on commit 6ac8c70

Please sign in to comment.