Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6693b5fa
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6693b5fa
编写于
2月 10, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reserve data structures for user auth
上级
05efaccf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
13 deletion
+63
-13
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+3
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+2
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+56
-12
未找到文件。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
6693b5fa
...
...
@@ -233,7 +233,8 @@ typedef struct {
int64_t
updateTime
;
int8_t
superUser
;
int32_t
acctId
;
SHashObj
*
prohibitDbHash
;
SHashObj
*
readDbs
;
SHashObj
*
writeDbs
;
}
SUserObj
;
typedef
struct
{
...
...
@@ -260,6 +261,7 @@ typedef struct {
typedef
struct
{
char
name
[
TSDB_DB_FNAME_LEN
];
char
acct
[
TSDB_USER_LEN
];
char
createdUser
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
uint64_t
uid
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
6693b5fa
...
...
@@ -73,6 +73,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
,
DB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pDb
->
acct
,
TSDB_USER_LEN
,
DB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pDb
->
createdUser
,
TSDB_USER_LEN
,
DB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
createdTime
,
DB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
updateTime
,
DB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
uid
,
DB_ENCODE_OVER
)
...
...
@@ -133,6 +134,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
,
DB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pDb
->
acct
,
TSDB_USER_LEN
,
DB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pDb
->
createdUser
,
TSDB_USER_LEN
,
DB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
createdTime
,
DB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
updateTime
,
DB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
uid
,
DB_DECODE_OVER
)
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
6693b5fa
...
...
@@ -180,6 +180,8 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
STB_DECODE_OVER:
if
(
terrno
!=
0
)
{
mError
(
"stb:%s, failed to decode from raw:%p since %s"
,
pStb
->
name
,
pRaw
,
terrstr
());
tfree
(
pStb
->
pColumns
);
tfree
(
pStb
->
pTags
);
tfree
(
pRow
);
return
NULL
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
6693b5fa
...
...
@@ -105,6 +105,24 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pUser
->
createdTime
,
USER_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pUser
->
updateTime
,
USER_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pUser
->
superUser
,
USER_ENCODE_OVER
)
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadDbs
,
USER_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteDbs
,
USER_ENCODE_OVER
)
char
*
db
=
taosHashIterate
(
pUser
->
readDbs
,
NULL
);
while
(
db
!=
NULL
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
db
,
TSDB_DB_FNAME_LEN
,
USER_ENCODE_OVER
);
db
=
taosHashIterate
(
pUser
->
readDbs
,
db
);
}
db
=
taosHashIterate
(
pUser
->
writeDbs
,
NULL
);
while
(
db
!=
NULL
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
db
,
TSDB_DB_FNAME_LEN
,
USER_ENCODE_OVER
);
db
=
taosHashIterate
(
pUser
->
writeDbs
,
db
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_USER_RESERVE_SIZE
,
USER_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
USER_ENCODE_OVER
)
...
...
@@ -138,6 +156,10 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
SUserObj
*
pUser
=
sdbGetRowObj
(
pRow
);
if
(
pUser
==
NULL
)
goto
USER_DECODE_OVER
;
pUser
->
readDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
true
);
pUser
->
writeDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
true
);
if
(
pUser
->
readDbs
==
NULL
||
pUser
->
writeDbs
==
NULL
)
goto
USER_DECODE_OVER
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pUser
->
user
,
TSDB_USER_LEN
,
USER_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
,
USER_DECODE_OVER
)
...
...
@@ -145,6 +167,26 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pUser
->
createdTime
,
USER_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pUser
->
updateTime
,
USER_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pUser
->
superUser
,
USER_DECODE_OVER
)
int32_t
numOfReadDbs
=
0
;
int32_t
numOfWriteDbs
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadDbs
,
USER_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteDbs
,
USER_DECODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
numOfReadDbs
;
++
i
)
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
dataPos
,
db
,
TSDB_DB_FNAME_LEN
,
USER_DECODE_OVER
)
int32_t
len
=
strlen
(
db
)
+
1
;
taosHashPut
(
pUser
->
readDbs
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteDbs
;
++
i
)
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
dataPos
,
db
,
TSDB_DB_FNAME_LEN
,
USER_DECODE_OVER
)
int32_t
len
=
strlen
(
db
)
+
1
;
taosHashPut
(
pUser
->
writeDbs
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
);
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_USER_RESERVE_SIZE
,
USER_DECODE_OVER
)
terrno
=
0
;
...
...
@@ -152,6 +194,8 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
USER_DECODE_OVER:
if
(
terrno
!=
0
)
{
mError
(
"user:%s, failed to decode from raw:%p since %s"
,
pUser
->
user
,
pRaw
,
terrstr
());
taosHashCleanup
(
pUser
->
readDbs
);
taosHashCleanup
(
pUser
->
writeDbs
);
tfree
(
pRow
);
return
NULL
;
}
...
...
@@ -162,13 +206,7 @@ USER_DECODE_OVER:
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform insert action, row:%p"
,
pUser
->
user
,
pUser
);
pUser
->
prohibitDbHash
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pUser
->
prohibitDbHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, failed to perform insert action since %s"
,
pUser
->
user
,
terrstr
());
return
-
1
;
}
SAcctObj
*
pAcct
=
sdbAcquire
(
pSdb
,
SDB_ACCT
,
pUser
->
acct
);
if
(
pAcct
==
NULL
)
{
terrno
=
TSDB_CODE_MND_ACCT_NOT_EXIST
;
...
...
@@ -183,11 +221,8 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) {
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform delete action, row:%p"
,
pUser
->
user
,
pUser
);
if
(
pUser
->
prohibitDbHash
)
{
taosHashCleanup
(
pUser
->
prohibitDbHash
);
pUser
->
prohibitDbHash
=
NULL
;
}
taosHashCleanup
(
pUser
->
readDbs
);
taosHashCleanup
(
pUser
->
writeDbs
);
return
0
;
}
...
...
@@ -195,6 +230,15 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
mTrace
(
"user:%s, perform update action, old row:%p new row:%p"
,
pOld
->
user
,
pOld
,
pNew
);
memcpy
(
pOld
->
pass
,
pNew
->
pass
,
TSDB_PASSWORD_LEN
);
pOld
->
updateTime
=
pNew
->
updateTime
;
void
*
tmp1
=
pOld
->
readDbs
;
pOld
->
readDbs
=
pNew
->
readDbs
;
pNew
->
readDbs
=
tmp1
;
void
*
tmp2
=
pOld
->
writeDbs
;
pOld
->
writeDbs
=
pNew
->
writeDbs
;
pNew
->
writeDbs
=
tmp2
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录