Can't create digest password database tables

kcaseye - March 4, 2009 - 21:16
Project:Secure Site
Version:6.x-2.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I can't seem to create users in the digest password database. I know for a fact the mysql user is correctly created and the user has all privileges on the password database. (The password database currently has no tables in it, but I assumed the script would create those itself.) I gathered all of this information from the rather cryptic phrase in the documentation: "You can set up a password database in the same way you create a Drupal database."

I'm using MySQL 5.0.51 and php 5.2.6

I ran the following command and got this error message. Am I missing a step or is this a bug?

# php stored_passwords.php username='test' realm='realm' password='test' op='create'

Warning: BLOB/TEXT column 'realm' used in key specification without a key length
query: CREATE TABLE securesite_passwords (
`name` VARCHAR(60) NOT NULL DEFAULT '',
`realm` TEXT DEFAULT NULL,
`pass` VARCHAR(32) NOT NULL DEFAULT '',
PRIMARY KEY (name, realm),
INDEX name (name),
INDEX realm (realm)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /opt/local/apache2/htdocs/includes/database.mysql.inc on line 128

Warning: BLOB/TEXT column 'nonce' used in key specification without a key length
query: CREATE TABLE securesite_nonce (
`nonce` TEXT NOT NULL DEFAULT '',
`qop` TEXT DEFAULT NULL,
`nc` INT NOT NULL DEFAULT 0,
`opaque` TEXT DEFAULT NULL,
`hash` TEXT DEFAULT NULL,
`time` INT DEFAULT NULL,
`realm` TEXT DEFAULT NULL,
PRIMARY KEY (nonce, realm),
INDEX nonce (nonce),
INDEX opaque (opaque),
INDEX realm (realm)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /opt/local/apache2/htdocs/includes/database.mysql.inc on line 128

Warning: Table 'cerfcustomers.securesite_passwords' doesn't exist
query: SELECT name FROM securesite_passwords WHERE name = 'test' AND realm = 'realm' LIMIT 0, 1 in /opt/local/apache2/htdocs/includes/database.mysql.inc on line 128

Warning: Table 'cerfcustomers.securesite_passwords' doesn't exist
query: INSERT INTO securesite_passwords (name, realm, pass) VALUES ('test', 'realm', '') in /opt/local/apache2/htdocs/includes/database.mysql.inc on line 128
Failed to add test to realm.

#1

Andreas Wolf - March 13, 2009 - 19:54
Component:Documentation» Code

Hi,

I had the same problem. I helped myself with a quick and dirty solution.
I changed in the file digest_md5.conf.php :

function _securesite_schema() {

[...]
    'primary key' => array('name, realm(100)'),
    'indexes' => array(
      'name' => array('name'),
      'realm' => array('realm(100)'),
    ),

[...]
    'primary key' => array('nonce(100), realm(100)'),
    'indexes' => array(
      'nonce' => array('nonce(100)'),
      'opaque' => array('opaque(100)'),
      'realm' => array('realm(100)'),
    ),

This tells MySQL that for the index only the first 100 chars are relevant. Restriction of the index length seems to be mandatory for indexes on text fields.

I don't know if this change may
1) affect postgresql,
2) has some hidden implications on the module
so I do not submit a patch.

By the way:

# php stored_passwords.php username='test' realm='realm' password='test' op='create'

does not work for testing, try pass instead of password
# php stored_passwords.php username='test' realm='realm' pass='test' op='create'

I submit an extra bug report about this issue.

Also it took me quite some time to figure out why the sudo stuff did not work for me.
I was reading the readme.txt in the digest_md5 folder, assuming that there would be some kind of automatic sudo.
This assumption is wrong and the right way is mentioned in the online help:

On the Secure Site settings page, add sudo at the beginning of the line for the digest authentication script and the password storage script:
sudo /usr/local/digest_md5/digest_md5.php
sudo /usr/local/digest_md5/stored_passwords.php

This part is missing in the readme.txt, I submit an extra report about this too.
I just mention it here, because it may help you too.

I changed the component from documentation to code since it is a bug in the code and the subject of the bug is not related to a documentation issue.

#2

vrteach - March 31, 2009 - 13:54

I had the same problem, and the fix given in the first reply worked. Many thanks to Andreas Wolf.

Seems as though this is an important issue, and an easy fix.

 
 

Drupal is a registered trademark of Dries Buytaert.