MySQLAuth External Authentication Module for DMail

An external authentication module that allows DMail to do user lookups on a MySQL Database.


Installing MySQLAuth

When you look for MySQLAuth in your DMail distribution, you should find two files:

unix nt
mysqlauth
mysqlauth.ini
mysqlauth.exe
mysqlauth.ini

(If you cannot find these files see, Download and History for MySQLAuth)

Place these files into your dmail directory and update dmail.conf to point to this external module.

e.g. on UNIX
    authent_method external
    authent_process /usr/local/dmail/mysqlauth
and on Windows:
    authent_method external
    authent_process c:\dmail\mysqlauth.exe

Then you must edit the mysqlauth.ini file so that it points to your MySQL server. More details on this step are provided on the rest of this page.

NB: You should locate the ini file in the same directory as the mysqlauth binary or as,
/etc/mysqlauth.ini (on UNIX based platforms)
or,
c:\winnt\system32\mysqlauth.ini (on Windows platforms)

And then RESTART both DSMTP and DPOP.

NB: you must RESTART both DSMTP and DPOP whenever you change your mysqlauth.ini file, as they spawn copies of MySQLAuth which only read mysqlauth.ini at startup.

And that's it. For details on other External Authentication Settings see the User Administration section of the DMail Manual.


Creating/Using a MySQL Database

MySQLAuth requires a MySQL database which is setup and working. The database that is setup must have a username and a password that is encrypted using the mysql command PASSWORD(). You can either create a new database/table for MySQLAuth or use a current database that has usernames and passwords.

New DataBase:

Below are instructions on how to setup a brand new database and table to work with MySQLAuth, with all of the features that MySQLAuth provides.

CREATE DATABASE maildb

USE maildb;

CREATE TABLE maildb (
        username CHAR(128) binary DEFAULT '' NOT NULL,
        passwd CHAR(128) DEFAULT '*' NOT NULL,
        forward CHAR(255) DEFAULT '',
        quota CHAR(20) DEFAULT '',
        mailmask CHAR(18) DEFAULT '0.0.0.0' NOT NULL,
        maildrop CHAR(255),
        PRIMARY KEY (username)
);

To insert a brand new account into this account using your sql the command is:

INSERT INTO maildb VALUES
     ('test@test.org', PASSWORD('test'), '', '100k',
      '0.0.0.0','/usr/spool/mail/test');

This will create a user called test@test.org with the username of test.

To manually remove a user the command is:

DELETE FROM maildb WHERE username='test@test.org'

The inserting and deleting of users is usually taken care of by MySQLAuth. The above is to show how you would do this manually.

The ini settings for the above would look like the following:

mysql_server your.sql.server
mysql_login login
mysql_password password

domain your.default.domain

mysql_mail_user_db maildb
mysql_mail_user_table maildb

field_username username
field_password passwd
field_forward forward
field_quota quota
field_mailmask mailmask
field_maildrop maildrop

 

Using Current DataBase:

If you already have an existing database which you wish to use, then as long as the usernames are unique and the password field is encrypted using the PASSWORD() mysql command you should simply be able to change the ini settings to point to this database, table and field label names.

eg. If you have a database called 'accounts' and a table called 'mail_users' that stores all sorts of information but has the username field names 'name' and the password field called 'pwd' then the ini settings that you required are:

mysql_server your.sql.server
mysql_login login
mysql_password password

domain your.default.domain

mysql_mail_user_db accounts
mysql_mail_user_table mail_users

field_username name
field_password pwd

If you also have the ability to store the mail quota or forwarding, then you can add these ini settings as well...

ie.    field_forward forward
        field_quota quota


Check Install

Once MySQLAuth is installed, it is best to check immediately that MySQLAuth is working correctly. You will need to run MySQLAuth from the command line (in a dos box on Windows) and try the following.

NOTE:    C: - Client, S: - Server

./mysqlauth

C: set test_account password
S: +OK 'test_account@test.org' has been added to database

C: set test_fwd password fwd="test_account@domain1"
S: +OK 'test_account@test.org' has been added to database

C: set test_quota password quota="100k"
S: +OK 'test_account@test.org' has been added to database

C: set test password fwd="test_account@domain1" quota="100k"
S: +OK 'test_account@test.org' has been added to database

