check if setting exists
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 1 Nov 2012 18:26:29 +0000 (19:26 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 1 Nov 2012 18:26:29 +0000 (19:26 +0100)
src/libimcv/os_info/os_info.c
src/libimcv/plugins/imc_os/imc_os.c

index 05e335f..d5fa4b9 100644 (file)
@@ -159,10 +159,18 @@ METHOD(os_info_t, get_setting, chunk_t,
                 * In order to guarantee privacy, only settings from the
                 * /etc/, /proc/ and /sys/ directories can be retrieved
                 */
+               DBG1(DBG_IMC, "not allowed to access \"%s\"", name);
+
                return chunk_empty;
        }
 
        file = fopen(name, "r");
+       if (!file)
+       {
+               DBG1(DBG_IMC, "failed to open \"%s\"", name);
+
+               return chunk_empty;
+       }
        while (i < sizeof(buf) && fread(buf + i, 1, 1, file) == 1)
        {
                i++;
index 7510b26..f8fe7ea 100644 (file)
@@ -267,7 +267,6 @@ static void add_settings(enumerator_t *enumerator, imc_msg_t *msg)
                value = os->get_setting(os, name);
                if (!value.ptr)
                {
-                       DBG1(DBG_IMC, "  failed to get setting");
                        continue;
                }
                if (first)