libimcv: Move settings to <ns>.imcv and <ns>.plugins with fallback
authorTobias Brunner <tobias@strongswan.org>
Fri, 7 Feb 2014 13:19:06 +0000 (14:19 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 12 Feb 2014 13:34:34 +0000 (14:34 +0100)
src/libimcv/imcv.c
src/libimcv/imv/imv_msg.c
src/libimcv/imv/imv_policy_manager.c
src/libimcv/os_info/os_info.c
src/libimcv/plugins/imc_os/imc_os.c
src/libimcv/plugins/imc_scanner/imc_scanner.c
src/libimcv/plugins/imc_test/imc_test.c
src/libimcv/plugins/imv_os/imv_os_state.c
src/libimcv/plugins/imv_scanner/imv_scanner_state.c
src/libimcv/plugins/imv_test/imv_test_agent.c

index aa55746..2a4fd33 100644 (file)
@@ -134,6 +134,10 @@ bool libimcv_init(bool is_imv)
        }
        ref_get(&libstrongswan_ref);
 
+       lib->settings->add_fallback(lib->settings, "%s.imcv", "libimcv", lib->ns);
+       lib->settings->add_fallback(lib->settings, "%s.plugins", "libimcv.plugins",
+                                                               lib->ns);
+
        if (libimcv_ref == 0)
        {
                char *uri, *script;
@@ -149,9 +153,10 @@ bool libimcv_init(bool is_imv)
                if (is_imv)
                {
                        uri = lib->settings->get_str(lib->settings,
-                                               "libimcv.database", NULL);
+                                               "%s.imcv.database", NULL, lib->ns);
                        script = lib->settings->get_str(lib->settings,
-                                               "libimcv.policy_script", IMCV_DEFAULT_POLICY_SCRIPT);
+                                               "%s.imcv.policy_script", IMCV_DEFAULT_POLICY_SCRIPT,
+                                               lib->ns);
                        if (uri)
                        {
                                imcv_db = imv_database_create(uri, script);
index 642b479..e718175 100644 (file)
@@ -208,8 +208,8 @@ METHOD(imv_msg_t, send_assessment, TNC_Result,
        }
 
        /* Send an IETF Assessment Result attribute if enabled */
-       if (lib->settings->get_bool(lib->settings, "libimcv.assessment_result",
-                                                               TRUE))
+       if (lib->settings->get_bool(lib->settings, "%s.imcv.assessment_result",
+                                                               TRUE, lib->ns))
        {
                this->state->get_recommendation(this->state, &rec, &eval);
                attr = ietf_attr_assess_result_create(eval);
index 15d291a..afb54d6 100644 (file)
@@ -328,7 +328,12 @@ int main(int argc, char *argv[])
        session_id = atoi(tnc_session_id);
 
        /* attach IMV database */
-       uri = lib->settings->get_str(lib->settings, "libimcv.database", NULL);
+       uri = lib->settings->get_str(lib->settings,
+                       "imv_policy_manager.database",
+                       lib->settings->get_str(lib->settings,
+                               "charon.imcv.database",
+                               lib->settings->get_str(lib->settings,
+                                       "libimcv.database", NULL)));
        if (!uri)
        {
                fprintf(stderr, "database uri not defined.\n");
index 17000cd..0642757 100644 (file)
@@ -560,9 +560,9 @@ os_info_t *os_info_create(void)
 
        /* As an option OS name and OS version can be configured manually */
        name.ptr = lib->settings->get_str(lib->settings,
-                                                                         "libimcv.os_info.name", NULL);
+                                                                         "%s.imcv.os_info.name", NULL, lib->ns);
        version.ptr = lib->settings->get_str(lib->settings,
-                                                                         "libimcv.os_info.version", NULL);
+                                                                         "%s.imcv.os_info.version", NULL, lib->ns);
        if (name.ptr && version.ptr)
        {
                name.len = strlen(name.ptr);
index 2558be9..647a449 100644 (file)
@@ -387,7 +387,7 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
                return TNC_RESULT_FATAL;
        }
        if (lib->settings->get_bool(lib->settings,
-                                                               "libimcv.plugins.imc-os.push_info", TRUE))
+                                                               "%s.plugins.imc-os.push_info", TRUE, lib->ns))
        {
                out_msg = imc_msg_create(imc_os, state, connection_id, imc_id,
                                                                 TNC_IMVID_ANY, msg_types[0]);
index c87e827..2be6a87 100644 (file)
@@ -274,7 +274,7 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
                return TNC_RESULT_FATAL;
        }
        if (lib->settings->get_bool(lib->settings,
-                                                               "libimcv.plugins.imc-scanner.push_info", TRUE))
+                                                       "%s.plugins.imc-scanner.push_info", TRUE, lib->ns))
        {
                out_msg = imc_msg_create(imc_scanner, state, connection_id, imc_id,
                                                                 TNC_IMVID_ANY, msg_types[0]);
index c97d416..ee982d9 100644 (file)
@@ -91,11 +91,11 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
        {
                case TNC_CONNECTION_STATE_CREATE:
                        command = lib->settings->get_str(lib->settings,
-                                                               "libimcv.plugins.imc-test.command", "none");
+                                                               "%s.plugins.imc-test.command", "none", lib->ns);
                        dummy_size = lib->settings->get_int(lib->settings,
-                                                               "libimcv.plugins.imc-test.dummy_size", 0);
+                                                               "%s.plugins.imc-test.dummy_size", 0, lib->ns);
                        retry = lib->settings->get_bool(lib->settings,
-                                                               "libimcv.plugins.imc-test.retry", FALSE);
+                                                               "%s.plugins.imc-test.retry", FALSE, lib->ns);
                        state = imc_test_state_create(connection_id, command, dummy_size,
                                                                                  retry);
 
