Module: kamailio Branch: master Commit: d901d4eab24c2b8ddd5880da05083eafc9e0daea URL: https://github.com/kamailio/kamailio/commit/d901d4eab24c2b8ddd5880da05083eaf...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-03-05T12:22:04+01:00
kamctl: CMDHASH to specify password hashing command
- like md5sum, sha256sum
---
Modified: utils/kamctl/kamctl.base Modified: utils/kamctl/kamctlrc
---
Diff: https://github.com/kamailio/kamailio/commit/d901d4eab24c2b8ddd5880da05083eaf... Patch: https://github.com/kamailio/kamailio/commit/d901d4eab24c2b8ddd5880da05083eaf...
---
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base index ea0fff94362..e61b556c3d0 100644 --- a/utils/kamctl/kamctl.base +++ b/utils/kamctl/kamctl.base @@ -62,14 +62,19 @@ if [ -z "$GDB" ] ; then GDB="$TOOLPATH" fi fi -if [ -z "$MD5" ]; then - locate_tool md5sum md5 - if [ -z "$TOOLPATH" ] ; then - # now error, but we can look for alternative names if it is the case - echo "error: 'md5sum' or 'md5' tool not found: set MD5 variable to correct tool path" - exit +if [ -z "$CMDHASH" ]; then + if [ -z "$MD5" ]; then + locate_tool md5sum md5 + if [ -z "$TOOLPATH" ] ; then + # now error, but we can look for alternative names if it is the case + echo "error: 'md5sum' or 'md5' tool not found: set CMDHASH variable to correct tool path" + exit + fi + CMDHASH="$TOOLPATH" + else + # handle old variable setting md5 tool + CMDHASH="$MD5" fi - MD5="$TOOLPATH" fi if [ -z "$LAST_LINE" ] ; then locate_tool tail @@ -777,7 +782,7 @@ filter_json() # output: HA1 _gen_ha1() { - HA1=`echo -n "$1:$2:$3" | $MD5 | $AWK '{ print $1 }'` + HA1=`echo -n "$1:$2:$3" | $CMDHASH | $AWK '{ print $1 }'` if [ $? -ne 0 ] ; then echo "HA1 calculation failed" exit 1 @@ -788,7 +793,7 @@ _gen_ha1() # output: HA1B _gen_ha1b() { - HA1B=`echo -n "$1@$2:$2:$3" | $MD5 | $AWK '{ print $1 }'` + HA1B=`echo -n "$1@$2:$2:$3" | $CMDHASH | $AWK '{ print $1 }'` if [ $? -ne 0 ] ; then echo "HA1B calculation failed" exit 1 @@ -800,7 +805,7 @@ _gen_ha1b() _gen_phplib_id() { NOW=`date`; - PHPLIB_ID=`echo -n "$1$2:$3:$NOW" | $MD5 | $AWK '{ print $1 }'` + PHPLIB_ID=`echo -n "$1$2:$3:$NOW" | $CMDHASH | $AWK '{ print $1 }'` }
# params: user, password diff --git a/utils/kamctl/kamctlrc b/utils/kamctl/kamctlrc index 67af483d9c6..eb5c361f18b 100644 --- a/utils/kamctl/kamctlrc +++ b/utils/kamctl/kamctlrc @@ -79,8 +79,9 @@ # DEFAULT_Q="1.0"
-## Program to calculate a message-digest fingerprint -# MD5="md5sum" +## Program to calculate the MD5/SHA256 message-digest fingerprint +# - md5sum, sha256sum +# CMDHASH="md5sum"
## awk tool # AWK="awk"