sahlberg / libsmb2 Goto Github PK
View Code? Open in Web Editor NEWSMB2/3 userspace client
License: Other
SMB2/3 userspace client
License: Other
Libsmb2 is a userspace client library for accessing SMB2/SMB3 shares on a network. It is high performance and fully async. It supports both zero-copy for SMB READ/WRITE commands as well as compounded commands. Libsmb2 is distributed under the LGPLv2.1 licence. API === Libsmb2 implements three different APIs for accessing remote SMB shares : 1, High level synchronous posix-like API. This is a simple API for accessing a share. The functions in this API are modelled to be be similar to the corresponding POSIX functions. This API is described in libsmb.h 2, High level async posix-like API. This is a high performance, fully non-blocking and async API. The functions in this API are modelled to be be similar to the corresponding POSIX functions. This is the recommended API. This API is described in libsmb.h 3, Low level async RAW API. This is a low level API that provides direct access to the SMB2 PDUs and data structures. This API is described in libsmb-raw.h SMB URL Format ============== The SMB URL format is currently a small subset of the URL format that is defined/used by the Samba project. The goal is to eventually support the full URL format, thus making URLs interchangeable between Samba utilities and Libsmb2 but we are not there yet. smb://[<domain>;][<user>@]<server>[:<port>]/<share>[/path][?arg=val[&arg=val]*] <server> is either a hostname, an IPv4 or an IPv6 address. Arguments supported by libsmb2 are : sec=<mech> : Mechanism to use to authenticate to the server. Default is any available mech, but can be overridden by : krb5: Use Kerberos using credentials from kinit. krb5cc: Use Kerberos using credentials from credentials cache. ntlmssp : Only use NTLMSSP vers=<version> : Which SMB version to negotiate: 2: Negotiate any version of SMB2 3: Negotiate any version of SMB3 2.02, 2.10, 3.00, 3.02, 3.1.1 : negotiate a specific version. Default is to negotiate any SMB2 or SMB3 version. seal : Enable SMB3 encryption. sign : Require SMB2/3 signing. timeout : Timeout in seconds when to cancel a command. Default it 0: No timeout. NOTE:- When using krb5cc mode use smb2_set_domain() and smb2_set_password() in the examples and applications Authentication ============== Libsmb2 provides has builtin support for NTLMSSP username/password authentication. It can also, optionally, be built with (MIT) Kerberos authentication. Libsmb2 will try to build with Kerberos if these libraries are present. You can force a build without Kerberos support by using the flag --without-libkrb5 to configure. In this case only NTLMSSP authentication will be available. MIT KERBEROS ============ Authentication is implemented using MIT Kerberos and it supports both KRB5 for authentication against Active Directory as well as NTLMSSP (optional). MIT Kerberos can be configured to also provide NTLMSSP authentication, as an alternative to the builtin NTLMSSP implementation using an external mech plugin. To use this Kerberos/NTLMSSP module you will need to build and install GSS-NTLMSSP from [https://github.com/simo5/gss-ntlmssp] If you are uncertain you can skip this module and just use the NTLMSSP module that is provided by libsmb2. NTLM Authentication ------------------- NTLM credentials are stored in a text file of the form : DOMAIN:USERNAME:PASSWORD with one line per username. You need to set up the environment variable NTLM_USER_FILE to point to this file. You need one entry in this file for each local user account you want to be able to use libsmb2 for accessing a remote share. By default, NTLM authentication will use the username for the current process. This can be overridden by specifying a different username in the SMB URL : smb://guest@server/share?sec=ntlmssp KRB5 Authentication ------------------- Kerberos authentication can be used when the linux workstation as well as the file server are part of Active Directory. You should be able to authenticate to the file server using krb5 by specifying sec=krb5 in the URL : smb://server/share?sec=krb5 The application needs to set the username, password and the domain fqdn in the context using smb2_set_user(), smb2_set_password() and smb2_set_domain() respectively. NTLM Credentials ================ This applies to both the builtin NTLMSSP implementation as well as when using Kerberos with the NTLMSSP mech plugin. NTLM credentials are stored in a text file of the form : DOMAIN:USERNAME:PASSWORD with one line per username. You need to set up the environment variable NTLM_USER_FILE to point to this file. You need one entry in this file for each local user account you want to be able to use libsmb2 for accessing a remote share. By default, NTLM authentication will use the username for the current process. This can be overridden by specifying a different username in the SMB URL : smb://guest@server/share?sec=ntlmssp Alternatively you can provide the username and password from your application by calling : smb2_set_user(smb2, <username>); smb2_set_password(smb2, <password>); SMB2/3 SIGNING ============== Signing is supported with KRB5, with the builtin ntlmssp support and with gss-ntlmssp mech plugin. SMB3 Encryption =============== Encryption is only supported with KRB5 or with the builtin ntlmssp support. Encryption is not supported when the gss-ntlmssp mech plugin is used. Encryption can be enabled either using the "seal" URL argument or by calling smb3_set_seal(smb2, 1); BUILDING LIBSMB2 =============== Windows --------------------------- You have to install CMake (https://cmake.org/) and Visual Studio (https://www.visualstudio.com/) to build libsmb2 for Windows (including Universal Windows Platform). Please follow the next steps to build shared library: mkdir build cd build cmake -G "Visual Studio 15 2017" .. cmake --build . --config RelWithDebInfo Static library: mkdir build cd build cmake -G "Visual Studio 15 2017" -DBUILD_SHARED_LIBS=0 .. cmake --build . --config RelWithDebInfo macOS, iOS, tvOS, watchOS --------------------------- You can use AMSMB2 (https://github.com/amosavian/AMSMB2) universal framework which incorporates precompiled libsmb2 for Apple devices. It is written in Swift but can be used in both Swift and Objective-C codes. If you want to rebuild libsmb2 in AMSMB2, please follow these steps: git clone https://github.com/amosavian/AMSMB2 cd AMSMB2/buildtools ./build.sh Precompiled binaries don't include Kerberos support by default. If you want build libraries with Kerberos support, execute this script instead: ./build-with-krb5.sh ESP32 ----- libsmb2 is pre-configured for the ESP32 micro-controller using the esp-idf toolchain (Arduino is not supported). Simply clone this project in the 'components' directory of the ESP32 project and it will automatically be included in the build process. Raspberry Pi Pico W (RP2040) ---------------------------- libsmb2 will compile on the RP2040 using gcc-arm-none-eabi, the pico-sdk and FreeRTOS-Kernel. In examples/picow is a CMakeLists.txt that can be edited to point at the pico-sdk and FreeRTOS-Kernel, and will then build libsmb2 and a sample - this can be used as a starting point. Inside include/picow are some configuration files for lwip, FreeRTOS and any applications built with libsmb2. These can also be used as a starting point and adjusted as needed for your applications. The only define needed for libsmb2 on the RP2040, other than the RP2040 defines such as PICO_BOARD=pico_w, is PICO_PLATFORM. Playstation 2 ------------ EE, Emotion-Engine, is the main CPU for the PS2. To compile libsmb2 for the PS2 EE, first install the PS2 toolchain and PS2 SDK and set it up. To build libsmb2.a, a version of libsmb2 for the EE tcpip stack: $ make -f Makefile.platform clean $ make -f Makefile.platform ps2_ee_install EE Using IOP Stack, It´s a different of EE version for when the LWIP stack is running on the IOP (libsmb2_rpc and linking with -lps2ips) To build libsmb2_rpc.a, a version of libsmb2 for ee with IOP tcpip stack: $ make -f Makefile.platform clean $ make -f Makefile.platform ps2_rpc_install IOP, IO-Processor is the secondary CPU for the PS2. The library is been used to build smb2man.irx module but it doesn´t comes with the library installed, To install libsmb2 for the PS2 IOP and smb2man.irx, first install the PS2 toolchain and PS2SDK and set it up. Then to build libsmb2, run $ make -f Makefile.platform clean $ make -f Makefile.platform ps2_iop_install $ make -f Makefile.platform clean $ make -f Makefile.platform ps2_irx_install PlayStation 3 ------------- PPU, PowerPC, is the main CPU for the PS3. To compile libsmb2 for the PS3 PPU, first install the PS3 toolchain and PSL1GHT SDK and set it up. Then to build libsmb2, run $ cd lib $ make -f Makefile.PS3_PPU install The process will copy the resulting libsmb2.a and the include/smb2 headers to your PSL1GHT SDK portlibs folder. PlayStation Vita ------------- ARM® Cortex™ - A9 core (4 core), is the main CPU for the PSVITA. To compile libsmb2 for the PSVITA, first install the VitaSDK using vdpm Then to build libsmb2, run $ make vita_install -f Makefile.platform The process will copy the resulting libsmb2.a and the include/smb2 headers to your VitaSDK libs folder. PlayStation 4 ------------- x86_64 is the main CPU for the PS4. To compile libsmb2 for the PS4 PPU, first install the PS4 toolchain and OpenOrbis SDK and set it up. Then to build libsmb2, run $ make -f Makefile.platform ps4_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your OpenOrbis SDK include folder. Nintendo 3DS ------------- Nintendo 3DS CPU is a ARM11 MPCore variant. To compile libsmb2 for the Nintendo 3DS, first install the devkitPro with libctru to set it up. Then to build libsmb2, run $ make -f Makefile.platform 3ds_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your devkitPro 3ds portlibs folder. Nintendo Switch ------------- Nintendo Switch CPU is a Custom Nvidia Tegra X1. To compile libsmb2 for the Nintendo Switch, first install the devkitPro with libnx to set it up. Then to build libsmb2, run $ cd lib $ make -f Makefile.platform switch_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your devkitPro switch portlibs folder. Nintendo Wii ------------- Nintendo Wii CPU is a Broadway PowerPC processor. To compile libsmb2 for the Nintendo Wii, first install the devkitPro with libogc using pacman to set it up. Then to build libsmb2, run $ make -f Makefile.platform wii_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your devkitPro wii portlibs folder. Nintendo Gamecube ------------- Nintendo GameCube CPU is a IBM "Gekko" PowerPC CPU. To compile libsmb2 for the Gamecube, first install the devkitPro with libogc using pacman to set it up. Then to build libsmb2, run $ make -f Makefile.platform gc_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your devkitPro gamecube portlibs folder. Nintendo DS ------------- Nintendo DS CPU is both ARM7TDMI and ARM946E-S. To compile libsmb2 for the Nintendo DS, first install the devkitPro with libnds using pacman to set it up. Then to build libsmb2, run $ cd lib $ make -f Makefile.platform ds_install The process will copy the resulting libsmb29.a and the include/smb2 headers to your devkitPro ds portlibs folder on: lib/arm9. Nintendo WII-U ------------- Nintendo Wii-U CPU is a IBM "Espresso" PowerPC-based 45 nm, with 4 cores and a clock speed of 1.24 GHz. To compile libsmb2 for the Nintendo WII-U, first install the devkitPro with libwut using pacman to set it up. Then to build libsmb2, run $ cd lib $ make -f Makefile.platform wiiu_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your devkitPro wiiu portlibs folder. Amiga (AmigaOS) ---------------------- AmigaOS is Operating system which the main processor is a Microprocessor PowerPC. There are 3 versions: AmigaOS4(Makefile.AMIGA) AmigaOS3(Makefile.AMIGA_OS3) AmigaAROS(Makefile.AMIGA_AROS) To compile libsmb2 for the AmigaOS, you need to set newlib.library V53.40 or newer (or V53.30 as included in 4.1 FE) and filesysbox.library 54.4 or newer to set it up. Then to build libsmb2, choose the makefile acording your AmigaOS system and hit $ cd lib $ make -f Makefile.YOUR_AMIGA_OS_USED clean install The process will copy the resulting libsmb2.a and the include/smb2 headers in the bin folder inside of the lib folder NOTE: Amiga AROS is a Open Source version of AmigaOS, So do not build this version unless you are using the AmigaAROS. Dreamcast (KallistiOS) ---------------------- Hitachi SH4 in little-endian mode is the main CPU for the Dreamcast. To compile libsmb2 for the Dreamcast, first install the KOS toolchain and and set it up. Then to build libsmb2, run $ cd lib $ make -f Makefile.platform clean dc_install The process will copy the resulting libsmb2.a and the include/smb2 headers to your KallistiOS toolchain install location addons folder. NOTE: There is not yet a kos-ports entry for libsmb2 but once a versioned release that includes Dreamcast support is created installing from kos-ports will become the preferred method of installation. Xbox (Xbox XDK) ---------------------- Xbox CPU is a custom Intel Pentium III Coppermine-based processor which only supports litlle endian values. To compile libsmb2 for the Xbox, first install the Xbox XDK(with all features), Microsoft Visual C++ 2003 Professional and Windows XP. Then to build libsmb2, go to Xbox folder and open the provided .sln file, Then hit the green button to build: The process will result a libsmb2.lib. So you can copy the include files and the .lib file to your Xbox project. Xbox 360 (Xbox 360 SDK) ---------------------- Xbox 360 CPU is a PPC(PowerPC) Xenon which only supports only big endian values. To compile libsmb2 for the Xbox 360, first install the Xbox 360 SDK(with all features), Microsoft Visual C++ 2010 Ultimate and Windows XP(Recommended) or Windows 7. Then to build libsmb2, go to Xbox 360 folder and open the provided .sln file, Then hit the green button to build: The process will result a libsmb2.lib. So you can copy the include files and the .lib file to your Xbox 360 project. NOTE: Both ports was based on XBMC-360 port by BDC(Brent De Cartet) and now being updated to libsmb2 standards to best performance.
I'm not sure if this was intended but it seems that libsmb2 is missing a current_offset
argument. This is used by Kodi to get the current position. see, https://github.com/xbmc/xbmc/blob/master/xbmc/filesystem/NFSFile.cpp#L519-L534
libsmb2
int smb2_lseek(struct smb2_context *smb2, struct smb2fh *fh,
int64_t offset, int whence);
lbnfs
EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh,
int64_t offset, int whence, uint64_t *current_offset);
in "libsmb2.c" I can see we set the "ent->dirent.st.smb2_nlink = 0;", is this a limitation? I though this might help to get child file count of a directory, but now I can only get a "0"
Hi,
I'm developing a wrapper Swift framework for libsmb2. I successfully have run it on my iOS device but when I try write a file, after opening file with O_WRONLY | O_CREAT | O_TRUNC
flag. Either using smb2_write()
or smb2_pwrite()
I get result -1
. I also tried other flags combination for writing.
I've tried to use async version, thus I reimplemented wait_for_reply
in Swift. It worked without issue for smb2_rename_async()
(as I didn't find sync version).
In async version, smb2_service()
returns negative value and smb2_get_error()
prints POLLHUP
error.
I reiterate this issue is only exist in writing functions and other functions work without any issue.
Thanks for this life saving library by the way. I also wrote building scripts and I can publish framework in Github after this issue got resolved.
EDIT: There is some minor issues in your code in apple platform which I will create a PR later to address them.
EDIT 2: An empty file is created in server every time I execute, if the file does not exist.
Currently in smb2-errors.h, there are only a few NT error status codes defined. A more complete status codes can be found at https://msdn.microsoft.com/en-us/library/ee441884.aspx.
Hi,
How can I get file_id
from smb2fh
to pass to smb2_ioctl_request
struct?
When smb2_service() encounters error (say socket error), does libsmb2 issues callbacks to the pending async calls? It looks the code does not do so (smb2_service() simply returns error).
In such case, how would caller do clean up work? Say caller has an open file handle. It can call smb2_destroy_context() to destroy the smb2_context but what about the open file handle? How to free the handle? Should it call smb2_close? But the context is already in bad state. And there is no API to directly close the file handle. This seems like a potential source of memory leak.
Having the following issue compiling with C++
In file included from /home/lukas/Documents/git/vfs.smb/src/SMBFile.cpp:30:0:
/usr/local/include/smb2/libsmb2-raw.h:32:20: error: uninitialized const ‘compound_file_id’ [-fpermissive]
const smb2_file_id compound_file_id;
^
In file included from /home/lukas/Documents/git/vfs.smb/src/SMBConnection.cpp:27:0:
/usr/local/include/smb2/libsmb2-raw.h:32:20: error: uninitialized const ‘compound_file_id’ [-fpermissive]
const smb2_file_id compound_file_id;
^
I can fix the error with the following, but not sure what a proper fix would be
const smb2_file_id compound_file_id = {0};
Hi
Current implementation does not support FSCTL
commands. We need it for two main purposes:
Enumerating shares: while I successfully implemented listing shares using file interface, official way to support this capability is to use FSCTL_PIPE_TRANSCEIVE
(0x0011c017) command.
Failure to add signature
error, similiar to #46.Server-side copy: Currently we have to download then upload data to copy a file. With FSCTL_SRV_COPYCHUNK
& FSCTL_SRV_COPYCHUNK_WRITE
commands we can duplicate folder/file on server without roundtrip see details.
Hi
Documentation states this project dependents on gss-ntlmssp but I could not find how and where. Would you mind clarifying if this library is dependent on that or not?
For the smb2_pwrite_async function, the callback function receives a status of 0 when a write completes successfully instead of the number of bytes written.
Smb2_parse_url parse has a bug, when there is no domain in url bug path has ';' or '@',
"smb2_parse_url" should first extract the smb:// to the path between smb://domain;user:ip/path, and then analyze the domain and user pwd and ip.
struct smb2_url *smb2_parse_url(struct smb2_context *smb2, const char *url)
{
struct smb2_url *u;
char *ptr, *tmp, str[MAX_URL_SIZE];
char *args;
if (strncmp(url, "smb://", 6)) {
smb2_set_error(smb2, "URL does not start with 'smb://'");
return NULL;
}
if (strlen(url + 6) >= MAX_URL_SIZE) {
smb2_set_error(smb2, "URL is too long");
return NULL;
}
strncpy(str, url + 6, MAX_URL_SIZE);
args = strchr(str, '?');
if (args) {
*(args++) = '\0';
if (smb2_parse_args(smb2, args) != 0) {
return NULL;
}
}
u = malloc(sizeof(struct smb2_url));
if (u == NULL) {
smb2_set_error(smb2, "Failed to allocate smb2_url");
return NULL;
}
memset(u, 0, sizeof(struct smb2_url));
ptr = str;
/* domain */
if ((tmp = strchr(ptr, ';')) != NULL) { //this will be bug when path is smb://192.168.1.200/path/1;abc.txt
*(tmp++) = '\0';
u->domain = strdup(ptr);
ptr = tmp;
}
/* user */
if ((tmp = strchr(ptr, '@')) != NULL) { // the same bug like above.
*(tmp++) = '\0';
u->user = strdup(ptr);
ptr = tmp;
}
/* server */
if ((tmp = strchr(ptr, '/')) != NULL) {
*(tmp++) = '\0';
u->server = strdup(ptr);
ptr = tmp;
}
/* Do we just have a share or do we have both a share and an object */
tmp = strchr(ptr, '/');
/* We only have a share */
if (tmp == NULL) {
u->share = strdup(ptr);
return u;
}
/* we have both share and object path */
*(tmp++) = '\0';
u->share = strdup(ptr);
u->path = strdup(tmp);
return u;
}
Hi,
How can we list available shares on a server?
Thanks a lot
Hello, thank you for providing the clean smbV2 library, but how can I connect a shared folder without a password and user? Thank you
What is your process/policy for cutting a new release of libsmb2?
Would you accept a request to cut a minor release soon?
I'm interested in getting recent changes into a release so that they can
be picked up by videolan.
Thanks for your help!
Hi,
Is it safe to use smb2_context
in multiple concurrent threads in order to execute file operation functions? What about smb2fh
and smb2dir
?
In other words, is it safe to call 2 different functions on same context from two different threads?
I'm trying to use the examples to make sure the code works properly but I can't seem to connect to my share
$ ./smb2-ls-sync smb://192.168.1.106/concerts/
smb2_connect_share failed. gss_init_sec_context: (Unspecified GSS failure. Minor code may provide more information, SPNEGO cannot find mechanisms to negotiate)
I'm just trying to use anonymous guest but I'm not sure about the url
I've tried a bunch of various urls with no success
smb://Guest:@192.168.1.106/concerts/
smb://guest:@192.168.1.106/concerts/
smb://192.168.1.106/concerts/
Any ideas about what I'm doing wrong would be great
Encountered this error when using libsmb2 APIs to iterate through a directory tree on an Isilon SMB server. I will attach a tcpdump trace when the problem is happening.
We can improve latency by tens of us for busy clients if we try to process as many replies as possible
each time smb2_service() is invoke instead of returning after each pdu.
I'm having an issue with this include
/usr/local/include/smb2/smb2.h:22:25: fatal error: smb2-errors.h: No such file or directory
compilation terminated.
In file included from /home/lukas/Documents/git/vfs.smb/src/SMBConnection.cpp:25:0:
/usr/local/include/smb2/smb2.h:22:25: fatal error: smb2-errors.h: No such file or directory
compilation terminated.
if I change it to
#include <smb2/smb2-errors.h>
or
#include "smb2-errors.h"
it works
There appears no function in libsmb2 to get/set ACL. Can this be added?
HI,
When I try to connect to my macOS smb server which is SMB 3.02, All /
delimiters in path must be replaced by \
otherwise the operation will fail with Failure to add signature
message.
EDIT: This issue is limited to macOS 10.13.4 High Sierra. Windows 10 and Samba on Linux has no issue with dialect 3.02 signing.
I don't find any symlink create API in libsmb2.h. Is this missing?
We currently drop any ACEs we do not understand.
We should probably keep these as-is as blobs so that we will be able to
fetch/mutate-some-aces/store without loss of ACEs.
Greetings,
There are some use after free / double frees in the libsmb2 library.
I have forgotten some of them, but this one has been the primary one to cause me the trouble:
dcerpc.c --
dcerpc_decode_pdu:
default: smb2_set_error(ctx->smb2, "DCERPC No decoder for PDU type %d", pdu->hdr.PTYPE); dcerpc_free_pdu(ctx, pdu); // pdu is freed once here, and returns -1 return -1; }
dcerpc_call_cb:
ret = dcerpc_decode_pdu(dce, pdu, &iov);
if (ret < 0) { // if ret == -1
pdu->cb(dce, -EINVAL, NULL, pdu->cb_data);
smb2_free_data(dce->smb2, rep->output);
dcerpc_free_pdu(dce, pdu); // pdu is freed twice
return;
}
smb2_free_data(dce->smb2, rep->output);
if (pdu->hdr.PTYPE != PDU_TYPE_RESPONSE) {
smb2_set_error(dce->smb2, "DCERPC response was not a RESPONSE");
pdu->cb(dce, -EINVAL, NULL, pdu->cb_data);
dcerpc_free_pdu(dce, pdu);
return;
}
Hi,
I am trying to add a timeout for one of the library functions in libsmb2 but have been unable to find an implementation within the library. I am also using the libnfs library and found a way to timeout a call here. Does some sort of timeout system exist within libsmb2 and if so, does it follow a similar pattern?
Thanks!
Hi,
I'm trying to port libsmb2 to an ESP32. Unfortunately the ESP32 does not support poll() at this time. Although configure checks for HAVE_POLL_H, libsmb2 does not compile without that header file. I think it should be possible to revert to a strictly synchronous API in that case. Any guidance on how to go about that? Simply marking the socket as blocking and doing a no-op in wait_for_reply() doesn't work.
TIA,
AP
smb2_lseek returns -EINVAL on error, else the resulting offset. But if the seek is past 31 bits, then the return value flips negative as it overflows an int. While the seek was good, an error will be signaled (neg return value) and a seek failure will result on app side.
I implemented server-side copy using ioctl command. Occasionally smb2_ioctl_reply
returned by async handler is corrupted and output_count
has weird values like 2939741608
. In this condition, when I try to free output
memory using smb2_free_data()
, I get SIGABRT
.
This issue always happens when I try to copy two files simultaneously using same smb2_context.
Unfortunately I can't ignore reply otherwise I will have memory leaks.
Furthermore, reply's ctl_code
always mismatch with request's one.
Error is: malloc: *** error for object 0x1c81575f8: pointer being freed was not allocated
The port to use is hardwired in socket.cc to be CIFS_PORT (445).
In order to support a server accessed through an SSH tunnel, I'd like
to be able to specify a port for the SMB server.
Would you be willing to accept a code change to accept an optional :port suffix
after the host name?
Hi,
Thanks for fast implementation of statvfs()
, Here are two issues I found
An strange behavior in linux I found when I implemented swiftlang/swift-corelibs-foundation#1250 was statvfs()
populates f_frsize
in Linux with correct block size, whereas old-school statfs()
(in Darwin) function populates f_bsize
! I suggest you to fill both with same value for the sake of compatibility.
f_blocks
and a_bavail
are set to UINT64_MAX
when server doesn't command. Is this expected behavior?
Hi,
can I use libsmb2 to query a server for the different shares (and other services).
I've tried to use smb2_connect_async to connect to a server and then call smb2_opendir_async with directory "/", but it hangs. (I've modified the example smb2_ls_async).
Thanks in advance,
Stef
libnfs has nfs_truncate
EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path,
uint64_t length);
A similar function seems to be missing from libsmb2
Has Guest access been verified for smb2/3 (built with --without-libkrb5) ?
Seeing failure to connect and just starting to dig into it.
this works:
smb2_rename_async(smb2, "abc.txt.tmp", "abc.txt", smb2_rename_cb, NULL); // succeed
but the following failed:
// failed with status == -5 in smb2_rename_cb
smb2_rename_async(smb2, "123/abc.txt.tmp", "123/abc.txt", smb2_rename_cb, NULL);
what does the error -5 mean ?
It looks like we have the following code for file open:
/* Create disposition */
if (flags & O_CREAT) {
if (flags & O_EXCL) {
create_disposition = SMB2_FILE_CREATE;
} else {
create_disposition = SMB2_FILE_OVERWRITE_IF;
}
} else {
if (flags & (O_WRONLY | O_RDWR)) {
create_disposition = SMB2_FILE_OVERWRITE;
} else {
create_disposition = SMB2_FILE_OPEN;
}
}
This is a bug as it causes all writes to truncate files.
O_WRONLY | O_RDWR should be O_TRUNC
The same url (e.g. smb://timecapsule/) doesn't work in libsmb2 while it works correctly in Samba library when using mDNS. In libsmb2 only smb://timecapsule.local/ URL is working, which results in problems with porting from Samba to libsmb2.
Greetings Ronnie!
I randomly found this library from discussions on the libdsm repo about SMB client libraries that support version 2 and up. This library looks absolutely fantastic!
I've been working on an app for iPhone and iPad and one of my dream features is adding SMB2 support so I can easily access files on my NAS over WiFi directly from the device. I wrote a wrapper around libdsm so it could be built and deployed on iOS devices, however libdsm only supports SMB1 at the moment, and given how different the two protocol standards are, I'm not sure if libdsm will ever get SMB2 support.
I'm curious to try building and deploying libsmb2 for iOS, but before that, I thought I'd better ask you.
While being able to dynamically link frameworks on iOS solves most of the conditions of the LGPL, the fact that customers can't easily replace the dynamic framework on their devices themselves means shipping LGPL software on the iOS App Store is still somewhat ambiguous. From what I've seen, it usually depends on the original author's views of the LGPL.
What would your thoughts be on this? Would it be acceptable to use this library in shipping iOS software? Or would you prefer not?
Thanks for your time!
if you have a spare time please make it possible to use the same context (i.e. same session) to connect to different trees.
smb2_share_enum_async returns Error -22 (Invalid argument) against an macOS SMB Server (10.13.6). It works fine with any other samba server I tested. All other operations (connect, dirlisting) work fine with the macOS SMB server. After some further investigation this issue seems to be related by dcerpc decoding not working for dcerpc responses delivered in multiple fragments.
I have not a full overview how libsmb2 internals work yet, but I assume the fragments (if they are multiple) need to be assembled before decoding, which is currently missing or buggy.
I attached a Wireshark trace for the NetShareEnumAll session against the macOS SMB Server
NetShareEnumAll_macOSHighSierra.pcapng.zip
If I can assist any further, please let me know.
Currently there is no support to add backup intent flag in SMB2 CREATE request.
Wonder what is the right way to do this? Add an extra API to set some flag in smb2_context?
Looks like this line https://github.com/sahlberg/libsmb2/blob/master/lib/smb2-cmd-error.c#L77 causes an overlapping the body with next header in handling compounded response with errors. while the expected size of response is 9 it actual size is 8. this causes an overlapping the body to next header. this makes unimpossible to use the same context to any other requests.
if I comment this line all works fine
Hi sahlberg
I have been using AMSMB2 which is based on this repo for a long time, it works great, but with the update on Xcode10.2, the list share API failed. I ran the test case of func testShareEnum()
of AMSMB2's test case. The case success on xcode10.1 but failed on xcode10.2. After some debug, I found it was caused by smb2_cmd_create_async
API.
Can you please take a look? Is it a xcode issue and do we have a workaround?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.