Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b47c829a
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看板
提交
b47c829a
编写于
6月 24, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: auth failure
上级
e8db435e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
17 deletion
+30
-17
source/dnode/mnode/impl/inc/mndAuth.h
source/dnode/mnode/impl/inc/mndAuth.h
+2
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+7
-2
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+20
-13
未找到文件。
source/dnode/mnode/impl/inc/mndAuth.h
浏览文件 @
b47c829a
...
...
@@ -23,7 +23,8 @@ extern "C" {
#endif
typedef
enum
{
MND_OPER_CREATE_USER
=
1
,
MND_OPER_CONNECT
=
1
,
MND_OPER_CREATE_USER
,
MND_OPER_DROP_USER
,
MND_OPER_ALTER_USER
,
MND_OPER_CREATE_BNODE
,
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
b47c829a
...
...
@@ -222,7 +222,7 @@ typedef struct {
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
+
1
];
char
pass
[
TSDB_PASSWORD_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
...
...
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
b47c829a
...
...
@@ -93,8 +93,13 @@ int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
goto
_OVER
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
-
1
;
switch
(
operType
)
{
case
MND_OPER_CONNECT
:
break
;
default:
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
-
1
;
}
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
b47c829a
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndProfile.h"
#include "mndAuth.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -215,36 +216,42 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
char
ip
[
24
]
=
{
0
};
const
STraceId
*
trace
=
&
pReq
->
info
.
traceId
;
if
(
tDeserializeSConnectReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
connReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CONN
_OVER
;
goto
_OVER
;
}
taosIp2String
(
pReq
->
info
.
conn
.
clientIp
,
ip
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
{
mGError
(
"user:%s, failed to login
while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
terrstr
());
goto
CONN
_OVER
;
mGError
(
"user:%s, failed to login
from %s while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
if
(
0
!=
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
))
{
mGError
(
"user:%s, failed to auth while acquire user, input:%s"
,
pReq
->
info
.
conn
.
user
,
connReq
.
passwd
);
if
(
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since invalid pass, input:%s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
passwd
);
code
=
TSDB_CODE_RPC_AUTH_FAILURE
;
goto
CONN_OVER
;
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONNECT
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
if
(
connReq
.
db
[
0
])
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
}
;
snprintf
(
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pUser
->
acctId
,
TS_PATH_DELIMITER
,
connReq
.
db
);
pDb
=
mndAcquireDb
(
pMnode
,
db
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mGError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
db
,
terrstr
());
goto
CONN
_OVER
;
goto
_OVER
;
}
}
...
...
@@ -252,7 +259,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pReq
->
info
.
conn
.
clientPort
,
connReq
.
pid
,
connReq
.
app
,
connReq
.
startTime
);
if
(
pConn
==
NULL
)
{
mGError
(
"user:%s, failed to login from %s while create connection since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
CONN
_OVER
;
goto
_OVER
;
}
SConnectRsp
connectRsp
=
{
0
};
...
...
@@ -268,9 +275,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
mndGetMnodeEpSet
(
pMnode
,
&
connectRsp
.
epSet
);
int32_t
contLen
=
tSerializeSConnectRsp
(
NULL
,
0
,
&
connectRsp
);
if
(
contLen
<
0
)
goto
CONN
_OVER
;
if
(
contLen
<
0
)
goto
_OVER
;
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
goto
CONN
_OVER
;
if
(
pRsp
==
NULL
)
goto
_OVER
;
tSerializeSConnectRsp
(
pRsp
,
contLen
,
&
connectRsp
);
pReq
->
info
.
rspLen
=
contLen
;
...
...
@@ -280,7 +287,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
code
=
0
;
CONN
_OVER:
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseDb
(
pMnode
,
pDb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录