~ A Rust client library for SMB ~
Get started · Crates.io · Documentation
Developed by @veeso
Current version: 0.2.3 (16/05/2023)
Pavão (/pɐ.ˈvɐ̃w̃/) is a Rust client library for SMB version 2 and 3 which exposes type-safe functions to interact with the C libsmbclient.
Pavão |> Pavé |> Animal Crossing |> Carnival |> Rio De Janeiro |> Samba |> SMB
toml
pavao = "0.2"
Install samba with brew:
sh
brew install samba
Install libsmbclient with apt:
sh
apt install -y libsmbclient-dev libsmbclient
⚠️ libsmbclient-dev
is required only on the machine where you build the application
Install libsmbclient with dnf:
sh
dnf install libsmbclient-devel libsmbclient
⚠️ libsmbclient-devel
is required only on the machine where you build the application
Install libsmbclient building from sources:
sh
wget -O samba.tar.gz https://github.com/samba-team/samba/archive/refs/tags/samba-4.16.1.tar.gz
mkdir -p samba/
tar xzvf samba.tar.gz -C samba/ --strip-components=1
rm samba.tar.gz
cd samba/
./configure
make
make install
cd ..
rm -rf samba/
```rust use pavao::{SmbClient, SmbCredentials, SmbOptions, SmbOpenOptions};
// Initialize a new client let client = SmbClient::new( SmbCredentials::default() .server(server) .share(share) .password(password) .username(username) .workgroup(workgroup), SmbOptions::default().oneshareperserver(true), ) .unwrap(); // do anything you want here with client let mut file = client.openwith("/abc/test.txt", SmbOpenOptions::default().read(true)).unwrap(); // read file... drop(file); // disconnect from server drop(client);
```
Two examples are provided along with this repository and can be found under the examples/
directory.
The tree
example can be used to get a fs tree of the smb share and can be run with:
sh
cargo run --example tree -- -u <username> -w <workspace> -s <share> -P <password> smb://<hostname>
while the transfer
example shows how to write a file to the remote host and can be run with:
sh
cargo run --example transfer -- -i <file_on_local> -o <file_to_write> -u <username> -w <workspace> -s <share> -P <password> smb://<hostname>
The developer documentation can be found on Rust Docs at https://docs.rs/pavao
If you like Pavão and you're grateful for the work I've done, please consider a little donation 🥳
You can make a donation with one of these platforms:
Contributions, bug reports, new features and questions are welcome! 😉 If you have any question or concern, or you want to suggest a new feature, or you want just want to improve pavao, feel free to open an issue or a PR.
Please follow our contributing guidelines
View Pavão's changelog HERE
Pavão is licensed under the GPLv3 license.
You can read the entire license HERE