Re: Fwd: SmbRandomAccessFile for read-only access

Michael B Allen <[email protected]> Fri, 21 Jun 2013 00:12:11 -0400
Newsgroups gmane.network.samba.java
Message-ID <CAGMFw4gLMCDfgLv9dAzw0mgE-qJpL97TBSPAQ1YF8-Ht6Frh+w@mail.gmail.com>
On Jun 8, 2013 2:12 AM, "Somnath Kundu" <[email protected]> wrote:
>
> Thanks for your response.
>
> This happened several weeks ago when I included source code of this
library with my Android project and was stepping through it to understand
what is happening in the library. Then it could not open files for reading,
and after I made the above changes, it worked.
>
> Today, after receiving your email, I again tested my project, which is
now in working condition, with your "jcifs-1.3.17.jar", and to my surprise,
it is working fine.
>
> To find out why it was not working previously, I open the "SmbFile.java",
and see there is a conditional block,
>
> if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS
)) {

Hi Somnath,

I would be shocked if you found a server that does not hasCapability
CAP_NT_SMBS. Maybe an ancient version of Samba thats actually a honeypot.

Mike

> .....
> SmbComNTCreateAndX request = new SmbComNTCreateAndX( unc, flags, access,
shareAccess, attrs, options, null );
> ......
> } else {
> .....
> send( new SmbComOpenAndX( unc, access, flags, null ), response );
> .....
> }
>
> I am yet to figure out what "hasCapability" method above is doing, but if
the control goes through "SmbComOpenAndX", it does not add FILE_READ_DATA
flag (where 'desiredAccess' is set to 'SHARING_DENY_NONE' only).
>
> Is it possible that this was happening in my case earlier?
>
> Best regards,
> Somnath
>
>
> On Fri, Jun 7, 2013 at 6:26 AM, Michael B Allen <[email protected]> wrote:
>>
>> On Thu, Jun 6, 2013 at 3:27 AM, Somnath Kundu <[email protected]> wrote:
>> > Hello,
>> >
>> > I was trying to use 'SmbRandomAccessFile' class with mode value "r" for
>> > reading some file data, but it was not working. From the source code,
it
>> > appears that for mode value "r", the 'access' value remains set to
'0', and
>> > hence this problem. I had to modify the code as below to make it
working.
>>
>> Hi Somnath,
>>
>> SmbComNTCreateAndX automatically adds FILE_READ_DATA.
>>
>> Perhaps you should post precisely what actually happens and describe
>> why you think it is in error.
>>
>> >
>> > BTW, what is the meaning of 'WRITE_OPTIONS' value as '0x0842' (as I do
not
>> > see any description in the code), and I see the default zero value is
being
>> > converted to '0x0040' later in the code?
>>
>> Those are options specific to if the file is created. I don't recall
>> what each bit actually means. I don't think they were documented when
>> I wrote the code. They may be now.
>>
>> Mike
>>
>> --
>> Michael B Allen
>> Java Active Directory Integration
>> http://www.ioplex.com/
>>