C: search *
S: +DATA test_quota@test.org config 0 quota="100k"
S: +DATA test_fwd@test.org config 0 fwd="test_account@domain1"
S: +DATA test_account@test.org config
S: +DATA test@test.org config 0 fwd="test_account@domain1" quota="100k"
S: +OK Search Completed 4 items found

C: lookup test_quota
S: +OK test_quota@test.org config 0 quota="100k"

C: lookup test
S: +DATA test@test.org config 0 fwd="test_account@domain1" quota="100k"

C: check test password
S: +OK test@test.org config 0 fwd="test_account@domain1" quota="100k"

C: check test incorrect
S: -ERR test@test.org password wrong or not a valid user

C: del test
S: +OK 'test@test.org' has been deleted

C: del test_account
S: +OK 'test_account@test.org' has been deleted

C: del test_quota
S: +OK 'test_quota@test.org' has been deleted

C: del test_fwd
S: +OK 'test_fwd@test.org' has been deleted

The acutal response with quota and fwd might vary if the mysql database does not have quotas or fwd setup. In order to display the complete list of commands that MySQLAuth supports, enter the command:

help

Information about the protocol being used can be found in the DMail manual:

User Administration , External Authentication Protocol section


MySQLAuth.ini settings

If you need an mysqlauth.ini to start with, download, mysqlauth.ini.

Label

Example

Default

Explanation

debug true false Enables verbose debug output.
domain your.default.domain none This is default domain that is appended to any username which does not already have a domain setting attached.
field_username user username The label of the username field in your table.
field_password password passwd The label of the password field in your table.
field_forward fwd forward The label of the forward field in your table. This is the fowarding information that DMail uses to determine whether mail for the account looked up should be delivered to a different address.
field_quota quota none The label of the quota field in your table. This is the disk quota which the user has.
          e.g. 100k,  10M
field_mailmask mailmask none The label of the mailmask field in your table. This is the IP mask which MySQLAuth checks against the from IP of the user. If specified, this forces the user to connect only to the specified IP in order to collect mail (POP).
field_maildrop maildrop none The label of the maildrop field in your table. This is the location where dmail will drop the user mail files. NB: if the field value is empty in the database (NULL), mysqlauth will return the keywork 'config' indicating that the server knows where to locate the drop file.
log_path mysqlauth.log auth.log This is the mysqlauth log file.
mysql_server your.sql.server none This is the IP or name of the computer hosting the mysql server.
mysql_login username none This is the username that has access to the correct database and table that stores the usernames and passwords.
mysql_password password none This is the password that is required and used in conjuction with mysql_login.
mysql_mail_user_db user_data maildb This is the database name where the mail usernames are stored.
mysql_mail_user_table users_list maildb This is the table name that is within the mail user database that has the user details.
mysql_mail_uid 99 0 This is the unique mail ID. NB: by default, mysqlauth returns 0 for this, which indicates to the DMail Servers that the userid should not be checked.


A step by step example of creating a mysqldatabase on NT

Below is an unedited example of setting up a mysql database to test on a Windows NT box.

1. Downloaded from a mysql mirror site (they like it when you use a mirror),
mysql-shareware-3.22.32.win.zip
and unpacked to,
d:\mysql

2. Edited example file, d:\mysql\my-example.cnf that came with it, so that, all c:'s were changed to d:, and saved as,
c:\my.cnf
(notepad named it c:\my.cnf.txt for me so I did a rename on it in a dos prompt)

3. In order to install as service on NT...

d:\mysql\bin>mysqld-shareware --install

NB: when I then tried to start service in ControlPanel|Services, it failed with a message saying that the process had stopped itself.

so I entered...

d:\mysql\bin>mysqld-shareware --debug
and at the top of all the mess was an error about a setting in the my.cnf file that it did not like.

NB: if I ran it from a command line, it started and could not be stopped, even with a CTRL-C - I had to kill it in process list of task manager. In the bin dir was an exe mysqlshutdown, which just popped up a window (Icon in system tray), but I could not get it to stop the process - maybe it is for stopping the service? - no does not seem to affect that either - kind of a cute icon though :-)
The dos command,
net stop mysql
does work as does,
net start mysql
.

4. Creating root user.

NB: our sqlauth module makes you send a password. By default, the mysql daemon has a root user with no password, so you need to set the root password to something.

