For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > using htpasswd from perl script









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using htpasswd from perl script
Graeme McLaren

2005-07-24, 8:29 pm

Afternoon all, I was thinking about writing a perl script which would add
users to an .htaccess file.

How would I invoke htpasswd from a perl script? I'm thinking I'll need to
use the system command.


Cheers for any tips.


Graeme :)


JupiterHost.Net

2005-07-24, 8:29 pm



Graeme McLaren wrote:
> Afternoon all, I was thinking about writing a perl script which would
> add users to an .htaccess file.
>
> How would I invoke htpasswd from a perl script? I'm thinking I'll need
> to use the system command.


system or backticks or qx() but you'd probably be better off with a Module:

http://search.cpan.org/search?query...ess&mode=module
Thomas Bätzler

2005-07-24, 8:29 pm

JupiterHost.Net <mlists@jupiterhost.net> suggested:

> Graeme McLaren wrote:
>
> system or backticks or qx() but you'd probably be better off
> with a Module:
>
> http://search.cpan.org/search?query...ess&mode=module


Better yet, use mod_auth_mysql in your apache and manage
users, groups and passwords in a database table. This
should be a bit more secure than giving your web user
write access to a .htpasswd file.

HTH,
Thomas
JupiterHost.Net

2005-07-24, 8:29 pm

>>http://search.cpan.org/search?query...ess&mode=module
>
>
> Better yet, use mod_auth_mysql in your apache and manage
> users, groups and passwords in a database table. This
> should be a bit more secure than giving your web user
> write access to a .htpasswd file.


so you give your webuser** write access (IE INSERT/UPDATE) to your
..htpasswd-ish table? :)

I do like mod_auth_mysql but his question wasin regard to htpasswd type
interaction. So while its ogod to recommend alternative methods its not
really "Better yet" :)

** ok technically its the user connecting via DBI. which now you have to
worry about the world getting the auth data from the script. Personally,
mod_auth_mysql does have many advantages but security is not really one
of them.

For security you run under suexec then 700 on scripts and 600 on files
will be "secure". Then with .htpasswd or mod_auth_myslq I am "secure"
and can use whichever fits my needs.
Graeme McLaren

2005-07-24, 8:29 pm

Guys, thank you for your replies!

using .htaccess from the command line:

bash-2.03# /usr/local/apache/bin/htpasswd /path/to/auth/file/auth_file
username
New password:
Re-type new password:
Adding password for user username

How would I do this using that module? From what I can see there doesn't
seem to be anything that adds usernames. How do I do that?

# does this line mean the path to .htaccess file is passed to the
constructor?
# how does it know which auth file to use?
my $obj = Apache::Htaccess->new($path_to_htaccess);

Cheers for any more tips you can share.

Graeme :)


>
>
>
>Graeme McLaren wrote:
>
>system or backticks or qx() but you'd probably be better off with a Module:
>
>http://search.cpan.org/search?query...ess&mode=module
>
>--
>To unsubscribe, e-mail: beginners-unsubscribe@perl.org
>For additional commands, e-mail: beginners-help@perl.org
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>



JupiterHost.Net

2005-07-24, 8:29 pm



Graeme McLaren wrote:
> Guys, thank you for your replies!
>
> using .htaccess from the command line:
>
> bash-2.03# /usr/local/apache/bin/htpasswd /path/to/auth/file/auth_file
> username
> New password:
> Re-type new password:
> Adding password for user username
>
> How would I do this using that module? From what I can see there
> doesn't seem to be anything that adds usernames. How do I do that?


http://search.cpan.org/search?query...swd&mode=module
http://search.cpan.org/search?query...ess&mode=module
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com