Skip to content

Commit

Permalink
fix: handling samba BadFileDescriptor error (ref #38)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Feb 13, 2024
1 parent 0c43394 commit 3381b1a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/plugins/samba/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@ impl SMB {

let server = format!("smb://{}", target);
let root_cli = self.get_samba_client(&server, &self.workgroup, "", "", "")?;
for entry in root_cli.list_dir("").unwrap() {
match entry.get_type() {
SmbDirentType::FileShare | SmbDirentType::Dir => {
let share = format!("/{}", entry.name());
// if share is private we expect an error
let sub_cli =
self.get_samba_client(&server, &self.workgroup, &share, "", "")?;
let listing = sub_cli.list_dir("");
if listing.is_err() {
log::info!("{}{} found", &server, &share);
// found a private share, update the cache and return.
guard.insert(target.to_owned(), share.clone());
return Ok(share);

if let Ok(entries) = root_cli.list_dir("") {
for entry in entries {
match entry.get_type() {
SmbDirentType::FileShare | SmbDirentType::Dir => {
let share = format!("/{}", entry.name());
// if share is private we expect an error
let sub_cli =
self.get_samba_client(&server, &self.workgroup, &share, "", "")?;
let listing = sub_cli.list_dir("");
if listing.is_err() {
log::info!("{}{} found", &server, &share);
// found a private share, update the cache and return.
guard.insert(target.to_owned(), share.clone());
return Ok(share);
}
}
_ => {}
}
_ => {}
}
}

Expand Down

0 comments on commit 3381b1a

Please sign in to comment.