Get the owner of a file, calculate MD5/SHA-1

View: New views
4 Messages — Rating Filter:   Alert me  

Get the owner of a file, calculate MD5/SHA-1

by Jürgen R. Plasser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

how do I get the owner of a file? I need some code snippets, as I'm
new to JCIFS and CIFS at all.

I can get the ACLs from a file, and all I have understood until now is
that the owner is coded into a SID which has to be looked up
somewhere. I hope some can enlighten me ...

My second question (is likely OT):
Is it possible to calculate the file's MD5 or SHA-1 hash without
copying it from the source, just by streaming?

-Jürgen

Re: Get the owner of a file, calculate MD5/SHA-1

by Michael B Allen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 6/23/08, Jürgen R. Plasser <juergen.plasser@...> wrote:
> Hi All,
>
>  how do I get the owner of a file? I need some code snippets, as I'm
>  new to JCIFS and CIFS at all.
>
>  I can get the ACLs from a file, and all I have understood until now is
>  that the owner is coded into a SID which has to be looked up
>  somewhere. I hope some can enlighten me ...

Currently we do not extract the owner SID from the security
descriptor. In SecurityDescriptor.java ~line 40:

  http://jcifs.samba.org/src/src/jcifs/smb/SecurityDescriptor.java

you can see the "offset to owner sid" is ignored. You would need to
add some code similar to how daclOffset is used but without the loop.

Then you would need to add a getOwnerSid method to SmbFile (that
should look very much like a simplified version of getSecurity)

>  My second question (is likely OT):
>  Is it possible to calculate the file's MD5 or SHA-1 hash without
>  copying it from the source, just by streaming?

An SmbFileInputStream is an instance of InputStream so if you can
compute a hash on an InputStream you can compute it with an
SmbFileInputStream.

Mike

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

Re: Get the owner of a file, calculate MD5/SHA-1

by Jürgen R. Plasser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer

-Jürgen

On Mon, Jun 23, 2008 at 8:05 PM, Michael B Allen <ioplex@...> wrote:

> On 6/23/08, Jürgen R. Plasser <juergen.plasser@...> wrote:
>> Hi All,
>>
>>  how do I get the owner of a file? I need some code snippets, as I'm
>>  new to JCIFS and CIFS at all.
>>
>>  I can get the ACLs from a file, and all I have understood until now is
>>  that the owner is coded into a SID which has to be looked up
>>  somewhere. I hope some can enlighten me ...
>
> Currently we do not extract the owner SID from the security
> descriptor. In SecurityDescriptor.java ~line 40:
>
>  http://jcifs.samba.org/src/src/jcifs/smb/SecurityDescriptor.java
>
> you can see the "offset to owner sid" is ignored. You would need to
> add some code similar to how daclOffset is used but without the loop.
>
> Then you would need to add a getOwnerSid method to SmbFile (that
> should look very much like a simplified version of getSecurity)
>
>>  My second question (is likely OT):
>>  Is it possible to calculate the file's MD5 or SHA-1 hash without
>>  copying it from the source, just by streaming?
>
> An SmbFileInputStream is an instance of InputStream so if you can
> compute a hash on an InputStream you can compute it with an
> SmbFileInputStream.
>
> Mike
>
> --
> Michael B Allen
> PHP Active Directory SPNEGO SSO
> http://www.ioplex.com/
>



--
"Handle stets so, dass sich die Zahl deiner Möglichkeiten erweitern."
(Heinz von Foerster)

Re: Get the owner of a file, calculate MD5/SHA-1

by Michael B Allen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just noticed that there is a GetOwnerSid.patch in the patches directory.

Mike

On 6/25/08, Jürgen R. Plasser <juergen.plasser@...> wrote:

> Thanks for the answer
>
>  -Jürgen
>
>  On Mon, Jun 23, 2008 at 8:05 PM, Michael B Allen <ioplex@...> wrote:
>
> > On 6/23/08, Jürgen R. Plasser <juergen.plasser@...> wrote:
>  >> Hi All,
>  >>
>  >>  how do I get the owner of a file? I need some code snippets, as I'm
>  >>  new to JCIFS and CIFS at all.
>  >>
>  >>  I can get the ACLs from a file, and all I have understood until now is
>  >>  that the owner is coded into a SID which has to be looked up
>  >>  somewhere. I hope some can enlighten me ...
>  >
>  > Currently we do not extract the owner SID from the security
>  > descriptor. In SecurityDescriptor.java ~line 40:
>  >
>  >  http://jcifs.samba.org/src/src/jcifs/smb/SecurityDescriptor.java
>  >
>  > you can see the "offset to owner sid" is ignored. You would need to
>  > add some code similar to how daclOffset is used but without the loop.
>  >
>  > Then you would need to add a getOwnerSid method to SmbFile (that
>  > should look very much like a simplified version of getSecurity)
>  >
>  >>  My second question (is likely OT):
>  >>  Is it possible to calculate the file's MD5 or SHA-1 hash without
>  >>  copying it from the source, just by streaming?
>  >
>  > An SmbFileInputStream is an instance of InputStream so if you can
>  > compute a hash on an InputStream you can compute it with an
>  > SmbFileInputStream.
>  >
>  > Mike
>  >
>  > --
>  > Michael B Allen
>  > PHP Active Directory SPNEGO SSO
>  > http://www.ioplex.com/
>  >
>
>
>
>
> --
>  "Handle stets so, dass sich die Zahl deiner Möglichkeiten erweitern."
>  (Heinz von Foerster)
>


--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/
LightInTheBox - Buy quality products at wholesale price!