smbj-rpc icon indicating copy to clipboard operation
smbj-rpc copied to clipboard

Share listing on macOS (High) Sierra

Open mcd2000 opened this issue 6 years ago • 8 comments

I'm trying to write an SMB2 client for Android. I need to read share list from the server. I'm doing something like this:

SmbConfig cfg = SmbConfig.builder().
                        withMultiProtocolNegotiate(true).
                        withSecurityProvider(new BCSecurityProvider()).
                        build();
SMBClient client = new SMBClient(cfg);

try (Connection connection = client.connect("server")) {
   AuthenticationContext ac = new AuthenticationContext(username, password.toCharArray(), "WORKGROUP");
   Session session = connection.authenticate(ac);

   RPCTransport transport = SMBTransportFactories.SRVSVC.getTransport(session);
   final ServerService serverService = new ServerService(transport);
   final List<NetShareInfo0> shares = serverService.getShares0();
   for (final NetShareInfo0 share : shares) {
     System.out.println(share);
   }
 } catch (Exception e) {
 }
         

This code works fine when connected to Windows 10 PC, but I'am constantly getting the following exception with both macOS Sierra (10.12.8) and High Sierra (10.13.3) at "getTransport" method:
com.rapid7.helper.smbj.io.SMB2Exception: SMB2_CREATE returned STATUS_ACCESS_DENIED (3221225506/3221225506): expected=[STATUS_SUCCESS]

Is it anything I just do not understand here?

mcd2000 avatar Feb 28 '18 17:02 mcd2000

This must have to do with Apples SMBx implementation. smbj-RPC is throwing an exception when it tries to create a named pipe by sending and SMB2 create request. The response is an "Access denied" which then causes the exception.

Any workaround to this issue would be very helpful.

hschottm avatar Jun 20 '18 16:06 hschottm

Same issue here with 10.5.9 LEOPARD

Any ideas?

Thanks

fiasko131 avatar Mar 09 '19 14:03 fiasko131

I'm also facing the same issue with MAC OS only. `try{ final Connection smbConnection = smbClient.connect(mAddress); final AuthenticationContext smbAuthenticationContext = new AuthenticationContext( String.valueOf(userName), passWord, String.valueOf(domain)); final Session session = smbConnection.authenticate(smbAuthenticationContext);

        final RPCTransport transport = SMBTransportFactories.SRVSVC.getTransport(session);
        final ServerService serverService = new ServerService(transport);
        final List<NetShareInfo0> shares = serverService.getShares0();

        for (final NetShareInfo0 share : shares) {
            shareNameList.add(share.getNetName().toString());
            Log.d(TAG, share.getNetName().toString());
        }
    }catch(Exception e) {
        e.printStackTrace();
    }`

W/System.err: com.rapid7.helper.smbj.io.SMB2Exception: SMB2_CREATE returned 3221225506 (3221225506/3221225506): expected=[STATUS_SUCCESS] W/System.err: at com.rapid7.helper.smbj.io.SMB2SessionMessage.sendAndRead(SMB2SessionMessage.java:99) W/System.err: at com.rapid7.helper.smbj.share.NamedPipe.(NamedPipe.java:56) W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.openPipe(SMBTransportFactories.java:99) W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.openAndHandleStatusPipeNotAvailable(SMBTransportFactories.java:74) W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.getTransport(SMBTransportFactories.java:58) W/System.err: at com.samsung.android.app.networkstoragemanager.rpc.SMBjRPC.getShareList(SMBjRPC.java:49)

is there any solution ??

imbokhary avatar Oct 03 '19 06:10 imbokhary

@tosmun-r7 hello, I've fixed the issue on smbj-rpc related to share listing for MAC and I've tested it on MAC, Windows and Linux too working well. Changes should be pushed on smbj-rpc.

imbokhary avatar Dec 05 '19 09:12 imbokhary

@imbokhary Could, please, at least share the patch?

mcd2000 avatar Dec 23 '19 16:12 mcd2000

@imbokhary Any ideas?

Thanks

Hhcoco avatar Sep 28 '20 11:09 Hhcoco

Any update on this issue ?

mreiterer avatar Jun 27 '23 08:06 mreiterer

@imbokhary It would be great if you can share your fix.

dkocher avatar Aug 24 '23 11:08 dkocher