Merge pull request #12726 from neheb/ykp2

ykpers: fix compilation with newer json-c
This commit is contained in:
Rosen Penev 2020-07-06 13:54:06 -07:00 committed by GitHub
commit 98d4a7952d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 96 additions and 9 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ykpers
PKG_VERSION:=1.20.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://developers.yubico.com/yubikey-personalization/Releases
@ -12,6 +12,9 @@ PKG_MAINTAINER:=Stuart B. Wilkins <stuwilkins@mac.com>
PKG_LICENSE:=BSD-2-Clause
PKG_LICENSE_FILES:=COPYING
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/ykpers
@ -32,20 +35,21 @@ CONFIGURE_ARGS += \
--disable-static
define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR)/usr/include
$(CP) $(PKG_BUILD_DIR)/ykcore/*.h $(STAGING_DIR)/usr/include
$(CP) $(PKG_BUILD_DIR)/*.h $(STAGING_DIR)/usr/include
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/ykpers-1
$(CP) $(PKG_INSTALL_DIR)/usr/include/ykpers-1/*.h $(STAGING_DIR)/usr/include/ykpers-1
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libykpers-1.so* $(STAGING_DIR)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libykpers-1.so* $(STAGING_DIR)/usr/lib
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/ykpers-1.pc $(STAGING_DIR)/usr/lib/pkgconfig
endef
define Package/ykpers/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/.libs/ykchalresp $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/.libs/ykinfo $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/.libs/ykpersonalize $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ykchalresp $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ykinfo $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ykpersonalize $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/.libs/libykpers-1.so* $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libykpers-1.so* $(1)/usr/lib
endef
$(eval $(call BuildPackage,ykpers))

View File

@ -0,0 +1,83 @@
From 0aa2e2cae2e1777863993a10c809bb50f4cde7f8 Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail@eworm.de>
Date: Sat, 25 Apr 2020 20:55:28 +0200
Subject: [PATCH] fix boolean value with json-c 0.14
Upstream removed the TRUE and FALSE defines in commit
0992aac61f8b087efd7094e9ac2b84fa9c040fcd.
---
ykpers-json.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ykpers-json.c b/ykpers-json.c
index a62e907..15ad380 100644
--- a/ykpers-json.c
+++ b/ykpers-json.c
@@ -40,7 +40,7 @@
#define yk_json_object_object_get(obj, key, value) json_object_object_get_ex(obj, key, &value)
#else
typedef int json_bool;
-#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? (json_bool)FALSE : (json_bool)TRUE
+#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? 0 : 1
#endif
static void set_json_value(struct map_st *p, int mode, json_object *options, YKP_CONFIG *cfg) {
@@ -50,7 +50,7 @@ static void set_json_value(struct map_st *p, int mode, json_object *options, YKP
if(p->mode && (mode & p->mode) == mode) {
json_object *joption;
json_bool ret = yk_json_object_object_get(options, p->json_text, joption);
- if(ret == TRUE && json_object_get_type(joption) == json_type_boolean) {
+ if(ret == 1 && json_object_get_type(joption) == json_type_boolean) {
int value = json_object_get_boolean(joption);
if(value == 1) {
p->setter(cfg, true);
@@ -230,20 +230,20 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
ykp_errno = YKP_EINVAL;
goto out;
}
- if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == FALSE) {
+ if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == 0) {
ykp_errno = YKP_EINVAL;
goto out;
}
- if(yk_json_object_object_get(yprod_json, "mode", jmode) == FALSE) {
+ if(yk_json_object_object_get(yprod_json, "mode", jmode) == 0) {
ykp_errno = YKP_EINVAL;
goto out;
}
- if(yk_json_object_object_get(yprod_json, "options", options) == FALSE) {
+ if(yk_json_object_object_get(yprod_json, "options", options) == 0) {
ykp_errno = YKP_EINVAL;
goto out;
}
- if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == TRUE) {
+ if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == 1) {
int target_config = json_object_get_int(jtarget);
int command;
if(target_config == 1) {
@@ -275,13 +275,13 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
if(mode == MODE_OATH_HOTP) {
json_object *jdigits, *jrandom;
ykp_set_tktflag_OATH_HOTP(cfg, true);
- if(yk_json_object_object_get(options, "oathDigits", jdigits) == TRUE) {
+ if(yk_json_object_object_get(options, "oathDigits", jdigits) == 1) {
int digits = json_object_get_int(jdigits);
if(digits == 8) {
ykp_set_cfgflag_OATH_HOTP8(cfg, true);
}
}
- if(yk_json_object_object_get(options, "randomSeed", jrandom) == TRUE) {
+ if(yk_json_object_object_get(options, "randomSeed", jrandom) == 1) {
int random = json_object_get_boolean(jrandom);
int seed = 0;
if(random == 1) {
@@ -290,7 +290,7 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
goto out;
} else {
json_object *jseed;
- if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == TRUE) {
+ if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == 1) {
seed = json_object_get_int(jseed);
}
}