Skip to content

Commit 1da774e

Browse files
committed
Fixed issue with openssl and json_c version detection and macro setting
Signed-off-by: Nishidha Panpaliya <nishidha.panpaliya@partner.ibm.com>
1 parent 368b78c commit 1da774e

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

aws/security_plugins/db2-aws-iam/src/Makefile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,23 @@ GROUP_MODULE := $(PLUGINDIR)/group/$(PRINCIPAL_NAME)group.so
1414
AWS_SDK_LIBS := -L/usr/local/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-cognito-idp -Wl,-rpath,/opt/ibm/db2/V11.5/lib64
1515
CPPLIBS := -lstdc++
1616

17-
INSTALLED_OPENSSL := $(shell openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
18-
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
17+
# Check the installed version of openssl and json_c and according set the macro
18+
INSTALLED_OPENSSL := $(shell yum info installed openssl | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/[a-z]-*.*//' | sed -e 's/\.//g')
19+
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/\.//g')
20+
$(info INSTALLED_OPENSSL is $(INSTALLED_OPENSSL))
21+
$(info INSTALLED_JSON_C is $(INSTALLED_JSON_C))
22+
23+
OSSL_MACRO :=
24+
VER_GT_110 = $(shell echo $(INSTALLED_OPENSSL)\>=110 | bc )
25+
ifeq ($(VER_GT_110), 1)
26+
OSSL_MACRO += -DOPENSSL_1_1_0
27+
endif
28+
29+
JSON_MACRO :=
30+
VER_GT_0_13 = $(shell echo $(INSTALLED_JSON_C)\>=0130 | bc )
31+
ifeq ($(VER_GT_0_13), 1)
32+
JSON_MACRO += -DJSON_C_0_13
33+
endif
1934

2035
_dummy := $(shell mkdir -p $(OBJDIR))
2136
_dummy := $(shell mkdir -p $(OUTPUTDIR))
@@ -37,18 +52,6 @@ ifeq ($(OPENSSL_VER), 3)
3752
OSSL_LIBS_PATH := -L/usr/lib64
3853
endif
3954

40-
OSSL_MACRO :=
41-
ifeq ($(shell expr $(INSTALLED_OPENSSL) \>= 110), 1)
42-
OSSL_MACRO := -DOPENSSL_1_1_0
43-
endif
44-
45-
JSON_MACRO :=
46-
ifeq ($(shell expr $(INSTALLED_JSON_C) \>= 0130), 1)
47-
JSON_MACRO := -DJSON_C_0_13
48-
endif
49-
50-
#@echo INSTALLED_OPENSSL is $(INSTALLED_OPENSSL)
51-
5255
CFLAGS := $(INCLUDES) -g -fpic -fno-strict-aliasing -Werror \
5356
-DSQLUNIX \
5457
-D_GLIBCXX_USE_CXX11_ABI=0 \

aws/security_plugins/db2-aws-iam/src/gss/AWSIAMauthgroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ SQL_API_RC SQL_API_FN FindGroups(const char *authID,
220220
for(int retries = 0; retries < 5 && parsed_json == NULL; retries++)
221221
{
222222
#ifdef JSON_C_0_13
223-
char* json_e = json_util_get_last_err();
223+
const char* json_e = json_util_get_last_err();
224224
strcpy(json_err, json_e);
225225
#else
226226
snprintf(json_err, sizeof(json_err), JSON_READ_ERROR , DB2OC_USER_REGISTRY_FILE);
@@ -238,7 +238,7 @@ SQL_API_RC SQL_API_FN FindGroups(const char *authID,
238238
if(parsed_json == NULL)
239239
{
240240
#ifdef JSON_C_0_13
241-
char* json_e = json_util_get_last_err();
241+
const char* json_e = json_util_get_last_err();
242242
strcpy(json_err, json_e);
243243
#else
244244
snprintf(json_err, sizeof(json_err), JSON_READ_ERROR , DB2OC_USER_REGISTRY_FILE);

aws/security_plugins/db2-aws-iam/src/test/Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ GROUP_MODULE := $(PRINCIPAL_NAME)group.so
77

88
AWS_SDK_LIBS := -L/usr/local/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-cognito-idp -Wl,-rpath,/usr/local/lib64
99
CPPLIBS := -lstdc++
10-
export INSTALLED_OPENSSL := $(shell openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
11-
export INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
1210

1311
CXXFLAGS := -D_GLIBCXX_USE_CXX11_ABI=0
1412

@@ -19,14 +17,22 @@ ifeq ($(OPENSSL_VER), 3)
1917
INCLUDES := -I$(DB2_HOME)/include -I../gss -I../common -I/usr/include -I/usr/include/openssl3
2018
endif
2119

20+
# Check the installed version of openssl and json_c and according set the macro
21+
INSTALLED_OPENSSL := $(shell yum info installed openssl | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/[a-z]-*.*//' | sed -e 's/\.//g')
22+
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/\.//g')
23+
$(info INSTALLED_OPENSSL is $(INSTALLED_OPENSSL))
24+
$(info INSTALLED_JSON_C is $(INSTALLED_JSON_C))
25+
2226
OSSL_MACRO :=
23-
ifeq ($(shell expr $(INSTALLED_OPENSSL) \>= 110), 1)
24-
OSSL_MACRO := -DOPENSSL_1_1_0
27+
VER_GT_110 = $(shell echo $(INSTALLED_OPENSSL)\>=110 | bc )
28+
ifeq ($(VER_GT_110), 1)
29+
OSSL_MACRO += -DOPENSSL_1_1_0
2530
endif
2631

2732
JSON_MACRO :=
28-
ifeq ($(shell expr $(INSTALLED_JSON_C) \>= 0130), 1)
29-
JSON_MACRO := -DJSON_C_0_13
33+
VER_GT_0_13 = $(shell echo $(INSTALLED_JSON_C)\>=0130 | bc )
34+
ifeq ($(VER_GT_0_13), 1)
35+
JSON_MACRO += -DJSON_C_0_13
3036
endif
3137

3238
CFLAGS := $(INCLUDES) -L$(DB2_HOME)/lib -L../obj -g -fpic -fno-strict-aliasing -Werror \

0 commit comments

Comments
 (0)