[jcifs] NamedPipes problem

Michael B Allen mba2000 at ioplex.com
Thu Aug 10 15:11:39 GMT 2006


On Thu, 10 Aug 2006 13:07:20 +0200
"Michele Callegari" <michele.callegari at make-it.it> wrote:

> Hi all,
> I'm michele and I started using jcifs to comunicate with a windows
> application using windows named pipes:
> 
> SmbNamedPipe pipe = new SmbNamedPipe( "smb://COMPNAME/IPC$/foo",
> SmbNamedPipe.PIPE_TYPE_RDWR);
> OutputStream out = pipe.getNamedPipeOutputStream();
> out.write(b,0,b.length);
> 
> In the latest version (jcifs_1.2.9) this code fails:
> jcifs.smb.SmbException: The system cannot find the file specified.
> 	at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:510)
> 	at jcifs.smb.SmbTransport.send(SmbTransport.java:587)
> 	at jcifs.smb.SmbSession.send(SmbSession.java:231)
> 	at jcifs.smb.SmbTree.send(SmbTree.java:102)
> 	at jcifs.smb.SmbFile.send(SmbFile.java:687)
> 	at
> jcifs.smb.TransactNamedPipeOutputStream.write(TransactNamedPipeOutputStream.
> java:54)
> 	at Jcifs2DIPC.main(Jcifs2DIPC.java:38)
> 
> 
> The same code works with version 1.1.11
> 
> It looks like a problem in the getNamedPipeOutputStream().
> In the latest version this method returns a TransactNamedPipeOutputStream
> but I'm not working with Transacted Pipes.. I'm working with File I/O Named
> Pipes.
> Is this a bug?

Yes. This is a major bug. The SmbFile.O_RDONLY, SmbFile.O_WRONLY, and
SmbFile.O_RDWR flags used to be in the upper 16 bits of pipeType. Now
those flags are in the lower 16 bits which is colliding with the other
SmbNamedPipe.PIPE_TYPE_CALL and SmbNamedPipe.PIPE_TYPE_TRANSACT flags.

Unfortunately I don't have the time to fix this. For now you could just
hack the code to look like:

    183     public OutputStream getNamedPipeOutputStream() throws IOException {
    184         if( pipeOut == null ) {
    185             pipeOut = new SmbFileOutputStream( this, false, SmbFile.O_RDWR | SmbFile.O_EXCL);
    186         }
    187         return pipeOut;
    188     }
    189 }

and call like:

    SmbNamedPipe pipe = new SmbNamedPipe( "smb://COMPNAME/IPC$/foo", 0);

I'll add this to The List. Those flags need to be discombobulated.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/


More information about the jcifs mailing list