Skip to content

Commit ed51419

Browse files
committed
Some more cleanup
1 parent f69e41d commit ed51419

File tree

6 files changed

+9
-122
lines changed

6 files changed

+9
-122
lines changed

aws/security_plugins/db2-aws-iam/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ sh build_aws_sdk.sh $OPENSSL_VER
2626
3. Build the plugin
2727

2828
```shell
29-
export INSTALLED_OPENSSL=$(openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
30-
export INSTALLED_JSON_C=$(yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
3129
make
3230
```
3331

@@ -67,8 +65,6 @@ exit
6765
docker exec -ti mydb2 bash -c "su - db2inst1"
6866
declare -x DB2_HOME="${HOME}/sqllib"
6967
cd /mnt/db2-aws-iam
70-
export INSTALLED_OPENSSL=$(openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
71-
export INSTALLED_JSON_C=$(yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
7268
make
7369
```
7470

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ 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+
export INSTALLED_OPENSSL := $(shell openssl version | awk '{print $2}' | sed -e 's/[a-z]-*.*//' | awk -F. '{ print $1$2$3 }')
18+
export INSTALLED_JSON_C := $(shell yum info installed json-c | grep Version | sed -e 's/Version\s*: //g' | awk -F. '{ print $1$2$3 }')
19+
1720
_dummy := $(shell mkdir -p $(OBJDIR))
1821
_dummy := $(shell mkdir -p $(OUTPUTDIR))
1922
_dummy := $(shell mkdir -p $(PLUGINDIR)/server)

aws/security_plugins/db2-aws-iam/src/configSecPlugin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222
db2 update dbm cfg using AUTHENTICATION GSSPLUGIN
2323
db2 update dbm cfg using srvcon_auth GSS_SERVER_ENCRYPT
2424
db2 update dbm cfg using group_plugin ${PRINCIPAL_NAME}group
25-
db2 update dbm cfg using sysadm_group NULL
25+
#db2 update dbm cfg using sysadm_group NULL
2626
db2set DB2AUTH=OSAUTHDB,ALLOW_LOCAL_FALLBACK,PLUGIN_AUTO_RELOAD
2727
fi
2828

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

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ SQL_API_RC SQL_API_FN GenerateInitialCredUserPassword
317317
char *localErrorMsg = NULL;
318318
char oneNullByte[] = {'\0'};
319319

320-
321320
IAM_TRACE_ENTRY("GenerateInitialCredUserPassword");
322321

323322
if (newpasswordLen > 0)
@@ -545,118 +544,6 @@ SQL_API_RC SQL_API_FN GenerateInitialCredAccessToken
545544
goto exit;
546545
}
547546

548-
/*
549-
* GenerateInitialCredApiKey
550-
*/
551-
SQL_API_RC SQL_API_FN GenerateInitialCredApiKey
552-
(
553-
const char *apikey,
554-
db2int32 apikeyLen,
555-
const char *apikeyspace,
556-
db2int32 apikeyspaceLen,
557-
db2int32 apikeyspaceType,
558-
const char *dbname,
559-
db2int32 dbnameLen,
560-
gss_cred_id_t *pGSSCredHandle,
561-
void **ppInitInfo,
562-
char **errorMsg,
563-
db2int32 *errorMsgLen
564-
)
565-
{
566-
int rc = DB2SEC_PLUGIN_OK;
567-
CRED_T *pCred;
568-
char *localErrorMsg = NULL;
569-
char oneNullByte[] = {'\0'};
570-
const char *userid;
571-
db2int32 useridLen;
572-
IAM_TRACE_ENTRY("GenerateInitialCredApiKey");
573-
574-
if (!pGSSCredHandle)
575-
{
576-
localErrorMsg = "GenerateInitialCredApiKey: pGSSCredHandle == NULL";
577-
rc = DB2SEC_PLUGIN_UNKNOWNERROR;
578-
goto exit;
579-
}
580-
581-
/* Check lengths */
582-
if (apikeyLen > TOKEN_MAX_AUTH_TOKEN_LEN)
583-
{
584-
rc = DB2SEC_PLUGIN_BADPWD;
585-
localErrorMsg = "GenerateInitialCredApiKey: access token too long";
586-
goto exit;
587-
}
588-
589-
pCred = (CRED_T *)malloc(sizeof(CRED_T));
590-
if (pCred == NULL)
591-
{
592-
goto malloc_fail;
593-
}
594-
memset(pCred, '\0', sizeof(CRED_T));
595-
596-
/* Deal with NULL userids and passwords by using a one-byte
597-
* string containing only a NULL. We flow this to the server
598-
* and let it decide.
599-
*/
600-
601-
pCred->authtype = DB2SEC_AUTH_APIKEY;
602-
603-
//pCred->useridLen = 0;
604-
//pCred->userid = NULL;
605-
userid = oneNullByte;
606-
useridLen = 1;
607-
pCred->useridLen = useridLen;
608-
pCred->userid = (char *)malloc(useridLen);
609-
if (pCred->userid == NULL)
610-
{
611-
goto malloc_fail;
612-
}
613-
memcpy(pCred->userid, userid, useridLen);
614-
615-
pCred->authtokenLen = apikeyLen;
616-
pCred->authtoken = (char *)malloc(apikeyLen);
617-
if (pCred->authtoken == NULL)
618-
{
619-
goto malloc_fail;
620-
}
621-
memcpy(pCred->authtoken, apikey, apikeyLen);
622-
623-
*pGSSCredHandle = (gss_cred_id_t)pCred;
624-
625-
exit:
626-
627-
/* No init info */
628-
if (ppInitInfo != NULL)
629-
{
630-
*ppInitInfo = NULL;
631-
}
632-
633-
if (localErrorMsg != NULL)
634-
{
635-
*errorMsg = localErrorMsg;
636-
*errorMsgLen = strlen(localErrorMsg);
637-
}
638-
else
639-
{
640-
*errorMsg = NULL;
641-
*errorMsgLen = 0;
642-
}
643-
IAM_TRACE_EXIT("GenerateInitialCredApiKey",rc);
644-
645-
return(rc);
646-
647-
malloc_fail:
648-
if (pCred != NULL)
649-
{
650-
if (pCred->authtoken != NULL) free(pCred->authtoken);
651-
if (pCred->userid != NULL) free(pCred->userid);
652-
free(pCred);
653-
}
654-
655-
localErrorMsg = "GenerateInitialCredApiKey: malloc failed";
656-
rc = DB2SEC_PLUGIN_NOMEM;
657-
658-
goto exit;
659-
}
660547

661548
/******************************************************************************
662549
*
@@ -689,7 +576,7 @@ SQL_API_RC SQL_API_FN ProcessServerPrincipalName
689576
int rc = DB2SEC_PLUGIN_OK;
690577
NAME_T *pName;
691578
IAM_TRACE_ENTRY("ProcessServerPrincipalName");
692-
579+
693580
/* No error messages */
694581
*errorMsg = NULL;
695582
*errorMsgLen = 0;
@@ -861,7 +748,7 @@ OM_uint32 SQL_API_FN gss_init_sec_context
861748
char *errMsg = NULL;
862749
int length;
863750
IAM_TRACE_ENTRY("gss_init_sec_context");
864-
751+
865752
/* Check for unsupported options */
866753
if (context_handle == NULL)
867754
{
@@ -1140,7 +1027,6 @@ SQL_API_RC SQL_API_FN db2secClientAuthPluginInit
11401027
pFPs->db2secGetDefaultLoginContext = GetDefaultLoginContext;
11411028
pFPs->db2secGenerateInitialCred = GenerateInitialCredUserPassword;
11421029
pFPs->db2secGenerateInitialCredAccessToken = GenerateInitialCredAccessToken;
1143-
pFPs->db2secGenerateInitialCredApiKey = GenerateInitialCredApiKey;
11441030
pFPs->db2secProcessServerPrincipalName = ProcessServerPrincipalName;
11451031
pFPs->db2secFreeToken = FreeToken;
11461032
pFPs->db2secFreeInitInfo = FreeInitInfo;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ 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 }')
1012

1113
CXXFLAGS := -D_GLIBCXX_USE_CXX11_ABI=0
1214

aws/security_plugins/db2-aws-iam/src/test/teardown_cognito.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [[ -f ./env.sh ]]; then
77
aws cognito-idp delete-user-pool --user-pool-id "$USERPOOLID"
88
fi
99
if [[ -f $AWS_USERPOOL_CFG_ENV ]]; then
10-
rm -f $AWS_USERPOOL_CFG_ENV
10+
rm -f $DB2_HOME$AWS_USERPOOL_CFG_ENV
1111
fi
1212
rm -f ./env.sh
1313
fi

0 commit comments

Comments
 (0)