Module: kamailio
Branch: master
Commit: 782c3259a7afd0a0ea462a8ee17b95eacbfe3c81
URL: https://github.com/kamailio/kamailio/commit/782c3259a7afd0a0ea462a8ee17b95e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-23T08:47:19+02:00
kamdbctl: new option DBINITASK to control the steps for db init
- if set DBINITASK=yes, then each step requires confirmation (e.g.,
database creation, users creation, standard tables creation)
- can be useful when needing to run only some of the steps
---
Modified: utils/kamctl/kamctlrc
Modified: utils/kamctl/kamdbctl.mysql
---
Diff: https://github.com/kamailio/kamailio/commit/782c3259a7afd0a0ea462a8ee17b95e…
Patch: https://github.com/kamailio/kamailio/commit/782c3259a7afd0a0ea462a8ee17b95e…
---
diff --git a/utils/kamctl/kamctlrc b/utils/kamctl/kamctlrc
index 5306a6116d..a49c79f2ec 100644
--- a/utils/kamctl/kamctlrc
+++ b/utils/kamctl/kamctlrc
@@ -52,6 +52,9 @@
## - known to work for: mysql
# DBROOTPW="dbrootpw"
+## option to ask confirmation for all database creation steps
+# DBINITASK=yes
+
## database character set (used by MySQL when creating database)
#CHARSET="latin1"
diff --git a/utils/kamctl/kamdbctl.mysql b/utils/kamctl/kamdbctl.mysql
index e8f8d2e861..bdb8b98ab4 100644
--- a/utils/kamctl/kamdbctl.mysql
+++ b/utils/kamctl/kamdbctl.mysql
@@ -238,24 +238,45 @@ kamailio_create () # pars: <database name>
exit 1
fi
- kamailio_db_create $1
+ if [ "$DBINITASK" = "yes" ]; then
+ get_answer "ask" "Create the database '$1'? (y/n): "
+ else
+ ANSWER="y"
+ fi
+ if [ "$ANSWER" = "y" ]; then
+ kamailio_db_create $1
+ fi
- kamailio_db_grant $1
+ if [ "$DBINITASK" = "yes" ]; then
+ get_answer "ask" "Create database users with access privileges? (y/n): "
+ else
+ ANSWER="y"
+ fi
+ if [ "$ANSWER" = "y" ]; then
+ kamailio_db_grant $1
+ fi
- standard_create $1
+ if [ "$DBINITASK" = "yes" ]; then
+ get_answer "ask" "Create the standard database tables? (y/n): "
+ else
+ ANSWER="y"
+ fi
+ if [ "$ANSWER" = "y" ]; then
+ standard_create $1
+ fi
- get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
+ get_answer $INSTALL_PRESENCE_TABLES "Create the presence related tables? (y/n): "
if [ "$ANSWER" = "y" ]; then
presence_create $1
fi
- get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
+ get_answer $INSTALL_EXTRA_TABLES "Create the tables for $EXTRA_MODULES? (y/n): "
if [ "$ANSWER" = "y" ]; then
HAS_EXTRA="yes"
extra_create $1
fi
- get_answer $INSTALL_DBUID_TABLES "Install tables for $DBUID_MODULES? (y/n): "
+ get_answer $INSTALL_DBUID_TABLES "Create the tables for $DBUID_MODULES? (y/n): "
if [ "$ANSWER" = "y" ]; then
HAS_EXTRA="yes"
dbuid_create $1
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
```
Installed new kamailio 5.3, setting the uac module to register trunk.
The trunk has been added to the Mysql with an open password (or use ha1).
When try to register and send authorization data, the provider's server always gives a 403 error.
After the analysis, I found that the kamailio sends an incorrect hash in response header.
```
### Troubleshooting
#### Reproduction
<!--
If the issue can be reproduced, describe how it can be done.
-->
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
Provider send "407 Proxy Authentication Required":
Proxy-Authenticate: Digest nonce="MTU3MTY5Mzg2MTrbrxRPWP0AIkC7fowq+nZn",
opaque="MTU3MTY5Mzg2MTrbrxRPWP0AIkC7fowq+nZn",
algorithm=md5,
realm="BREDBAND",
qop="auth"
Kamailio send new "Register":
Proxy-Authorization: Digest username="79205615793",
realm="BREDBAND",
nonce="MTU3MTY5Mzg2MTrbrxRPWP0AIkC7fowq+nZn",
uri="sip:sbc.megafon.ru",
opaque="MTU3MTY5Mzg2MTrbrx
WP0AIkC7fowq+nZn",
qop=auth,
nc=00000001,
cnonce="3335441185",
response="395830e40a92fd7d4564d82dfab1dac0", algorithm=MD5
If you calculate the hash manually:
Correct response: "2cee0f5a35c0e4831455496ce040eaf4"
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
```
Problem with code in auth_alg.c.
He tries to verify that there is an encrypted password, even if it is not set in the database. Next, an uncorrect calculation of the hash for the answer 401 occurs. If you remove the block
```
if(UAC_FLCRED_HA1 & UAC_FLCRED_HA1) {
memcpy(sess_key, crd->passwd.s, HASHHEXLEN);
sess_key[HASHHEXLEN] = '\0';
if ( auth->flags& AUTHENTICATE_MD5SESS ) {
cvt_bin(sess_key, HA1);
} else {
return;
}
```
Password registration works.
Maybe there are 2 problems. He constantly tries to calculate the hash for ha1 password (if used open password), and if it is, then the function cvt_bin incorrectly considers it.
```
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
kamailio 5.3.0 (x86_64/linux) 4cc67a
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
Linux refs4 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3~deb8u1 (2015-04-24) x86_64 GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2108
Module: kamailio
Branch: master
Commit: c0879add55bef77703f2259f224b4a1f954cd8bf
URL: https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-22T10:49:18+02:00
kamdbctl: split create user and grant access statements for mysql
- MySQL 8 doesn't support all in one statement
---
Modified: utils/kamctl/kamdbctl.mysql
---
Diff: https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
Patch: https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
---
diff --git a/utils/kamctl/kamdbctl.mysql b/utils/kamctl/kamdbctl.mysql
index 6103705bc0..e8f8d2e861 100644
--- a/utils/kamctl/kamdbctl.mysql
+++ b/utils/kamctl/kamdbctl.mysql
@@ -160,8 +160,10 @@ kamailio_db_grant () # pars: <database name>
minfo "granting privileges to database $1 ..."
# Users: kamailio is the regular user, kamailioro only for reading
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO '${DBRWUSER}'@'$DBHOST' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '${DBROUSER}'@'$DBHOST' IDENTIFIED BY '$DBROPW';"
+ sql_query "" "CREATE USER '${DBRWUSER}'@'$DBHOST' IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '${DBRWUSER}'@'$DBHOST';
+ CREATE USER '${DBROUSER}'@'$DBHOST' IDENTIFIED BY '$DBROPW';
+ GRANT SELECT ON $1.* TO '${DBROUSER}'@'$DBHOST';"
if [ $? -ne 0 ] ; then
merr "granting privileges to database $1 failed!"
@@ -169,8 +171,10 @@ kamailio_db_grant () # pars: <database name>
fi
if [ "$DBHOST" != "localhost" ] ; then
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'localhost' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '$DBROUSER'@'localhost' IDENTIFIED BY '$DBROPW';"
+ sql_query "" "CREATE USER '$DBRWUSER'@'localhost' IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'localhost';
+ CREATE USER '$DBROUSER'@'localhost' IDENTIFIED BY '$DBROPW';
+ GRANT SELECT ON $1.* TO '$DBROUSER'@'localhost';"
if [ $? -ne 0 ] ; then
merr "granting localhost privileges to database $1 failed!"
exit 1
@@ -178,8 +182,10 @@ kamailio_db_grant () # pars: <database name>
fi
if [ ! -z "$DBACCESSHOST" ] ; then
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'$DBACCESSHOST' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '$DBROUSER'@'$DBACCESSHOST' IDENTIFIED BY '$DBROPW';"
+ sql_query "" "CREATE USER '$DBRWUSER'@'$DBACCESSHOST' IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'$DBACCESSHOST';
+ CREATE USER '$DBROUSER'@'$DBACCESSHOST' IDENTIFIED BY '$DBROPW';
+ GRANT SELECT ON $1.* TO '$DBROUSER'@'$DBACCESSHOST';"
if [ $? -ne 0 ] ; then
merr "granting access host privileges to database $1 failed!"
exit 1