Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Unable to establish SMB2 connection using Filesys::SmbClient

by Netras (Initiate)
on Feb 09, 2016 at 13:05 UTC ( #1154727=perlquestion: print w/replies, xml ) Need Help??
Netras has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks,

I need to access a SMB host which requires SMB version 2. Filesys::SmbClient (3.2) has served me well working with SMB1 but does not successfully create a SMB2 connection. This is the error I get:

samba_tevent: EPOLL_CTL_DEL EBADF for fde[0x27c9930] mpx_fde[(nil)] fd[8] - disabling

Directly using smbclient with SMB version 2 works fine:

smbclient -U domain\\user //HOSTNAME/ShareName -c "dir" -m SMB2

But when omitting the max-protocol tag (-m) while using smbclient, a very similar error appears:

smbclient -U domain\\user //HOSTNAME/ShareName -c "dir" samba_tevent: EPOLL_CTL_DEL EBADF for fde[0x7f454d1eff50] mpx_fde[(nil +)] fd[7] - disabling

I assume that Filesys::SmbClient is trying to use SMB version 1 to connect to the target host and I have no idea how I can change this behaviour. I have checked the official module documentation with no success and tried forcing the client protocol version in /etc/samba/smb.conf but this has no effect on Filesys::SmbClient as well.

Is there someone that has had this issue or has any ideas? I would appreciate any feedback and/or help in the matter.

Thank you!

Replies are listed 'Best First'.
Re: Unable to establish SMB2 connection using Filesys::SmbClient
by natxo (Scribe) on May 18, 2017 at 20:51 UTC
    A bit late to this post, but for future reference maybe worth it as smb 1 after the wannacry drama will probably be less and less common out there :-)

    I have just used Filesys::SmbClient with smb2 or 3. You just need to fill in the file ~/.smb/smb.conf that Filesys::Smbclient autocreates with something like this:

    [global] client max protocol = SMB3
    If the share only accepts smb2, it will downgrade to 2 or 2.1, otherwise it will use 3.

    I verified this using wireshark traces.

Re: Unable to establish SMB2 connection using Filesys::SmbClient
by Anonymous Monk on Feb 10, 2016 at 13:05 UTC

    Did you try to configure that option in your ~/.smb/smb.conf?

    client max protocol = SMB2

      That is a bit embarrassing: I changed the general smb.conf in /etc/samba, the user didnīt have one. But then I created it and added the global parameter (client max protocol) and something changed! Now the connection is actually established, as far as I can see though I still get an error:

      map_errno_from_nt_status: 32 bit codes: code=c0000059 smbc errno NT_STATUS_REVISION_MISMATCH -> 22

      Google has failed me on my first try but I now have something I can work on. Maybe you also know about the new error but in any case - thank you a lot Anonymous Monk!

        It may or may not be related, but libsmbclient seems to have (had) some peculiarities regarding the smb.conf file, as commented on in the module:

        # Actually libsmbclient will segfault if it can't find file # $ENV{HOME}/.smb/smb.conf so I will test if it exist, # and create it if no file is found. A empty file is enough ... ... creation of an empty $ENV{HOME}/.smb/smb.conf

        So maybe libsmbclient does not crash nowadays but doesn't necessarily respect /etc/smb.conf if it doesn't find a local file.

      Yes, I have set the global parameter in smb.conf. And it did cause the smbclient call to work without adding the max-protocol tag (-m), so this was successful:

      smbclient -U domain\\user //HOSTNAME/ShareName -c "dir"

      But unfortunately it has no effect on Filesys::SmbClient and my Perl-script. It appears that it still uses SMB1 (same error message as before). I am very puzzled over this behaviour.

Re: Unable to establish SMB2 connection using Filesys::SmbClient
by u65 (Chaplain) on Feb 10, 2016 at 12:23 UTC

    Welcome to the monastery, Netras! Have patience, some knowledgeable monk will help you eventually.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1154727]
Front-paged by GotToBTru
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2018-01-20 07:32 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.