Page 1 of 1

.htpasswd problem

Posted: Wed May 14, 2003 4:49 pm
by jchibbra
Hi,

I have the following problem with my .htpasswd.
when I use the htpasswd program it works fine. I can protect my directory.
when I use php and the following code to create the .htpasswd I have an authentication failure. I guess the .htpasswd hasn't been created fine.

code:
------
$log="toto";
$pass="toto42";
$htpasswd_txt .= "$log:".crypt($pass,CRYPT_STD_DES)."\n";
$htpasswd = fopen(".htpasswd", "w");
$r = fputs($htpasswd, $htpasswd_txt);
fclose($htpasswd);

so when I have the popup for login/passwd I put toto and toto42 and I cannot access the directory.
And the log told me that it is an authentication failure:

user toto: authentication failure for "/path/to/the/file/index.htm": password mismatch

Is someone know why?

Posted: Thu May 15, 2003 12:52 am
by volka
can you build an example password via htpasswd and post it here?

Posted: Thu May 15, 2003 8:35 am
by jchibbra
.htaccess:
------------

AuthUserFile "/var/www/vhost1/https/.htpasswd"
AuthName UserAuthentication
AuthType Basic
require valid-user

its path is: "/var/www/vhost1/http/galleries/rep1/.htpasswd"

and of course my .htpasswd is in :"/var/www/vhost1/https/"
the thing I don't understand is why with "htpasswd" it works and just after I use my function to create the .htpasswd and it doesn't work?

let me know if you need more information

Posted: Thu May 15, 2003 9:12 am
by volka
I meant an actual password, so we can see which algorithm has been used ;)

Posted: Thu May 15, 2003 12:15 pm
by jchibbra
Sorry :-)

for the example I took toto/toto42 as login/pass.
With htpasswd function the .htaccess looks like:
toto:2qm.tGvVQqiJY

when I use the my php function which is:
$log="toto";
$pass="toto42";
$htpasswd_txt .= "$log:".crypt($pass,CRYPT_STD_DES)."\n";
$htpasswd = fopen(".htpasswd", "a");
$r = fputs($htpasswd, $htpasswd_txt);
fclose($htpasswd);

the .htaccess looks like:
toto:1$5AVXvgnuw2.

Obviously they are different because they don't use the same seed to crypt.

Do you have any idea?

Posted: Thu May 15, 2003 12:24 pm
by jchibbra
I have only 1 thing to say:

@#$$%$#@%$#@ Windows.

because it works now. I restarted my computer and it works.
I really don't understand because every time I try with each of them (htpasswd and my function) I took all the precaution like closing the IE and reopen a new one.
And now it works.

I am really sorry if you wasted some times. :oops:

windows ?ucksssssssssss :)