libsmb2, meet samba

ronnie sahlberg ronniesahlberg at gmail.com
Wed Jan 25 03:31:33 UTC 2017


samba, please meet libsmb2
libsmb2 please meet samba


As you know already I am am for various reasons, to benefit linux, working on a
smb2 client library.

https://github.com/sahlberg/libsmb2


Why, and what requirements?
----------------------------------------
I want there to be a highly portable and free smb2 client that any/all
applications can use.

It should be small and nimble. Currently clocks in at ~50kb compiled
(though that excludes MIT kerberos).

$ ls -l lib/.libs/libsmb2.a -rw-rw-r-- 1 sahlberg sahlberg 54188 Jan
24 17:40 lib/.libs/libsmb2.a

It should need very few external dependencies. Right now I target
basic posix libc plus MIT. Nothing else.

It should be so portable that it compiles native on both Win32/64 as
well as Amiga Kickstart 1.3.

It should provide an API similar to libnfs so that porting between nfs
and smb wrappers should be as painless as possible.

SMB2+ only. No smb1 support. RDMA support will be nice to add in the future.

Zero-copy for [p]read/[p]write.


Also, I have been a bit bored recently and what better reason for
building a lightweight SMB2 client? Boredom is the fuel for
innovation.


Licence
----------
For licence, gnu licences lgplv2.1 only or lgpl2.1-plus are
acceptable. QMU licence compatibility is not negotiable. (Make me
angry and I will consider 2-clause BSD, or worse :-) )
Nah lgpl2.1 is fine :-)

Kodi support is kind of not negotiable as well, but they are
compatible with a lot mode different licences so that should not be an
issue.



Current status
-------------------
The codebase is in hue flux and will need a major refactoring and also
audits over the next few weeks until the implementation as well as the
APIs will settle down.

Mimicing the libnfs APIs it provides fair coverage of the common posix
file api already:
smb2_close
smb2_close_async
smb2_closedir
smb2_cmd_close_async
smb2_cmd_create_async
smb2_cmd_echo_async
smb2_cmd_logoff_async
smb2_cmd_negotiate_async
smb2_cmd_query_directory_async
smb2_cmd_query_info_async
smb2_cmd_session_setup_async
smb2_cmd_tree_connect_async
smb2_connect_async
smb2_connect_share
smb2_connect_share_async
smb2_destroy_context
smb2_destroy_url
smb2_fstat
smb2_fstat_async
smb2_get_client_guid
smb2_get_error
smb2_get_fd
smb2_init_context
smb2_mkdir
smb2_mkdir_async
smb2_open
smb2_open_async
smb2_opendir
smb2_opendir_async
smb2_parse_url
smb2_pread
smb2_pread_async
smb2_pwrite
smb2_pwrite_async
smb2_read
smb2_read_async
smb2_readdir
smb2_rewinddir
smb2_rmdir
smb2_rmdir_async
smb2_seek
smb2_seekdir
smb2_service
smb2_set_security_mode
smb2_stat
smb2_stat_async
smb2_telldir
smb2_unlink
smb2_unlink_async
smb2_which_events
smb2_write
smb2_write_async

Not complete yet but sufficient for building a filemanager or something similar.

It uses MIT + simo's GSS-NLTMSSP for authentication. It does not yet
do actual sign or seal
but I think that is low priority for the initial version. Patches welcome.

It leaks memory from the gss contexts that are used during session
setup. Again patches welcome as I am completely ignorant about MIT and
its GSS layer, and wish to remain so as I am too old and lazy to learn
new stuff.


These funcitons work pretty well and even run valgrind clean (aside
from the two leaks form the mis-use of the MIT library).
Woohoo for that.


Qemu and Kodi and all the other users of libnfs
---------------------------------------------------------------
It supports all the posix fs functions that any of those apps use
today for libnfs so it should be fairly easy for those folks to take
theur libnfs wrappers, do some sed-magic and end up with an almost
functional smb2 wrapper.

Easy porting from libnfs to libsmb2 is another requirement that I just made up.


Examples
-------------
There are a bunch of examples in the examples subdirectory to show the
async as well as the sync api. Please have look.


Fire extinguisher
----------------------
This is not a replacement for libsmbclient. This is aimed as a minimal
library that is
easy to port and use. With limited functionality but an alternative to
those apps that just need the most basic smb2 support and where
libsmb2 client is overkill.

Well, on amiga Kickstart 1.3 it might be a replacement as I doubt
anyone wants to port non-extremely-ancient versions of libsmbclient to
the amiga.



Interested?
---------------
It is functional right now. More posix function emulation is needed.
It probably need a re-write and re-factor as well as the internal APIs
settle down.

Want to help out? Contact me and check out the github.
Contacting me first before starting to prepare any pull requests. I
expect that the code base will
be in major flux for the next few weeks until things stabilize.

There is a lot of work that still needs doing.


Where to host?
--------------------
I kind of like github/sahlberg as your on-stop-shop for everything
related to network storage client software.
However, hosting this on samba.org at some stage might be a better choice.

You open for that idea?





regards, your friend in the file/block client space
ronnie sahlberg



More information about the samba-technical mailing list