[PATCH 1/3] nss: Don't stop parsing on unexpected key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Due to latest rewrite of NSS module, we are doing yajl parsing
ourselves. This means, we had to introduce couple of callback
that yajl calls. According to its documentation, a callback can
cancel parsing if it returns a zero value. Well, we do just that
in the string callback (findLeasesParserString()). If the JSON
file we are parsing contains a key that we are not interested in,
zero is returned meaning stop all parsing. This is not correct,
because the JSON file can contain some other keys which are not
harmful for our address translation (e.g. 'client-id').

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/nssdata/virbr1.status    | 1 +
 tools/nss/libvirt_nss_leases.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/nssdata/virbr1.status b/tests/nssdata/virbr1.status
index 4951d4513e..f73c478be0 100644
--- a/tests/nssdata/virbr1.status
+++ b/tests/nssdata/virbr1.status
@@ -20,6 +20,7 @@
     {
         "ip-address": "192.168.122.3",
         "mac-address": "52:54:00:aa:bb:cc",
+        "client-id": "01:52:54:00:aa:bb:cc",
         "expiry-time": 2000000000
     }
 ]
diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c
index 86881641a9..577b5a2fd1 100644
--- a/tools/nss/libvirt_nss_leases.c
+++ b/tools/nss/libvirt_nss_leases.c
@@ -201,7 +201,7 @@ findLeasesParserString(void *ctx,
             if (!(parser->entry.hostname = strndup((char *)stringVal, stringLen)))
                 return 0;
         } else {
-            return 0;
+            return 1;
         }
     } else {
         return 0;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux