Git Product home page Git Product logo

libsmb2's Introduction

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_ip.a, a version of libsmb2 for the EE tcpip stack:
  $ cd lib
  $ make -f Makefile.PS2_EE clean
  $ make -f Makefile.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_ips and linking
with -lps2ips)

To build libsmb2_ips.a, a version of libsmb2 for the IOP tcpip stack:
  $ cd lib
  $ make -f Makefile.PS2_EE_IPS clean
  $ make -f Makefile.PS2_EE_IPS install

IOP, IO-Processor is the secondary CPU for the PS2.
To compile libsmb2 for the PS2 IOP, first install the PS2 toolchain and
PS2 SDK and set it up.

Then to build libsmb2, run
  $ cd lib
  $ make -f Makefile.PS2_IOP clean
  $ make -f Makefile.PS2_IOP 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 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
  $ cd lib
  $ make -f Makefile.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
  $ cd lib
  $ make -f Makefile.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.SWITCH install

The process will copy the resulting libsmb2.a and the include/smb2 headers to your
devkitPro switch 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.DC_KOS clean 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.

libsmb2's People

Contributors

adamwilt avatar afedchin avatar akiranorthstar avatar amosavian avatar apuder avatar averne avatar bucanero avatar darcagn avatar davilla avatar epirat avatar healytpk avatar jacadcaps avatar jmk-foofus avatar kevin1018 avatar llakssz avatar lrusak avatar memecode avatar mwyoungpa avatar namjaejeon avatar nopnop2002 avatar polluks avatar sahlberg avatar salass00 avatar simo5 avatar skbehera1984 avatar stewbc avatar tguillem avatar timmeh87 avatar wi7a1ian avatar wolf3s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsmb2's Issues

Query server for shares.

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

statvfs() issues

Hi,

Thanks for fast implementation of statvfs(), Here are two issues I found

  1. An strange behavior in linux I found when I implemented apple/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.

  2. f_blocks and a_bavail are set to UINT64_MAX when server doesn't command. Is this expected behavior?

smb2_lseek breaks on large files

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.

  1. Either make current_offset pointer parameter mandatory and only return status ( -EINVAL or 0)
  2. Or change the return from int to int64_t, this will not match file->offset (uint64_t) but it has to be signed to signal an error. 1) seems better.

why not support number of links

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"

smb2_service() failure and pending callbacks

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.

[Enhancement] Implementing smb_cmd_fsctl

Hi

Current implementation does not support FSCTL commands. We need it for two main purposes:

  1. 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.

    • Listing shares on macOS 10.13 SMB3 server throws Failure to add signature error, similiar to #46.
  2. 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.

Support server:port syntax?

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?

Release request/process

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!

Releasing on the iOS App Store

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!

[Request] Timeout functionality

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!

smb2_share_enum_async (NetShareEnumAll) fails on macOS SMB Server (10.13.6)

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.

  1. My samba test server returns the dceprc response in one fragement => decoding works fine
  2. The macOS SMB Server returns the dcerpc response in multiple fragments with a maximum fragment size of 256 bytes => decoding fails

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.

Problems using examples

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

Writes truncate files

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

Guest access, failure to connect

Has Guest access been verified for smb2/3 (built with --without-libkrb5) ?

Seeing failure to connect and just starting to dig into it.

Multicast DNS name resolving doesn't work

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.

smb2_parse_url parse has bug when no domain.

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;

}

Double free on dcerpc_call_cb and dcerpc_decode_pdu

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;
        }

Add backup intent support

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?

uninitialized const when using C++

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};

Is libsmb2 thread safe?

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?

fatal error: smb2-errors.h: No such file

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

smb2_cmd_ioctl_async reply corrupted

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

missing smb2_truncate

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

Porting to ESP32

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

gss-ntlmssp dependency

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?

smb2_rename_async failed

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 ?

SMB3 fails to sign when path is delimited by slash

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.

Listing Shares

Hi,

How can we list available shares on a server?

Thanks a lot

Error in write/pwrite function

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.

smb2_lseek behaviour is different from nfs_lseek

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);

smb2_cmd_create_async failed on xcode 10.2

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.
Screenshot 2019-03-29 at 2 26 05 PM
Can you please take a look? Is it a xcode issue and do we have a workaround?

Handle unknown ACEs better

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.