Hi,

  Some time back we have faced necessity of mass
  authorization of our VPN-clients which were connected to our server
  using mpd, through a MySQL-database. Thus I have made patch for
  mpd-3.10 for the built-in support mysql authorizations.

  May be code is not very clean and well styled, but it works! It
  works on our servers for about 3 or 4 weeks without problems, so I
  decided to send it here, to hear what guru thinks about that, and
  also someone else can will find this thing useful to itself.

  Patch adds 5 new configuration directives:

  mysql_hostname defines a host, where mysqld is running

set bundle mysql_hostname localhost

  mysql_database defines a database to use

set bundle mysql_database users

  mysql_username and mysql_password defines a mysql user and
  password with enough privileges to make sql request, specified in mysql_sql

set bundle mysql_username someuser
set bundle mysql_password somepassword

  and mysql_sql defines an sql expression, which will be passed to
  mysql server to get credential for login, which is substituted
  instead of "%s". Expression should return one row with three fields:
  login, password and optionaly ip address (or NULL or empty string),
  just like a format for mpd.secret

set bundle mysql_sql "SELECT login, password, INET_NTOA(ip) FROM users WHERE 
login='%s' AND active=1 LIMIT 1"

  MySQL authentification is used when all these directives
  are defines, if one of them is missing - usual mpd.secret is used.

  That's all. I wait with impatience for comments.
  
-- 
Best regards,
 Vadim A. Shklyaev
 mailto:[EMAIL PROTECTED]

Attachment: mysql_auth-mpd-3.10.tgz
Description: application/compressed

Reply via email to