[td-10564] refactor and add test cases.
This commit is contained in:
parent
bf97ce3d9d
commit
8c416a5e4e
|
@ -379,7 +379,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
int32_t maxUsers;
|
||||
int32_t maxDbs;
|
||||
int32_t maxTimeSeries;
|
||||
|
@ -394,7 +394,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
} SCreateUserMsg, SAlterUserMsg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -912,8 +912,8 @@ typedef struct {
|
|||
char user[TSDB_USER_LEN];
|
||||
char spi;
|
||||
char encrypt;
|
||||
char secret[TSDB_KEY_LEN];
|
||||
char ckey[TSDB_KEY_LEN];
|
||||
char secret[TSDB_PASSWORD_LEN];
|
||||
char ckey[TSDB_PASSWORD_LEN];
|
||||
} SAuthMsg, SAuthRsp;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -188,7 +188,7 @@ do { \
|
|||
#define TSDB_MAX_TAG_CONDITIONS 1024
|
||||
|
||||
#define TSDB_AUTH_LEN 16
|
||||
#define TSDB_KEY_LEN 64
|
||||
#define TSDB_PASSWORD_LEN 64
|
||||
#define TSDB_VERSION_LEN 12
|
||||
#define TSDB_LABEL_LEN 8
|
||||
|
||||
|
|
|
@ -51,7 +51,19 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar
|
|||
MD5Init(&context);
|
||||
MD5Update(&context, inBuf, (unsigned int)inLen);
|
||||
MD5Final(&context);
|
||||
memcpy(target, context.digest, TSDB_KEY_LEN);
|
||||
memcpy(target, context.digest, tListLen(context.digest));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *target) {
|
||||
MD5_CTX context;
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, inBuf, (unsigned int)len);
|
||||
|
||||
MD5Final(&context);
|
||||
sprintf(target, "%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x", context.digest[0], context.digest[1], context.digest[2],
|
||||
context.digest[3], context.digest[4], context.digest[5], context.digest[6], context.digest[7],
|
||||
context.digest[8], context.digest[9], context.digest[10], context.digest[11], context.digest[12],
|
||||
context.digest[13], context.digest[14], context.digest[15]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct SAppInfo {
|
|||
|
||||
typedef struct STscObj {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char acctId[TSDB_ACCT_ID_LEN];
|
||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
||||
uint32_t connId;
|
||||
|
@ -117,7 +117,7 @@ void destroyRequest(void* p);
|
|||
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
|
||||
|
||||
void taos_init_imp(void);
|
||||
int taos_options_imp(TSDB_OPTION option, const char *pStr);
|
||||
int taos_options_imp(TSDB_OPTION option, const char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, c
|
|||
char ipStr[TSDB_EP_LEN] = {0};
|
||||
char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||
char userStr[TSDB_USER_LEN] = {0};
|
||||
char passStr[TSDB_KEY_LEN] = {0};
|
||||
char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||
|
||||
strncpy(ipStr, ip, MIN(TSDB_EP_LEN - 1, ipLen));
|
||||
strncpy(userStr, user, MIN(TSDB_USER_LEN - 1, userLen));
|
||||
strncpy(passStr, pass, MIN(TSDB_KEY_LEN - 1, passLen));
|
||||
strncpy(passStr, pass, MIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||
strncpy(dbStr, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ static bool validateUserName(const char* user) {
|
|||
}
|
||||
|
||||
static bool validatePassword(const char* passwd) {
|
||||
return stringLengthCheck(passwd, TSDB_KEY_LEN - 1);
|
||||
return stringLengthCheck(passwd, TSDB_PASSWORD_LEN - 1);
|
||||
}
|
||||
|
||||
static bool validateDbName(const char* db) {
|
||||
|
@ -52,14 +52,14 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
|||
strdequote(tmp);
|
||||
}
|
||||
|
||||
char secretEncrypt[32] = {0};
|
||||
char secretEncrypt[64] = {0};
|
||||
if (auth == NULL) {
|
||||
if (!validatePassword(pass)) {
|
||||
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
taosEncryptPass((uint8_t *)pass, strlen(pass), secretEncrypt);
|
||||
taosEncryptPass_c((uint8_t *)pass, strlen(pass), secretEncrypt);
|
||||
} else {
|
||||
tstrncpy(secretEncrypt, auth, tListLen(secretEncrypt));
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
|||
}
|
||||
}
|
||||
|
||||
return taosConnectImpl(ip, user, auth, db, port, NULL, NULL);
|
||||
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL);
|
||||
}
|
||||
|
||||
int initEpSetFromCfg(const char *firstEp, const char *secondEp, SRpcCorEpSet *pEpSet) {
|
||||
|
|
|
@ -74,6 +74,10 @@ void taos_cleanup(void) {
|
|||
}
|
||||
|
||||
void taos_close(TAOS* taos) {
|
||||
if (taos == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,22 @@ static void deregisterRequest(SRequestObj* pRequest) {
|
|||
taosReleaseRef(tscConnRef, pTscObj->id);
|
||||
}
|
||||
|
||||
static void tscInitLogFile() {
|
||||
taosReadGlobalLogCfg();
|
||||
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
|
||||
printf("failed to create log dir:%s\n", tsLogDir);
|
||||
}
|
||||
|
||||
const char *defaultLogFileNamePrefix = "taoslog";
|
||||
const int32_t maxLogFileNum = 10;
|
||||
|
||||
char temp[128] = {0};
|
||||
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
|
||||
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
|
||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||
}
|
||||
}
|
||||
|
||||
void tscFreeRpcObj(void *param) {
|
||||
#if 0
|
||||
assert(param);
|
||||
|
@ -200,22 +216,6 @@ void destroyRequest(void* p) {
|
|||
deregisterRequest(pRequest);
|
||||
}
|
||||
|
||||
static void tscInitLogFile() {
|
||||
taosReadGlobalLogCfg();
|
||||
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
|
||||
printf("failed to create log dir:%s\n", tsLogDir);
|
||||
}
|
||||
|
||||
const char *defaultLogFileNamePrefix = "taoslog";
|
||||
const int32_t maxLogFileNum = 10;
|
||||
|
||||
char temp[128] = {0};
|
||||
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
|
||||
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
|
||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||
}
|
||||
}
|
||||
|
||||
void taos_init_imp(void) {
|
||||
// In the APIs of other program language, taos_cleanup is not available yet.
|
||||
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
|
||||
|
@ -268,7 +268,7 @@ void taos_init_imp(void) {
|
|||
tscDebug("client is initialized successfully");
|
||||
}
|
||||
|
||||
int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
||||
int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||
SGlobalCfg *cfg = NULL;
|
||||
|
||||
switch (option) {
|
||||
|
@ -277,11 +277,11 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
tstrncpy(configDir, pStr, TSDB_FILENAME_LEN);
|
||||
tstrncpy(configDir, str, TSDB_FILENAME_LEN);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscInfo("set config file directory:%s", pStr);
|
||||
tscInfo("set config file directory:%s", str);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -290,13 +290,13 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
tsShellActivityTimer = atoi(pStr);
|
||||
tsShellActivityTimer = atoi(str);
|
||||
if (tsShellActivityTimer < 1) tsShellActivityTimer = 1;
|
||||
if (tsShellActivityTimer > 3600) tsShellActivityTimer = 3600;
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscInfo("set shellActivityTimer:%d", tsShellActivityTimer);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, pStr, tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -304,9 +304,9 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
cfg = taosGetConfigOption("locale");
|
||||
assert(cfg != NULL);
|
||||
|
||||
size_t len = strlen(pStr);
|
||||
size_t len = strlen(str);
|
||||
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
||||
tscInfo("Invalid locale:%s, use default", pStr);
|
||||
tscInfo("Invalid locale:%s, use default", str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -327,14 +327,14 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
}
|
||||
|
||||
// set the user specified locale
|
||||
char *locale = setlocale(LC_CTYPE, pStr);
|
||||
char *locale = setlocale(LC_CTYPE, str);
|
||||
|
||||
if (locale != NULL) { // failed to set the user specified locale
|
||||
tscInfo("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
} else { // set the user specified locale failed, use default LC_CTYPE as current locale
|
||||
locale = setlocale(LC_CTYPE, tsLocale);
|
||||
tscInfo("failed to set locale:%s, current locale:%s", pStr, tsLocale);
|
||||
tscInfo("failed to set locale:%s, current locale:%s", str, tsLocale);
|
||||
}
|
||||
|
||||
tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);
|
||||
|
@ -364,7 +364,7 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
tscInfo("charset remains:%s", tsCharset);
|
||||
}
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -374,27 +374,27 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
cfg = taosGetConfigOption("charset");
|
||||
assert(cfg != NULL);
|
||||
|
||||
size_t len = strlen(pStr);
|
||||
size_t len = strlen(str);
|
||||
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
||||
tscInfo("failed to set charset:%s", pStr);
|
||||
tscInfo("failed to set charset:%s", str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
if (taosValidateEncodec(pStr)) {
|
||||
if (taosValidateEncodec(str)) {
|
||||
if (strlen(tsCharset) == 0) {
|
||||
tscInfo("charset is set:%s", pStr);
|
||||
tscInfo("charset is set:%s", str);
|
||||
} else {
|
||||
tscInfo("charset changed from %s to %s", tsCharset, pStr);
|
||||
tscInfo("charset changed from %s to %s", tsCharset, str);
|
||||
}
|
||||
|
||||
tstrncpy(tsCharset, pStr, TSDB_LOCALE_LEN);
|
||||
tstrncpy(tsCharset, str, TSDB_LOCALE_LEN);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
} else {
|
||||
tscInfo("charset:%s not valid", pStr);
|
||||
tscInfo("charset:%s not valid", str);
|
||||
}
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -405,12 +405,12 @@ int taos_options_imp(TSDB_OPTION option, const char *pStr) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
tstrncpy(tsTimezone, pStr, TSDB_TIMEZONE_LEN);
|
||||
tstrncpy(tsTimezone, str, TSDB_TIMEZONE_LEN);
|
||||
tsSetTimeZone();
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
|
||||
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone, str);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -34,4 +34,5 @@ int main(int argc, char** argv) {
|
|||
|
||||
TEST(testCase, driverInit_Test) {
|
||||
taos_init();
|
||||
TAOS* pTaos = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
}
|
|
@ -240,18 +240,18 @@ static void dndSendMsgToMnodeRecv(SDnode *pDnode, SRpcMsg *pRpcMsg, SRpcMsg *pRp
|
|||
static int32_t dndAuthInternalMsg(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
||||
if (strcmp(user, INTERNAL_USER) == 0) {
|
||||
// A simple temporary implementation
|
||||
char pass[32] = {0};
|
||||
char pass[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
||||
memcpy(secret, pass, TSDB_KEY_LEN);
|
||||
memcpy(secret, pass, TSDB_PASSWORD_LEN);
|
||||
*spi = 0;
|
||||
*encrypt = 0;
|
||||
*ckey = 0;
|
||||
return 0;
|
||||
} else if (strcmp(user, TSDB_NETTEST_USER) == 0) {
|
||||
// A simple temporary implementation
|
||||
char pass[32] = {0};
|
||||
char pass[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass((uint8_t *)(TSDB_NETTEST_USER), strlen(TSDB_NETTEST_USER), pass);
|
||||
memcpy(secret, pass, TSDB_KEY_LEN);
|
||||
memcpy(secret, pass, TSDB_PASSWORD_LEN);
|
||||
*spi = 0;
|
||||
*encrypt = 0;
|
||||
*ckey = 0;
|
||||
|
@ -293,8 +293,8 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
|
|||
dError("user:%s, failed to get user auth from other mnodes since %s", user, terrstr());
|
||||
} else {
|
||||
SAuthRsp *pRsp = rpcRsp.pCont;
|
||||
memcpy(secret, pRsp->secret, TSDB_KEY_LEN);
|
||||
memcpy(ckey, pRsp->ckey, TSDB_KEY_LEN);
|
||||
memcpy(secret, pRsp->secret, TSDB_PASSWORD_LEN);
|
||||
memcpy(ckey, pRsp->ckey, TSDB_PASSWORD_LEN);
|
||||
*spi = pRsp->spi;
|
||||
*encrypt = pRsp->encrypt;
|
||||
dDebug("user:%s, success to get user auth from other mnodes", user);
|
||||
|
|
|
@ -107,7 +107,7 @@ SClient* createClient(const char* user, const char* pass, const char* fqdn, uint
|
|||
SClient* pClient = (SClient*)calloc(1, sizeof(SClient));
|
||||
ASSERT(pClient);
|
||||
|
||||
char secretEncrypt[32] = {0};
|
||||
char secretEncrypt[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass((uint8_t*)pass, strlen(pass), secretEncrypt);
|
||||
|
||||
SRpcInit rpcInit;
|
||||
|
|
|
@ -181,7 +181,7 @@ typedef struct SAcctObj {
|
|||
|
||||
typedef struct SUserObj {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char acct[TSDB_USER_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
|
|
|
@ -92,7 +92,7 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
|||
|
||||
int32_t dataPos = 0;
|
||||
SDB_SET_BINARY(pRaw, dataPos, pUser->user, TSDB_USER_LEN)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pUser->pass, TSDB_KEY_LEN)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pUser->pass, TSDB_PASSWORD_LEN)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pUser->acct, TSDB_USER_LEN)
|
||||
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime)
|
||||
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime)
|
||||
|
@ -120,7 +120,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
|
||||
int32_t dataPos = 0;
|
||||
SDB_GET_BINARY(pRaw, pRow, dataPos, pUser->user, TSDB_USER_LEN)
|
||||
SDB_GET_BINARY(pRaw, pRow, dataPos, pUser->pass, TSDB_KEY_LEN)
|
||||
SDB_GET_BINARY(pRaw, pRow, dataPos, pUser->pass, TSDB_PASSWORD_LEN)
|
||||
SDB_GET_BINARY(pRaw, pRow, dataPos, pUser->acct, TSDB_USER_LEN)
|
||||
SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->createdTime)
|
||||
SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->updateTime)
|
||||
|
@ -165,7 +165,7 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) {
|
|||
static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pSrcUser, SUserObj *pDstUser) {
|
||||
mTrace("user:%s, perform update action", pSrcUser->user);
|
||||
memcpy(pSrcUser->user, pDstUser->user, TSDB_USER_LEN);
|
||||
memcpy(pSrcUser->pass, pDstUser->pass, TSDB_KEY_LEN);
|
||||
memcpy(pSrcUser->pass, pDstUser->pass, TSDB_PASSWORD_LEN);
|
||||
memcpy(pSrcUser->acct, pDstUser->acct, TSDB_USER_LEN);
|
||||
pSrcUser->createdTime = pDstUser->createdTime;
|
||||
pSrcUser->updateTime = pDstUser->updateTime;
|
||||
|
|
|
@ -228,7 +228,7 @@ static int syncInitRpcServer(SSyncManager* syncManager, const SSyncCluster* pSyn
|
|||
}
|
||||
|
||||
static int syncInitRpcClient(SSyncManager* syncManager) {
|
||||
char secret[TSDB_KEY_LEN] = "secret";
|
||||
char secret[TSDB_PASSWORD_LEN] = "secret";
|
||||
SRpcInit rpcInit;
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.label = "sync-client";
|
||||
|
|
|
@ -51,8 +51,8 @@ typedef struct {
|
|||
char user[TSDB_UNI_LEN]; // meter ID
|
||||
char spi; // security parameter index
|
||||
char encrypt; // encrypt algorithm
|
||||
char secret[TSDB_KEY_LEN]; // secret for the link
|
||||
char ckey[TSDB_KEY_LEN]; // ciphering key
|
||||
char secret[TSDB_PASSWORD_LEN]; // secret for the link
|
||||
char ckey[TSDB_PASSWORD_LEN]; // ciphering key
|
||||
|
||||
void (*cfp)(void *parent, SRpcMsg *, SEpSet *);
|
||||
int (*afp)(void *parent, char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
@ -97,8 +97,8 @@ typedef struct SRpcConn {
|
|||
char user[TSDB_UNI_LEN]; // user ID for the link
|
||||
char spi; // security parameter index
|
||||
char encrypt; // encryption, 0:1
|
||||
char secret[TSDB_KEY_LEN]; // secret for the link
|
||||
char ckey[TSDB_KEY_LEN]; // ciphering key
|
||||
char secret[TSDB_PASSWORD_LEN]; // secret for the link
|
||||
char ckey[TSDB_PASSWORD_LEN]; // ciphering key
|
||||
char secured; // if set to 1, no authentication
|
||||
uint16_t localPort; // for UDP only
|
||||
uint32_t linkUid; // connection unique ID assigned by client
|
||||
|
@ -698,7 +698,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) {
|
|||
pConn->linkUid = (uint32_t)((int64_t)pConn + taosGetPid() + (int64_t)pConn->tranId);
|
||||
pConn->spi = pRpc->spi;
|
||||
pConn->encrypt = pRpc->encrypt;
|
||||
if (pConn->spi) memcpy(pConn->secret, pRpc->secret, TSDB_KEY_LEN);
|
||||
if (pConn->spi) memcpy(pConn->secret, pRpc->secret, TSDB_PASSWORD_LEN);
|
||||
tDebug("%s %p client connection is allocated, uid:0x%x", pRpc->label, pConn, pConn->linkUid);
|
||||
}
|
||||
|
||||
|
@ -1527,9 +1527,9 @@ static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) {
|
|||
int ret = -1;
|
||||
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_PASSWORD_LEN);
|
||||
MD5Update(&context, (uint8_t *)pMsg, msgLen);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_PASSWORD_LEN);
|
||||
MD5Final(&context);
|
||||
|
||||
if (memcmp(context.digest, pAuth, sizeof(context.digest)) == 0) ret = 0;
|
||||
|
@ -1541,9 +1541,9 @@ static void rpcBuildAuthHead(void *pMsg, int msgLen, void *pAuth, void *pKey) {
|
|||
MD5_CTX context;
|
||||
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_PASSWORD_LEN);
|
||||
MD5Update(&context, (uint8_t *)pMsg, msgLen);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN);
|
||||
MD5Update(&context, (uint8_t *)pKey, TSDB_PASSWORD_LEN);
|
||||
MD5Final(&context);
|
||||
|
||||
memcpy(pAuth, context.digest, sizeof(context.digest));
|
||||
|
|
|
@ -275,13 +275,13 @@ char *strsep(char **stringp, const char *delim) {
|
|||
}
|
||||
|
||||
char *getpass(const char *prefix) {
|
||||
static char passwd[TSDB_KEY_LEN] = {0};
|
||||
memset(passwd, 0, TSDB_KEY_LEN);
|
||||
static char passwd[TSDB_PASSWORD_LEN] = {0};
|
||||
memset(passwd, 0, TSDB_PASSWORD_LEN);
|
||||
//printf("%s", prefix);
|
||||
|
||||
int32_t index = 0;
|
||||
char ch;
|
||||
while (index < TSDB_KEY_LEN) {
|
||||
while (index < TSDB_PASSWORD_LEN) {
|
||||
ch = getch();
|
||||
if (ch == '\n' || ch == '\r') {
|
||||
break;
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef int32_t (*FCqWrite)(int32_t vgId, void *pHead, int32_t qtype, void *pMsg
|
|||
typedef struct {
|
||||
int32_t vgId;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; // size must same with SVnodeObj.db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]
|
||||
FCqWrite cqWrite;
|
||||
} SCqCfg;
|
||||
|
@ -37,7 +37,7 @@ typedef struct {
|
|||
int32_t master;
|
||||
int32_t num; // number of continuous streams
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
FCqWrite cqWrite;
|
||||
struct SCqObj *pHead;
|
||||
|
|
Loading…
Reference in New Issue