Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ categories = ["os::linux-apis", "os", "api-bindings"]
repository = "https://github.com/bilelmoussaoui/oo7"
homepage = "https://github.com/bilelmoussaoui/oo7"
license = "MIT"
rust-version = "1.86"
rust-version = "1.88"
exclude = ["org.freedesktop.Secrets.xml"]

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion client/src/file/api/legacy_keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl Keyring {
if size > cursor.get_ref()[pos..].len() {
return Err(Error::NoData);
}
if size % 16 != 0 {
if !size.is_multiple_of(16) {
size = (size / 16) * 16;
}
let encrypted_content = Vec::from(&cursor.get_ref()[pos..pos + size]);
Expand Down
1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ allow = [

[sources]
allow-git = [
"https://github.com/bilelmoussaoui/ashpd"
]

[bans]
Expand Down
45 changes: 19 additions & 26 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,25 @@ pub fn derive_secret_schema(input: TokenStream) -> TokenStream {
/// Extract the schema name from #[schema(name = "...")] attribute
fn extract_schema_name(attrs: &[syn::Attribute]) -> Option<String> {
for attr in attrs {
if attr.path().is_ident("schema") {
if let Meta::List(meta_list) = &attr.meta {
if let Ok(name_value) = meta_list.parse_args::<MetaNameValue>() {
if name_value.path.is_ident("name") {
if let syn::Expr::Lit(expr_lit) = &name_value.value {
if let Lit::Str(lit_str) = &expr_lit.lit {
return Some(lit_str.value());
}
}
}
}
}
if attr.path().is_ident("schema")
&& let Meta::List(meta_list) = &attr.meta
&& let Ok(name_value) = meta_list.parse_args::<MetaNameValue>()
&& name_value.path.is_ident("name")
&& let syn::Expr::Lit(expr_lit) = &name_value.value
&& let Lit::Str(lit_str) = &expr_lit.lit
{
return Some(lit_str.value());
}
}
None
}

/// Check if a type is Option<T>
fn is_option_type(ty: &Type) -> bool {
if let Type::Path(TypePath { path, .. }) = ty {
if let Some(segment) = path.segments.last() {
return segment.ident == "Option";
}
if let Type::Path(TypePath { path, .. }) = ty
&& let Some(segment) = path.segments.last()
{
return segment.ident == "Option";
}
false
}
Expand All @@ -210,16 +206,13 @@ fn is_option_type(ty: &Type) -> bool {
/// with is_option_type(). If called with a non-Option type, it will cause a
/// compile error in the generated code.
fn extract_option_inner_type(ty: &Type) -> &Type {
if let Type::Path(TypePath { path, .. }) = ty {
if let Some(segment) = path.segments.last() {
if segment.ident == "Option" {
if let syn::PathArguments::AngleBracketed(args) = &segment.arguments {
if let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first() {
return inner_ty;
}
}
}
}
if let Type::Path(TypePath { path, .. }) = ty
&& let Some(segment) = path.segments.last()
&& segment.ident == "Option"
&& let syn::PathArguments::AngleBracketed(args) = &segment.arguments
&& let Some(syn::GenericArgument::Type(inner_ty)) = args.args.first()
{
return inner_ty;
}
// This should never be reached if is_option_type() returned true
// Return the original type as a fallback - this will cause a compile error
Expand Down
10 changes: 5 additions & 5 deletions pam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ pub unsafe extern "C" fn pam_sm_open_session(
let arg_ptr = unsafe { *argv.offset(i as isize) };
if !arg_ptr.is_null() {
let arg_cstr = unsafe { CStr::from_ptr(arg_ptr) };
if let Ok(arg_str) = arg_cstr.to_str() {
if arg_str == "auto_start" {
auto_start = true;
tracing::debug!("auto_start argument detected");
}
if let Ok(arg_str) = arg_cstr.to_str()
&& arg_str == "auto_start"
{
auto_start = true;
tracing::debug!("auto_start argument detected");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions server/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ pub fn drop_unnecessary_capabilities() -> Result<(), rustix::io::Errno> {
}

// Clear bounding set if we have CAP_SETPCAP (do this before dropping caps)
if caps.effective.contains(CapabilitySet::SETPCAP) {
if let Err(err) = set_bounding_set(CapabilitySet::IPC_LOCK) {
tracing::warn!("Failed to set bounding set: {}", err);
}
if caps.effective.contains(CapabilitySet::SETPCAP)
&& let Err(err) = set_bounding_set(CapabilitySet::IPC_LOCK)
{
tracing::warn!("Failed to set bounding set: {}", err);
}

set_capabilities(
Expand Down
8 changes: 4 additions & 4 deletions server/src/collection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ impl Collection {
Ok(unlocked) => unlocked,
Err(err) => {
// Reload the locked keyring from disk before returning error
if let Some(path) = keyring_path {
if let Ok(reloaded) = oo7::file::LockedKeyring::load(&path).await {
*keyring_guard = Some(Keyring::Locked(reloaded));
}
if let Some(path) = keyring_path
&& let Ok(reloaded) = oo7::file::LockedKeyring::load(&path).await
{
*keyring_guard = Some(Keyring::Locked(reloaded));
}
return Err(custom_service_error(&format!(
"Failed to unlock keyring: {err}"
Expand Down
14 changes: 7 additions & 7 deletions server/src/item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ impl Item {
let signal_emitter = self.service.signal_emitter(&self.collection_path)?;
Collection::item_changed(&signal_emitter, &self.path).await?;

if let Ok(signal_emitter) = self.service.signal_emitter(&self.path) {
if let Err(err) = self.modified_changed(&signal_emitter).await {
tracing::error!(
"Failed to emit PropertiesChanged signal for Modified: {}",
err
);
}
if let Ok(signal_emitter) = self.service.signal_emitter(&self.path)
&& let Err(err) = self.modified_changed(&signal_emitter).await
{
tracing::error!(
"Failed to emit PropertiesChanged signal for Modified: {}",
err
);
}

Ok(())
Expand Down
25 changes: 12 additions & 13 deletions server/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,10 +994,10 @@ impl Service {
// assumes all items are from the same collection
if let Some(path_str) = objects.first().and_then(|p| p.as_str().rsplit_once('/')) {
let collection_path = path_str.0;
if let Ok(obj_path) = ObjectPath::try_from(collection_path) {
if let Some(collection) = self.collection_from_path(&obj_path).await {
return collection.label().await;
}
if let Ok(obj_path) = ObjectPath::try_from(collection_path)
&& let Some(collection) = self.collection_from_path(&obj_path).await
{
return collection.label().await;
}
}

Expand Down Expand Up @@ -1102,18 +1102,17 @@ impl Service {
.await
.insert(collection_path.clone(), collection.clone());

if alias == oo7::dbus::Service::DEFAULT_COLLECTION {
if let Err(e) = self
if alias == oo7::dbus::Service::DEFAULT_COLLECTION
&& let Err(e) = self
.object_server()
.at(DEFAULT_COLLECTION_ALIAS_PATH, collection)
.await
{
tracing::error!(
"Failed to register default alias for migrated collection '{}': {}",
name,
e
);
}
{
tracing::error!(
"Failed to register default alias for migrated collection '{}': {}",
name,
e
);
}

if let Ok(signal_emitter) =
Expand Down
Loading