Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Can a Perl script modify .htaccess

by soonix (Canon)
on Jul 22, 2019 at 21:50 UTC ( [id://11103175]=note: print w/replies, xml ) Need Help??


in reply to Can a Perl script modify .htaccess

yes

Replies are listed 'Best First'.
Re^2: Can a Perl script modify .htaccess
by SergioQ (Beadle) on Jul 23, 2019 at 01:38 UTC

    Sorry, I see my error now

    The documentation says my $obj = Apache::Htaccess->new($path_to_htaccess); and I took that to literally mean just the path.

Re^2: Can a Perl script modify .htaccess
by SergioQ (Beadle) on Jul 23, 2019 at 01:04 UTC

    My apologies I meant to say I tried that module. And it has so many warnings and I am having trouble figuring it out.

    I'll call  my $obj = Apache::Htaccess->new('/var/www/examplecom/public_html/');

    And I get

    Use of uninitialized value in substitution (s///) at /usr/local/share/ +perl/5.26.1/Apache/Htaccess.pm line 63. Use of uninitialized value in pattern match (m//) at /usr/local/share/ +perl/5.26.1/Apache/Htaccess.pm line 67. Use of uninitialized value in substitution (s///) at /usr/local/share/ +perl/5.26.1/Apache/Htaccess.pm line 68. Use of uninitialized value in substitution (s///) at /usr/local/share/ +perl/5.26.1/Apache/Htaccess.pm line 86. Use of uninitialized value in pattern match (m//) at /usr/local/share/ +perl/5.26.1/Apache/Htaccess.pm line 92.

    If there were some sample documentation maybe I'd have a chance. My knowledge base is extremely limited in Perl and Linux, and I've Googled this module a lot to try and find samples. So I was just thinking if I could run a Cron job to do what I needed to do that might be a way to get done what I was trying to do.

Re^2: Can a Perl script modify .htaccess
by SergioQ (Beadle) on Jul 23, 2019 at 05:02 UTC

    So after a lot of testing, and playing I finally got the correct code. However in the end the changes I make only get saved if someone other than root owns .htaccess

    Not sure whether this follow up question belongs here in the replies or in a new question, but what would be the safest ownership of .htaccess so that I can change it from Perl scripts run via CGI?

      Assuming that you have exhausted all the other, safer means of achieving the same goal then in your place I might:

      • Ensure AllowOverride is set to the smallest list feasible
      • Create a user and group specifically for this task
      • Ensure that only the files to be modified are owned by this user with tight perms (0644 should be easily lax enough)
      • Set up suEXEC for just the one script to be run by this user/group
      • Have an already-written contingency plan for when this system is broken into.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11103175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-28 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found