Skip to content

Commit

Permalink
Fixed issue with openssl and json_c version detection and macro setting
Browse files Browse the repository at this point in the history
Signed-off-by: Nishidha Panpaliya <[email protected]>
  • Loading branch information
npanpaliya committed Feb 9, 2024
1 parent 368b78c commit 1da774e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
31 changes: 17 additions & 14 deletions aws/security_plugins/db2-aws-iam/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,23 @@ GROUP_MODULE := $(PLUGINDIR)/group/$(PRINCIPAL_NAME)group.so
AWS_SDK_LIBS := -L/usr/local/lib64 -laws-cpp-sdk-core -laws-cpp-sdk-cognito-idp -Wl,-rpath,/opt/ibm/db2/V11.5/lib64
CPPLIBS := -lstdc++

INSTALLED_OPENSSL := $(shell openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
# Check the installed version of openssl and json_c and according set the macro
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')
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/\.//g')
$(info INSTALLED_OPENSSL is $(INSTALLED_OPENSSL))
$(info INSTALLED_JSON_C is $(INSTALLED_JSON_C))

OSSL_MACRO :=
VER_GT_110 = $(shell echo $(INSTALLED_OPENSSL)\>=110 | bc )
ifeq ($(VER_GT_110), 1)
OSSL_MACRO += -DOPENSSL_1_1_0
endif

JSON_MACRO :=
VER_GT_0_13 = $(shell echo $(INSTALLED_JSON_C)\>=0130 | bc )
ifeq ($(VER_GT_0_13), 1)
JSON_MACRO += -DJSON_C_0_13
endif

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

OSSL_MACRO :=
ifeq ($(shell expr $(INSTALLED_OPENSSL) \>= 110), 1)
OSSL_MACRO := -DOPENSSL_1_1_0
endif

JSON_MACRO :=
ifeq ($(shell expr $(INSTALLED_JSON_C) \>= 0130), 1)
JSON_MACRO := -DJSON_C_0_13
endif

#@echo INSTALLED_OPENSSL is $(INSTALLED_OPENSSL)

CFLAGS := $(INCLUDES) -g -fpic -fno-strict-aliasing -Werror \
-DSQLUNIX \
-D_GLIBCXX_USE_CXX11_ABI=0 \
Expand Down
4 changes: 2 additions & 2 deletions aws/security_plugins/db2-aws-iam/src/gss/AWSIAMauthgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ SQL_API_RC SQL_API_FN FindGroups(const char *authID,
for(int retries = 0; retries < 5 && parsed_json == NULL; retries++)
{
#ifdef JSON_C_0_13
char* json_e = json_util_get_last_err();
const char* json_e = json_util_get_last_err();
strcpy(json_err, json_e);
#else
snprintf(json_err, sizeof(json_err), JSON_READ_ERROR , DB2OC_USER_REGISTRY_FILE);
Expand All @@ -238,7 +238,7 @@ SQL_API_RC SQL_API_FN FindGroups(const char *authID,
if(parsed_json == NULL)
{
#ifdef JSON_C_0_13
char* json_e = json_util_get_last_err();
const char* json_e = json_util_get_last_err();
strcpy(json_err, json_e);
#else
snprintf(json_err, sizeof(json_err), JSON_READ_ERROR , DB2OC_USER_REGISTRY_FILE);
Expand Down
18 changes: 12 additions & 6 deletions aws/security_plugins/db2-aws-iam/src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ GROUP_MODULE := $(PRINCIPAL_NAME)group.so

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

CXXFLAGS := -D_GLIBCXX_USE_CXX11_ABI=0

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

# Check the installed version of openssl and json_c and according set the macro
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')
INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*:\s*//g' | sed -e 's/\.//g')
$(info INSTALLED_OPENSSL is $(INSTALLED_OPENSSL))
$(info INSTALLED_JSON_C is $(INSTALLED_JSON_C))

OSSL_MACRO :=
ifeq ($(shell expr $(INSTALLED_OPENSSL) \>= 110), 1)
OSSL_MACRO := -DOPENSSL_1_1_0
VER_GT_110 = $(shell echo $(INSTALLED_OPENSSL)\>=110 | bc )
ifeq ($(VER_GT_110), 1)
OSSL_MACRO += -DOPENSSL_1_1_0
endif

JSON_MACRO :=
ifeq ($(shell expr $(INSTALLED_JSON_C) \>= 0130), 1)
JSON_MACRO := -DJSON_C_0_13
VER_GT_0_13 = $(shell echo $(INSTALLED_JSON_C)\>=0130 | bc )
ifeq ($(VER_GT_0_13), 1)
JSON_MACRO += -DJSON_C_0_13
endif

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

0 comments on commit 1da774e

Please sign in to comment.