@@ -107,7 +107,7 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
 
                        /* Optionally reserve additional IMC IDs */
                        additional_ids = lib->settings->get_int(lib->settings,
-                                                               "libimcv.plugins.imc-test.additional_ids", 0);
+                                                       "%s.plugins.imc-test.additional_ids", 0, lib->ns);
                        imc_test->reserve_additional_ids(imc_test, additional_ids -
                                                                imc_test->count_additional_ids(imc_test));
 
@@ -127,8 +127,8 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
                        if (!test_state->is_first_handshake(test_state))
                        {
                                command = lib->settings->get_str(lib->settings,
-                                                               "libimcv.plugins.imc-test.retry_command",
-                                                               test_state->get_command(test_state));
+                                                               "%s.plugins.imc-test.retry_command",
+                                                               test_state->get_command(test_state), lib->ns);
                                test_state->set_command(test_state, command);
                        }
 
index f7e9a6b..4f5a4b0 100644 (file)
@@ -494,7 +494,7 @@ METHOD(imv_state_t, get_remediation_instructions, bool,
 
        *string = this->remediation_string->get_encoding(this->remediation_string);
        *uri = lib->settings->get_str(lib->settings,
-                                                       "libimcv.plugins.imv-os.remediation_uri", NULL);
+                                                       "%s.plugins.imv-os.remediation_uri", NULL, lib->ns);
 
        return TRUE;
 }
index 6658683..90475d3 100644 (file)
@@ -314,7 +314,7 @@ METHOD(imv_state_t, get_remediation_instructions, bool,
                                                                        this->violating_ports);
        *string = this->remediation_string->get_encoding(this->remediation_string);
        *uri = lib->settings->get_str(lib->settings,
-                               "libimcv.plugins.imv-scanner.remediation_uri", NULL);
+                                       "%s.plugins.imv-scanner.remediation_uri", NULL, lib->ns);
 
        return TRUE;
 }
index cdf0e18..4263000 100644 (file)
@@ -103,7 +103,7 @@ static TNC_Result receive_msg(private_imv_test_agent_t *this, imv_state_t *state
 
        /* add any new IMC and set its number of rounds */
        rounds = lib->settings->get_int(lib->settings,
-                                                               "libimcv.plugins.imv-test.rounds", 0);
+                                                                       "%s.plugins.imv-test.rounds", 0, lib->ns);
        test_state = (imv_test_state_t*)state;
        test_state->add_imc(test_state, in_msg->get_src_id(in_msg), rounds);
 
@@ -178,7 +178,7 @@ static TNC_Result receive_msg(private_imv_test_agent_t *this, imv_state_t *state
                if (result != TNC_RESULT_SUCCESS)
                {
                        return result;
-               }  
+               }
                return this->agent->provide_recommendation(this->agent, state);
        }
 
@@ -200,7 +200,7 @@ static TNC_Result receive_msg(private_imv_test_agent_t *this, imv_state_t *state
                out_msg->add_attribute(out_msg, attr);
 
                /* send PA-TNC message with excl flag set */
-               result = out_msg->send(out_msg, TRUE);  
+               result = out_msg->send(out_msg, TRUE);
                out_msg->destroy(out_msg);
 
                return result;
@@ -214,11 +214,11 @@ static TNC_Result receive_msg(private_imv_test_agent_t *this, imv_state_t *state
                if (result != TNC_RESULT_SUCCESS)
                {
                        return result;
-               }  
+               }
                return this->agent->provide_recommendation(this->agent, state);
        }
        else
-       {       
+       {
                return TNC_RESULT_SUCCESS;
        }
  }