Wobbel has asked for the wisdom of the Perl Monks concerning the following question:

How can I change in a legal Perl way the user rights -full access- of my/our public folder and it's content? In our small department, we use a simple html-page (browser favorites) for "actual" documents and announcements etc. Everyone can dump his usefull documents in this folder. My Perl script generates an updated "index.html". New entries will be highlighted and older documents will be moved to a back up folder. Alternative: change user rights manually. I can change the user rights of my public folder -legal-manually for 60 different users under different log ins. And every week there is an update.... I use Cava packager for my simple scripts and they work! There is one "tiny" problem; user rights! Summary of the script: run my/our perl script, read the content of the documents in "my/our" folder and generate new hyperlinks, overwrite my/our existing "index.html"

Replies are listed 'Best First'.
Re: User rights and Perl
by cdarke (Prior) on Nov 03, 2009 at 12:48 UTC
    Which operating system? Operating systems have different security systems and ways to set them. For example on UNIX it is fairly easy to use chmod from Perl since it is a built-in, but on Windows you might have to use the Win32 API, which is quite complex.

    If you have a manual way of doing it, then call that program from Perl using system. It might not be the most efficient way of doing it, but will probably be the simplest.
Re: User rights and Perl
by scorpio17 (Canon) on Nov 03, 2009 at 14:17 UTC

    I'm assuming you're on a unix system.

    Here's one way you can let a group of people "share" a single, common web directory:

    Have each user create a "public_html" directory (chmod 755) inside their home directory for their personal web files. The files should be world readable (chmod 644).

    Then inside the real webpage root directory, create a symbolic link to each of the user's public_html directories.
    For example:

    ln -s /home/john_doe/public_html /var/www/public_html/john_doe

    Your perl script can now crawl the /var/www/public_html directory and build its index - just make sure that it knows how to follow symbolic links. If your using Apache, there's a special directive needed for symbolic links as well:

    <Directory "/var/www/public_html"> Options FollowSymLinks </Directory>

    (note that you may have more directives inside the "Directory" block, and the path to your web root may be different - but you get the idea).

    Another alternative is to switch to a full Content Management System (CMS) - google for it, you'll find lots of choices.

Re: User rights and Perl
by matze77 (Friar) on Nov 03, 2009 at 14:38 UTC

      Thanks a lot! At least two usefull starting points. Reading and testing, I'll be back!