From the mysql manual ...
(The following example starts by removing the anonymous user. That allows anyone to access the 'test' database)

d:\mysql\bin\mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
d:\mysql\bin\mysqladmin reload
d:\mysql\bin\mysqladmin -u root password your_password

NB: I had problems getting the root password set after deleting it. I ended up entering the following to set the root password...

D:\mysql\bin>mysqlc -u root mysql
Reading table information for completion of table and column names

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 3.22.32-shareware-debug

Type 'help' for help.

mysql> UPDATE user SET Password=PASSWORD('qwerty') WHERE user='root';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

Now in c:\my.cnf edit client section and add,
password=qwerty
and save.

Now you should be able to connect with the client program as user root with the new password...

5. Now follow the examples in the manual.

In section 8.4 of the manual file,
d:\mysql\docs\manual.htm
start client (on local machine - same as ...

D:\mysql\bin>mysqlc -u root -pqwerty

(can also do,
D:\mysql\bin>mysqlc -u root -p
and it prompts for password so that your command prompt buffer does not contain your password if you are worried about that sort of security)

(on non-local machine,
D:\mysql\bin>mysqlc -u root -pqwerty -host=1.2.3.4
)

(NB: you can also include a database name on the end of the line to connect to a specific database, e.g. to connect to a database called, 'mydb' enter,
D:\mysql\bin>mysqlc -u root -pqwerty mydb
)

every time you see 'mysql>' from now on, it indicates that you are at the prompt in the mysqlc client program...

6. Create test database and a table within it ...

mysql> CREATE DATABASE maildb;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE TABLE maildb (username VARCHAR(20),password VARCHAR(20),forward VARCHAR(20));
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW TABLES;

+------------------+
| Tables in maildb |
+------------------+
| maildb           |
+------------------+
1 row in set (0.01 sec)

mysql> DESCRIBE maildb;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(20) | YES  |     | NULL    |       |
| password | varchar(20) | YES  |     | NULL    |       |
| forward  | varchar(20) | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

7. Loading users in from a text file ...

I then made a file d:\mysql\users.txt which looked like,

tam pass \N
test test \N

where \N stands for NULL meaning no entry for that field. and then tried to load it. You'll see I assumed a few things about file paths incorrectly. I remember reading in the manual somewhere about using / instead of \ (or using \\).

mysql> LOAD DATA LOCAL INFILE "users.txt" INTO TABLE maildb;
ERROR: File 'users.txt' not found (Errcode: 2)
mysql> LOAD DATA LOCAL INFILE "d:\MYSQL\users.txt" INTO TABLE maildb;
ERROR: File 'd:MYSQLusers.txt' not found (Errcode: 2)
mysql> LOAD DATA LOCAL INFILE "d:/MYSQL/users.txt" INTO TABLE maildb;
Query OK, 2 rows affected (0.02 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 0

8. Inserting a single record/updating a field/encrypting passwords ...

(use 'NULL' where you don't have an entry for a field)

mysql> INSERT INTO maildb VALUES ('bob','bob','NULL');
Query OK, 1 row affected (0.01 sec)

oops - should have encrypted the password ...

mysql> UPDATE maildb SET password = PASSWORD('bob') WHERE username = 'bob';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

so how do I add from text file and encrypt the passwords ...?

I can't work out how to do this, so I had better encrypt all the other passwords ...

mysql> UPDATE maildb SET passwd = PASSWORD('tam') WHERE username = 'tam';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> UPDATE maildb SET passwd = PASSWORD('test') WHERE username = 'test';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Now, let's see what I have in my maildb database ...

mysql> SELECT * FROM maildb;

+----------+------------------+---------+
| username | password         | forward |
+----------+------------------+---------+
| tam      | 6752d6483e543e43 | NULL    |
| test     | 378b243e220ca493 | NULL    |
| bob      | 7d67547927a4589e | NULL    |
+----------+------------------+---------+
3 rows in set (0.01 sec)

oops - I gave the wrong name to my table column 'password' ...

8. Changing a table column name ...

mysql> ALTER TABLE maildb CHANGE 'password' 'passwd' VARCHAR(20);
ERROR 1064: You have an error in your SQL syntax near ''password' 'passwd' VARCH
AR(20)' at line 1
mysql> ALTER TABLE maildb CHANGE password passwd VARCHAR(20);
Query OK, 3 rows affected (0.19 sec)
Records: 3 Duplicates: 0 Warnings: 0

Now let's see what is in my maildb database again ...

mysql> SELECT * FROM maildb;

+----------+------------------+---------+
| username | passwd           | forward |
+----------+------------------+---------+
| tam      | 6752d6483e543e43 | NULL    |
| test     | 378b243e220ca493 | NULL    |
| bob      | 7d67547927a4589e | NULL    |
+----------+------------------+---------+
3 rows in set (0.01 sec)


A step by step example of creating a mysqldatabase on Solaris

Went to Australian mirror of http://mysql.com , http://mirror.aarnet.edu.au/mysql and downloaded,

mysql-3.23.32-sun-solaris2.7-sparc.tar.gz
then umpacked to /usr/local with, gzip -d mysql-3.23.32-sun-solaris2.7-sparc.tar.gz (I had already retrieved gzip for solaris from the sun freeware site, see instructions for getting GNU tar below for details)

I tried to untar but failed, apparently because of a bug in solaris tar.

So I upgraded to GNU tar by...

# cd /usr/local/ # ftp sunfreeware.davnet.com.au
(login with username) anonymous
(give email address) my_email_address
ftp> bin
ftp> hash
ftp> cd pub/freeware/sparc/7
(NB: I am running solaris 7)
ftp> get tar-1.13-sol7-sparc-local.gz
ftp> quit
Then add package with
# gzip -d tar-1.13-sol7-sparc-local.gz
# pkgadd -d tar-1.13-sol7-sparc-local
(selected pressed return twice for,
1. install all packages
2. allow it to overwrite attributes on some files already there (I presume they
were the old tar)
)
Untared with,
tar -xvf mysql-3.23.32-sun-solaris2.7-sparc.tar
Then followed relevant instructions on page,
http://mirror.aarnet.edu.au/mysql/doc/I/n/Installing_binary.html
i.e.,
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
had already done this, shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db
{

# scripts/mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables

In order to start mysqld at boot time, you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
This is done with:
./bin/mysqladmin -u root -p password 'new-password'
./bin/mysqladmin -u root -h fluffy -p password 'new-password'
See the manual for more instructions.

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com


}
shell> chown -R mysql /usr/local/mysql
shell> chgrp -R mysql /usr/local/mysql
shell> bin/safe_mysqld --user=mysql &

(If you want to install support for the Perl DBI/DBD interface, see section 4.11 Perl Installation Comments. )

# bin/safe_mysqld --user=mysql &
[1] 7710
# Starting mysqld daemon with databases from /usr/local/mysql-3.23.32-sun-solaris2.7-sparc/data
Abort
010202 11:30:07 mysqld ended

Hmmm, seems not to be working when I do, ps -ef |grep mysql, so find manual section,
4.16.2 Problems Starting the MySQL Server
which informs me that log is in,

/usr/local/mysql/data/servername.err

which has,
010202 12:00:00 mysqld started
010202 12:00:00 bdb: /usr/local/mysql-3.23.32-sun-solaris2.7-sparc/dataalog.00
00000001: Permission denied

So check permissions...

# ls -l
total 18
drwxr-xr-x 2 502 1003 1024 Jan 22 18:56 bin
drwxr-x--- 4 502 1003 512 Feb 2 11:30 data
drwxr-xr-x 2 502 1003 1024 Jan 22 18:56 include
drwxr-xr-x 2 502 1003 512 Jan 22 18:56 lib
drwxr-xr-x 2 502 1003 512 Jan 22 18:56 scripts
drwxr-xr-x 3 502 1003 512 Jan 22 18:56 share
drwxr-xr-x 5 502 1003 512 Feb 2 10:41 sql-bench
drwxr-xr-x 2 502 1003 512 Jan 22 18:56 support-files
drwxr-xr-x 2 502 1003 512 Jan 22 18:56 tests
and when su to the mysql users,
# cd data
bash: cd: data: Permission denied
but,
chown -R mysql mysql
should have recursed all dirs - perhaps the solaris chown only goes one level deep?!
so did,
cd /usr/local/mysql
chwon -R mysql ./*
chgrp -R mysql ./*
then as root user I try again,
bin/safe_mysqld --user=mysql &
and get,
# Starting mysqld daemon with databases from /usr/local/mysql-3.23.32-sun-solaris2.7-sparc/data (I pressed enter here) #
Yay!

Now did the tests from the manual,

shell> bin/mysqladmin version
shell> bin/mysqladmin variables

In order to use MySQLAuth, you have to have set the root password, so ...
using the instructions given above,

# bin/mysqladmin -u root -p password 'qwerty' Enter password: (I pressed enter here as there was no password currently set) #

So root password should now be 'qwerty'
check with,

# bin/mysqladmin version
bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'
and it fails when it did not before, so try,
# bin/mysqladmin -u root -p version
Enter password: (enter qwerty here)
and it worked. Success.

Test running SQL client,

# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 3.23.32

Type 'help;' or '\h' for help. Type '\c' to clear the buffer

mysql> select version(), current_date;

+-----------+--------------+
| version() | current_date |
+-----------+--------------+
| 3.23.32   | 2001-02-02   |
+-----------+--------------+
1 row in set (0.02 sec)

mysql>
Success.

Now test mysqlauth from NT box with c:\winnt\system32\mysqlauth.ini of,

# Welcome to MySQLAuth ini File.
# Leading # makes line a comment
# Save this file to /etc/mysqlauth.ini or c:\winnt\system32\mysqlauth.ini or
# in same directory as executable.
# Manual page is at, http://www.netwinsite.com/dmail/mysqlauth.htm
# -------------------------------------------------------------------------------------

# IP address of server to connect to:
mysql_server 10.0.0.2
# Login username and password:
mysql_login root
mysql_password qwerty

# MySQL Table Field Names
# ---------------------
field_username username
field_password passwd
field_forward forward

# Other common INI settings for MYSQLAuth
# --------------------------
# debug true
log true
log_path c:\dmail\mysqlauth.log
# domain test.com
# mysql_mail_user_db maildb
# mysql_mail_user_table maildb

and enter,

cd \dmail
mysqlauth
and get error,
-ERR: Cannot Connect to 10.0.0.2 as root
try,
telnet 10.0.0.2 3306
and get,
'server_name' is not allowed to connect to this MySQL server

So we need to allow access...

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature in order to get a quicker startup with -A

Database changed
mysql> select database();

	+------------+
	| database() |
	+------------+
	| mysql      |
	+------------+
	1 row in set (0.00 sec)

	mysql> show tables;
	+-----------------+
	| Tables_in_mysql |
	+-----------------+
	| columns_priv    |
	| db              |
	| func            |
	| host            |
	| tables_priv     |
	| user            |
	+-----------------+
	6 rows in set (0.00 sec)

	mysql> select * from user;
	+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
	| Host      | User | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
	+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
	| localhost | root | 009094026f11b5c7 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
	| fluffy    | root |                  | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
	| localhost |      |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
	| fluffy    |      |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
	+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
	4 rows in set (0.00 sec)
	
Manual says to use commands rather than touching the table directly. Want to change host from,
localhost
to
10.0.0.*
(or maybe the special char % to allow connections from anywhere) so,
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
Oops I did not put in the correct password. so now I have,
mysql> select * from user;
+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
| Host      | User | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
| localhost | root | 009094026f11b5c7 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
| fluffy    | root |                  | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
| localhost |      |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
| fluffy    |      |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
| %         | root | 0fc756bc026507b2 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
+-----------+------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
5 rows in set (0.01 sec)
where root connecting from anywhere can use password some_pass, and if connecting locally can use qwerty!

So now try adding a special user, dmail password of mail,

mysql> GRANT ALL PRIVILEGES ON *.* TO dmail@"%" IDENTIFIED BY 'mail' WITH GRANT OPTION;
NB: GRANT is implemented in MySQL Version 3.22.11 or later. For earlier MySQL versions, the GRANT statement does nothing.
mysql> select * from user;
+-----------+-------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
| Host      | User  | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
+-----------+-------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
| localhost | root  | 009094026f11b5c7 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
| fluffy    | root  |                  | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
| localhost |       |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
| fluffy    |       |                  | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          |
| %         | root  | 0fc756bc026507b2 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
| %         | dmail | 64d94ec17fb953a4 | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          |
+-----------+-------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
6 rows in set (0.00 sec)

(and can revoke them again,

mysql> REVOKE ALL PRIVILEGES ON *.* FROM dmail@"%";
mysql> flush privileges;
)

Let's try from local box, so on solaris box set /etc/mysqlauth.ini as above but change,

mysql_server 10.0.0.2
to
mysql_server 127.0.0.1
just to be sure connecting locally. we get,
# ./mysqlauth
-ERR: Cannot Connect to database maildb
so connection to the server was successfull, now we need to add an appropriate database and table as per the NT example above.

Download and History for MySQLAuth

Generally you will find the latest download in with your distribution set. You can check what version of mysqlauth you have by running mysqlauth at a command prompt, e.g.,
c:\dmail\mysqlauth -version

If we put a download on the site for a version, it will be listed in the history below as a link.

Here is the download for an example mysqlauth.ini file if you need it,
mysqlauth.ini

Known Bugs:

A customer reports that it would seem that the mysql,user table entry, i.e. the entry that holds the username and password that mysqlauth connects as, must allow access from anywhere. We suspect that this is just an intricacy of the permission system used by MySQL. However, in testing we have found that almost the reverse is true, we had to add the user twice, once for connections from 'localhost' AND once for connections from '%'. If you want to test this ...
You can use the following in order to add a login account for a user called, 'dmail' with a password of 'mail', where that user can login from anywhere,

GRANT ALL PRIVILEGES ON *.* TO dmail@"%" IDENTIFIED BY 'mail' WITH GRANT OPTION;
FLUSH PRIVILEGES;
and the following can be used to restrict it back to connections from localhost only,
use mysql;
UPDATE user SET Host = 'localhost' WHERE User = 'dmail';
FLUSH PRIVILEGES;
and the solution we had to use to allow both local and non-local connections was,
GRANT ALL PRIVILEGES ON *.* TO dmail@"localhost" IDENTIFIED BY 'mail' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO dmail@"%" IDENTIFIED BY 'mail' WITH GRANT OPTION;
FLUSH PRIVILEGES;

History:

1.0q TRW 21 Feb 2001 (mysqlauth10q_libc6 binary)
     - Fixed bug where search returned a user with null password (caused seg fault on linux) (sql_select was strdup(NULL))
     - added mysql_emsg which prints mysql client library errno and error message
     - fixed bug where set would try to set NULL values for any fields set in ini file but not entered on set line (depending on table setup fields may or may not allow NULL values, so best not to set them rather than set them to NULL).
     - added settings, sqlsuffix_lookup_where sqlsuffix_search_where so that lookup SQL statement becomes, SELECT username,password,fwd FROM maildb WHERE username='bob' ; e.g. sqlsuffix_lookup_where SELECT username,password,fwd FROM maildb WHERE username='bob' and attribute='Password';
     - added setting, sqlsuffix_set so that set command will always have added, e.g., INSERT INTO maildb SET username='tam', value=PASSWORD('tam') ; (also used on the del command as well as the set command).
     - added setting, domain_split If set, then on set, user@domain will be split into user and domain, so that username added is just 'user' and the field db_domain_field is set with the value 'domain'. If the username entered does not have a domain then the domain setting value will be used if it is set. Otherwise, nothing is set in the db_domain_field. Similarly, on a lookup, check or search the username will be split up and the WHERE clause will contain filter on, db_domain_field='domain'. For del it does the same as for set.
     - removed support for mod command as was doing it in a dangerous manner - needs to be rethought before adding back in.
     - startup log shows values of ini settings found in log.

1.0p TRW 31 Oct 2000
    - added -insensitive option, for case insensitive matches on username.

1.0o 14 Aug 2000 (also in dmail 2.9a)
    -fixed sql_del command using fixed username field.
    mysqlauth10o_libc6 (you may need to use Command line FTP to get this file uncorrupted)
    mysqlauth10o.zip (For Windows 95/98/NT/2000)

1.0n
    -fixed death when no field_alias setting given.

1.0m (in dmail 2.8 versions)
    mysqlauth10m_solarissparc.tar.Z

1.0g 28 June 2000
    fixed responses so that a uid is always given, previously might respond, '+ok username path' which breaks E.A.P.





 

 
Products Downloads Prices Support Company