How to check NTFS file permissions?

Discussion in 'Ruby' started by Chris, Feb 7, 2006.

  1. Chris

    Chris Guest

    This problem comes up because WinXP keeps putting it's 'System Volume
    Information' directories on each partition. In this case, I think the FS
    was created by an earlier incarnation of the machine I'm on.

    However it is marked Read Only, and there doesn't seem to be any way to
    change it. Properties window says it is Read only (with a square, not a
    checkmark) and Hidden, and it lets me think I'm changing it, even asks if
    I want to change all subordinates, but never changes it. That's an OT,
    but I'd be happy to hear a solution to it.

    The problem I'm having is that File.readable? and File.executable? both
    give me true for that directory, but if I try Dir.chdir into it, it throw=
    s
    an exception.

    Is there a check I can do, or is my only option: rescue Errno::EACCES?=20
    And I guess the followup is: is it much more expensive in Ruby to catch
    exceptions than to execute regular code (as it is in Java)?


    Thanks,

    -Chris
     
    Chris, Feb 7, 2006
    #1
    1. Advertising

  2. Chris

    Chris Guest

    POSIX-y - oh, right. I'm still not used to crossing the Win/not-Win line
    yet :) It was strange to see the file attributes of ctime =3D change tim=
    e,
    instead of create time. Back to the point, though, if Dir.chdir isn't a
    read and it isn't an execute (and I assume it isn't a write), what kind o=
    f
    operation is it? And can someone add that method to Ruby's File or Dir?

    I'm hoping I don't run into this problem often - I've gone through a
    couple larger partitions and things have worked well except for this one
    thing. I'm more than a little surprised that it happened with SVI but no=
    t
    with Recycler. And while I don't trust what I can't see and Window's
    ACLs are definitely on that list, it gets hard to do anything if I don't
    assume things are working the way it looks like they should. No one has
    made enough documentation to dissuade that state of affairs :(


    To address Daniel Berger's comment (which jogged my memory of this),
    unfortunately in the WindowsXP GUI nothing is cut-and-dried: a checkbox
    square can contain a square instead of a checkmark if it is only partiall=
    y
    true. Here it must be that some of the directory's files are read-only
    but others are not. So it may not reflect anything about the directory
    itself. I'm beginning to understand my confusion...


    Well, Thanks guys,

    -Chris


    David Vallner said:
    > D=C5=88a Utorok 07 Febru=C3=A1r 2006 20:49 Chris nap=C3=ADsal:
    >> This problem comes up because WinXP keeps putting it's 'System Volume
    >> Information' directories on each partition. In this case, I think the
    >> FS
    >> was created by an earlier incarnation of the machine I'm on.
    >>
    >> However it is marked Read Only, and there doesn't seem to be any way t=

    o
    >> change it. Properties window says it is Read only (with a square, not=

    a
    >> checkmark) and Hidden, and it lets me think I'm changing it, even asks
    >> if
    >> I want to change all subordinates, but never changes it. That's an OT=

    ,
    >> but I'd be happy to hear a solution to it.

    >
    > The Properties window doesn't display whether a directory is or is not
    > readable as per the POSIX-y meaning of the concept. It should technical=

    ly
    > display as read-only, if the contents of the directory are read-only, b=

    ut
    > the
    > contents aren't actually checked, if only because it might end up takin=

    g
    > bloody long. I'm not even sure how those vestigial FAT attributes map t=

    o
    > NTFS
    > ones. If you really want to get nitty-gritty with the system, check
    > whatever
    > setting it is that's hiding the NTFS ACLs from you and look at those.
    >
    > Slight sidenote: You really don't want to touch System Volume Informati=

    on
    > unless you really know what you're doing.
    >
    >>
    >> The problem I'm having is that File.readable? and File.executable? bot=

    h
    >> give me true for that directory, but if I try Dir.chdir into it, it
    >> throws
    >> an exception.
    >>
    >> Is there a check I can do, or is my only option: rescue Errno::EACCES?
    >> And I guess the followup is: is it much more expensive in Ruby to catc=

    h
    >> exceptions than to execute regular code (as it is in Java)?
    >>

    >
    > Do you expect to run into inaccessible directories in the script more
    > often
    > than you actually process data in accessible ones? Unless so, I say don=

    't
    > bother and use Errno::EACCES. The overhead isn't likely to be significa=

    nt
    > compared to total execution time.
    >
    > David Vallner
     
    Chris, Feb 7, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shawn H. Mesiatowsky

    Change NTFS Permissions or run shell script

    Shawn H. Mesiatowsky, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    Shawn H. Mesiatowsky
    Feb 3, 2005
  2. Gaetan
    Replies:
    0
    Views:
    613
    Gaetan
    Jan 20, 2006
  3. Morten V. Pedersen

    NTFS permissions for ASP.NET user

    Morten V. Pedersen, Oct 22, 2003, in forum: ASP .Net Security
    Replies:
    4
    Views:
    122
    Jacob Yang [MSFT]
    Oct 29, 2003
  4. Alex Maghen
    Replies:
    0
    Views:
    169
    Alex Maghen
    Feb 3, 2005
  5. travelling_nerd
    Replies:
    4
    Views:
    158
    Patrice
    Jul 13, 2004
Loading...

Share This Page