Jump to content
Калькуляторы

freeradius 3 + rlm_perl + mysql

Всем привет. В freeradius 2 была такая ф-ция CLONE, в которой можно было инициализировать db коннектор. В freeradius 3 её , я так понял не стало. Вывернулся объявив:

use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK $db);
...
sub DBCONN {
    if ( ! defined $db ){
        $db = DBI->connect("dbi:mysql:dbname=".DB_NAME.";host=".DB_HOSTNAME, DB_USER, DB_PASS, {'RaiseError' => 1});
    if ($DBI::err) {
            &ERROR("DB Connect Error. $DBI::errstr");
    }
    else {
        &INFO("DB Connect Success");
    }
    }
}

и вызываю DBCONN в каждой процедуре: authorize, accounting_start, accounting и т.д. Это есть правильно или надо както по другом? Спасибо

Edited by ichthyandr

Share this post


Link to post
Share on other sites

Попробуй вставить вывод в лог, типа

if ( defined $db ) {
  debug_log("variable db has defined");
} else {
  $db = DBI->connect("dbi:mysql:dbname=".DB_NAME.";host=".DB_HOSTNAME, DB_USER, DB_PASS, {'RaiseError' => 1});
  if ($DBI::err) {
    &ERROR("DB Connect Error. $DBI::errstr");
  } else {
    &INFO("DB Connect Success");
  }
}

Заодно и нам расскажешь. Но кмк, скрипт будет запускаться при каждом authorize, accounting, authen. Если оное определено. Могу ошибаться.

Share this post


Link to post
Share on other sites

31 минуту назад, pppoetest сказал:

Попробуй вставить вывод в лог, типа


if ( defined $db ) {
  debug_log("variable db has defined");
} else {
  $db = DBI->connect("dbi:mysql:dbname=".DB_NAME.";host=".DB_HOSTNAME, DB_USER, DB_PASS, {'RaiseError' => 1});
  if ($DBI::err) {
    &ERROR("DB Connect Error. $DBI::errstr");
  } else {
    &INFO("DB Connect Success");
  }
}

Заодно и нам расскажешь. Но кмк, скрипт будет запускаться при каждом authorize, accounting, authen. Если оное определено. Могу ошибаться.

оно работает, DBCONN вызывается и коннектор инициализируется один раз, но радиус иногда падает, что не очень хорошо. Как вариант объявить $db как our, но думаю сильно не поможет

Share this post


Link to post
Share on other sites

В 12.07.2018 в 15:28, pppoetest сказал:

Попробуй вставить вывод в лог, типа


if ( defined $db ) {
  debug_log("variable db has defined");
} else {
  $db = DBI->connect("dbi:mysql:dbname=".DB_NAME.";host=".DB_HOSTNAME, DB_USER, DB_PASS, {'RaiseError' => 1});
  if ($DBI::err) {
    &ERROR("DB Connect Error. $DBI::errstr");
  } else {
    &INFO("DB Connect Success");
  }
}

Заодно и нам расскажешь. Но кмк, скрипт будет запускаться при каждом authorize, accounting, authen. Если оное определено. Могу ошибаться.

Нашел косяк, perl под гентой собрался без тредов, оно потянуло сборку фрирадиуса без CLONE

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.