Sure, you could re-evaluate permission checks of your OS and emulate access before running the real application. But, you'll probably never get the tests 100% waterproof and will have to rely on your runtime checks.

The problem with the let it run and see approach is that some services can run a remarkably long time before a problem becomes visible, e.g. when an exceptional condition occurs that requires to save some evidence to a file and certainly - no permission. And there's also a chance that the application/system is left in an inconsistent state.

From my experience, it's better to have a clear and structured permission- and ownership-plan for a given set of directories and applications and to strictly adhere to this plan.

This concept is usually supported by catching exceptions at run-time (as you already do - but that is a second line of countermeasure) plus an automated mechanism (update-script) that enforces correct ownerships and permissions for file-types and - where necessary - individual files. It might be useful to let this script also create (empty) directory-trees.

Since your application-starter now can expect with confidence that the environment (permissions, ownerships) has a consistent and predictive state (remember update-script), things become easy for your application(-starter). It just has to check if the user belongs to a group (or set of groups) that is permitted to run a certain application (role: application). Sometimes you need another role for programs that update your files or need higher permissions (role: application-adm). If some of your programs are executed with root-permission - and you cannot avoid that - let those files be owned by root.

The whole concept can be scripted (update-script) and automated (e.g. cron). In extreme, the update-script is started before you run the application. This catches a lot of problems that can occur if e.g. someone has updated/installed files and forgot to set proper permissions/ownerships.

So, my advice is to separate permission/ownership-management (an administrative task) from application-startup (an operational task). YMMV, but I successfully run this (old school?) approach in one of our environments for years without any problems.
HTH


In reply to Re: How do I check if another user can access a file? by Perlbotics
in thread How do I check if another user can access a file? by mtnboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.