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

I'm not able to run htpasswd.exe from the web. My server error log tells me it's not able to create a certain temp file. I'm not concerned with any security problems, because there are already security measures that will prevent any unwanted parties from reaching that point in the program.

Is there some Apache:: module for doing what htpasswd does?

I guess what I could do is use my own authentication module so I don't have to use htpasswd.exe...

<Directory /foo/bar> AuthName "Foo Bar Authentication" AuthType Basic PerlAuthenHandler Apache::AcaciaPasswd require valid-user </Directory>
... where Apache::AcaciaPasswd does its own thing. Is that probably the easiest solution?
_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: (OT) Is there some Apache:: module for htpasswd work?
by matthewb (Curate) on Feb 18, 2004 at 05:07 UTC
    Is there some Apache:: module for doing what htpasswd does?

    Apache::Htpasswd?

    MB
Re: (OT) Is there some Apache:: module for htpasswd work?
by b10m (Vicar) on Feb 18, 2004 at 14:01 UTC
    My server error log tells me it's not able to create a certain temp file.

    I am pretty sure Apache told you a little bit more specific which temp file couldn't be created. And from such an error, I would look at the directory the temp file is trying to be created in. I'd say that directory doesn't include writing permissions for your Apache user.

    I'm not concerned with any security problems, because there are already security measures that will prevent any unwanted parties from reaching that point in the program.

    Ermmm, ok, if you say so ;)

    I guess what I could do is use my own authentication module so I don't have to use htpasswd.exe...

    Yes, you could do that, but AFAIK, htpasswd doesn't do anything awefully difficult. It opens a file, adds a line with `username:password`, in which the password is "encrypted". IIRC, it's just a MD5'ed password, so you can easilly do this yourself from within perl. See for example Digest::MD5.

    HTH

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: (OT) Is there some Apache:: module for htpasswd work?
by greenFox (Vicar) on Feb 19, 2004 at 03:44 UTC
    Apache::Htpasswd does what you want. My review contains some code samples.

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

Re: (OT) Is there some Apache:: module for htpasswd work?
by japhy (Canon) on Feb 19, 2004 at 04:33 UTC
    I installed mod_perl, and then I found Apache::Authen::Program. I modified the code to come up with my own authentication module.

    What's cool is that now I can make my own "require" statements.

    <Directory ...> AuthName "Foo Bar Authentication" AuthType Basic PerlAuthenHandler Apache::AcaciaAuthen require valid-user require deny ~^tmp </Directory>
    where "deny" ensures the user is not one of the given users, and a username starting with "~" is treated like a regex done on the username. Yay Apache! Yay mod_perl!
    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;