Module: sip-router
Branch: master
Commit: 3d716a94b620e0115381b164595ef0398c816856
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3d716a9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Oct 26 08:59:09 2013 +0200
kamctl: use a variable to set the now() function or a replacement for it
- sqlite uses instead the string returned by 'date' call, as it doesn't
have now()
- reported by Peter Dunkley, FS#356
---
utils/kamctl/kamctl | 6 +++---
utils/kamctl/kamctl.sqlbase | 2 ++
utils/kamctl/kamctl.sqlite | 3 +++
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 6e922c6..b63b51e 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -343,7 +343,7 @@ acl() {
QUERY="insert into $ACL_TABLE ($ACL_USER_COLUMN,\
$ACL_GROUP_COLUMN,$ACL_MODIFIED_COLUMN,$ACL_DOMAIN_COLUMN ) values \
-('$OSERUSER','$1', now(), '$OSERDOMAIN' );"
+('$OSERUSER','$1', $DBFNOW, '$OSERDOMAIN' );"
$DBCMD "$QUERY"
if [ $? -ne 0 ] ; then
merr "acl - SQL Error"
@@ -795,7 +795,7 @@ FROM $AVP_TABLE $CLAUSE;"
QUERY="INSERT INTO $AVP_TABLE \
($AVP_UUID_COLUMN,$AVP_USER_COLUMN,$AVP_DOMAIN_COLUMN,$AVP_ATTRIBUTE_COLUMN,\
$AVP_TYPE_COLUMN,$AVP_VALUE_COLUMN,$AVP_MODIFIED_COLUMN) \
-VALUES
('$AVP_UUID','$OSERUSER','$OSERDOMAIN','$2',$3,'$4',NOW());"
+VALUES
('$AVP_UUID','$OSERUSER','$OSERDOMAIN','$2',$3,'$4',$DBFNOW);"
# echo "Query: $QUERY"
$DBCMD "$QUERY"
if [ $? -ne 0 ] ; then
@@ -1047,7 +1047,7 @@ domain() {
exit 0
fi
QUERY="insert into $DOMAIN_TABLE ($DO_DOMAIN_COLUMN, \
- $DO_LAST_MODIFIED_COLUMN) VALUES ('$1',now());"
+ $DO_LAST_MODIFIED_COLUMN) VALUES ('$1',$DBFNOW);"
$DBCMD "$QUERY"
if [ $? -ne 0 ] ; then
merr "domain - SQL Error"
diff --git a/utils/kamctl/kamctl.sqlbase b/utils/kamctl/kamctl.sqlbase
index 6c43149..53d32f9 100644
--- a/utils/kamctl/kamctl.sqlbase
+++ b/utils/kamctl/kamctl.sqlbase
@@ -31,6 +31,8 @@ if [ -z "$DBROOTUSER" ]; then
DBROOTUSER="root"
fi
+DBFNOW="now()"
+
#params: none
# output: DBRWPW
prompt_pw() {
diff --git a/utils/kamctl/kamctl.sqlite b/utils/kamctl/kamctl.sqlite
index 8c3eb21..35cf45a 100644
--- a/utils/kamctl/kamctl.sqlite
+++ b/utils/kamctl/kamctl.sqlite
@@ -21,6 +21,9 @@ fi
DBNAME=$DB_PATH
+DATENOW=`date`
+DBFNOW="'$DATENOW'"
+
##### ----------------------------------------------- #####
### binaries
if [ -z "$SQLITE" ] ; then