Module: kamailio
Branch: master
Commit: 48663e4239f819b42e7035d9f4023c161eb71d05
URL:
https://github.com/kamailio/kamailio/commit/48663e4239f819b42e7035d9f4023c1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-04-23T16:34:35+02:00
permissions: fixed reload trusted rpc command
- reported by Emmanuel Schmidbauer, GH#138
---
Modified: modules/permissions/mi.c
Modified: modules/permissions/trusted.c
Modified: modules/permissions/trusted.h
---
Diff:
https://github.com/kamailio/kamailio/commit/48663e4239f819b42e7035d9f4023c1…
Patch:
https://github.com/kamailio/kamailio/commit/48663e4239f819b42e7035d9f4023c1…
---
diff --git a/modules/permissions/mi.c b/modules/permissions/mi.c
index 9f66683..35f2cca 100644
--- a/modules/permissions/mi.c
+++ b/modules/permissions/mi.c
@@ -54,11 +54,7 @@ struct mi_root* mi_trusted_reload(struct mi_root *cmd_tree, void
*param)
* RPC function to reload trusted table
*/
void rpc_trusted_reload(rpc_t* rpc, void* c) {
- if (hash_table==NULL) {
- rpc->fault(c, 500, "Reload failed. No hash table");
- return;
- }
- if (reload_trusted_table () != 1) {
+ if (reload_trusted_table_cmd () != 1) {
rpc->fault(c, 500, "Reload failed.");
return;
}
diff --git a/modules/permissions/trusted.c b/modules/permissions/trusted.c
index 920f307..db20e8f 100644
--- a/modules/permissions/trusted.c
+++ b/modules/permissions/trusted.c
@@ -555,3 +555,24 @@ int allow_trusted_2(struct sip_msg* _msg, char* _src_ip_sp, char*
_proto_sp)
return -1;
}
+
+int reload_trusted_table_cmd(void)
+{
+ if (!db_handle) {
+ db_handle = perm_dbf.init(&db_url);
+ if (!db_handle) {
+ LM_ERR("unable to connect database\n");
+ return -1;
+ }
+ }
+ if (reload_trusted_table () != 1) {
+ perm_dbf.close(db_handle);
+ db_handle = 0;
+ return -1;
+ }
+
+ perm_dbf.close(db_handle);
+ db_handle = 0;
+
+ return 1;
+}
diff --git a/modules/permissions/trusted.h b/modules/permissions/trusted.h
index cbb3655..f487f6a 100644
--- a/modules/permissions/trusted.h
+++ b/modules/permissions/trusted.h
@@ -84,4 +84,6 @@ int allow_trusted_0(struct sip_msg* _msg, char* str1, char* str2);
int allow_trusted_2(struct sip_msg* _msg, char* _src_ip_sp, char* _proto_sp);
+int reload_trusted_table_cmd(void);
+
#endif /* TRUSTED_H */