Simplified file permission handling

Issue #175 resolved
dreadnaut created an issue

Originally reported on Google Code with ID 175

File permissions are only used in the database list at the moment, and are probed using
a combination of is_readable, is_writable, integers and strings.

Why are we not using fileperms() ? 

Relative patch attached.

(beware: my eyes have landed on the database listing code and strange ideas of modularization
and caching are coming)

Reported by dreadnaut on 2013-02-11 15:18:22

<hr> * Attachment: fileperms-r333.diff

Comments (5)

  1. Christopher Kramer
    Yeah, your solution is cleaner and simpler than the current one.
    But I would propose another way which I consider even simpler.
    
    I also think is_readable() and is_writeable() is a bit more safe to use, as fileperms()
    results can be a bit platform specific (although I have not seen any platform where
    your code wouldn't work).
    
    (btw: In your patch, you removed the DB-name in the db-list in the second case)
    

    Reported by crazy4chrissi on 2013-02-12 18:30:16 - Status changed: Accepted

    <hr> * Attachment: fileperms-crazy4chrissi-r335.diff

  2. dreadnaut reporter
    I thought about the safety of fileperms(), but I couldn't think of a common OS or filesystem
    where stat() does not return standard read-write permissions. And it doesn't seem something
    we should "future-proof" against, either.
    
    At the same times, I like the two separate fields, because they abstract from low level
    stuff like "& 0400" but then again, do we need to abstract?
    
    In the end, anything would be more usable than checking for r/w characters in a string
    :)
    

    Reported by dreadnaut on 2013-02-12 19:33:28

  3. Christopher Kramer
    This issue was closed by revision r336.
    

    Reported by crazy4chrissi on 2013-02-15 14:19:10 - Status changed: Fixed

  4. Christopher Kramer
    I just committed my fix to svn.
    
    Although I'd agree fileperms() is okay to use and the additional abstraction is not
    necessary, I consider this solution a bit better.
    
    I hope this fixes your issue as you expected. If not, feel free to reopen it.
    

    Reported by crazy4chrissi on 2013-02-15 14:20:25

  5. Log in to comment