Skip to content

Commit c5caddf

Browse files
author
Rain Oksvort
committed
Update readme
1 parent 081ac97 commit c5caddf

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
vfs_python
2-
==========
1+
# vfs_python
32

4-
An experimental Samba module which lets you control execution of Samba actions in your own Python script.
3+
An experimental Samba module which lets you control execution of Samba actions in your own Python script. The aim of this this project is to rather offer a sample vfs module for those who find Samba's documentation difficult to follow than to be fully functional production ready module. Currently I do not plan to offer constant updates nor compile it for every Samba version.
54

6-
Installation
7-
------------
8-
You must have the Python headers installed (`python-dev`) and the Samba sourcecode lying around.
5+
## Compiling
96

10-
Clone this repository, then compile as follows:
7+
At the time of updating this code I used Debian 12 and Samba 4.17.12 which used Python 3.11. Both Samba and vfs_python were extracted to my home directory. You may have to adjust those commands to fit for your needs
8+
9+
1. Setup build environment.
1110
```sh
12-
./configure --enable-debug --enable-developer --with-samba-source=/path/to/samba/source3
13-
# or
14-
./configure --with-samba-source=$HOME/samba-4.17.12/source3
11+
wget https://gitlab.com/samba-team/samba/-/raw/master/bootstrap/generated-dists/debian12/bootstrap.sh
12+
chmod +x bootstrap.sh
13+
./bootstrap.sh
14+
```
1515

16+
2. Make Samba
17+
```sh
18+
wget https://download.samba.org/pub/samba/stable/samba-4.17.12.tar.gz
19+
tar -zxf samba-4.17.12.tar.gz
20+
cd samba-4.17.12
21+
./configure
1622
make
1723
```
1824

19-
Copy / symlink the resulting `vfs_python.so` to `/usr/local/samba/lib/vfs/python.so` (or wherever your VFS modules are).
25+
3. Make this vfs_python module
26+
```sh
27+
git clone https://github.com/rain1/vfs_python.git
28+
cd $HOME/vfs_python
29+
./configure --with-samba-source=$HOME/samba-4.17.12/source3
30+
make
31+
```
32+
33+
## Installation
34+
35+
1. Either download already compiled `vfs_python.so` from releases page or compile it yourself.
2036

21-
In your `smb.conf`, enable `vfs_python` per share:
37+
2. Copy / symlink the resulting `vfs_python.so` to `/usr/lib/x86_64-linux-gnu/samba/vfs/python.so` (or wherever your VFS modules are).
38+
39+
3. In your `smb.conf`, enable `vfs_python` per share:
2240
```ini
2341
[global]
24-
log level = 5 # Debug in C code can on beconfigured from [global]
42+
log level = 5 # If you want to see log that debug method in python script produces
2543
[myshare]
2644
path = /tmp
2745
vfs objects = python
@@ -30,14 +48,15 @@ In your `smb.conf`, enable `vfs_python` per share:
3048

3149
and make sure that the script path is valid.
3250

33-
The Python code
34-
---------------
35-
Take a look at [the `handler.py`](https://github.com/vortec/vfs_python/blob/master/handler.py) to see how it looks like and which Samba calls are supported at the moment (hint: not too many).
51+
## The Python code
52+
53+
Take a look at [the `handler.py`](https://github.com/vortec/vfs_python/blob/master/handler.py) to see how it looks like and which Samba calls are supported at treinvent the wheel.he moment (hint: not too many).
3654

3755
When a user performs an action, the corresponding Python function will be called. You can either allow or deny that action by returning a boolean.
3856

3957
The Python script will be imported every time a user connects and is valid for the duration of the connection.
4058

41-
Current status
42-
--------------
59+
`debug` function that us used in `handler.py` is defined in `python_importer.c` which is why IDEs think it is undefined. Reason for that is that now Samba itself will take care of logging instead of python script having to reinvent the wheel.
60+
61+
## Current status
4362
This is experimental, my C skills have plenty of room for improvement and if your Python code raises an exception the Samba daemon will crash. I plan to address all those things, but right now it is what it is. Any contribution is greatly appreciated. :)

0 commit comments

Comments
 (0)