Skip to content

Commit

Permalink
Merge pull request #22888 from taosdata/enh/TD-26272
Browse files Browse the repository at this point in the history
enh: prevent accessing ins_users&ins_user_privileges without sysinfo
  • Loading branch information
dapan1121 committed Sep 14, 2023
2 parents 5296207 + 90a6fb3 commit 8654012
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions source/common/src/systable.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_TAGS, userTagsSchema, tListLen(userTagsSchema), false},
{TSDB_INS_TABLE_COLS, userColsSchema, tListLen(userColsSchema), false},
// {TSDB_INS_TABLE_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
{TSDB_INS_TABLE_USERS, userUsersSchema, tListLen(userUsersSchema), false},
{TSDB_INS_TABLE_USERS, userUsersSchema, tListLen(userUsersSchema), true},
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema), true},
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema), true},
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema), false},
Expand All @@ -336,7 +336,7 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false},
{TSDB_INS_TABLE_STREAM_TASKS, streamTaskSchema, tListLen(streamTaskSchema), false},
{TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true},
{TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), false},
{TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), true},
};

static const SSysDbTableSchema connectionsSchema[] = {
Expand Down
9 changes: 8 additions & 1 deletion source/dnode/mnode/impl/src/mndInfoSchema.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
}

STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
if (NULL == pMeta || (!sysinfo && pMeta->sysInfo)) {
if (NULL == pMeta) {
mError("invalid information schema table name:%s", tbName);
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
return -1;
}

if (!sysinfo && pMeta->sysInfo) {
mError("no permission to get schema of table name:%s", tbName);
terrno = TSDB_CODE_PAR_PERMISSION_DENIED;
return -1;
}


*pRsp = *pMeta;

pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
Expand Down
3 changes: 2 additions & 1 deletion tests/script/tsim/user/privilege_sysinfo.sim
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ sql_error select * from information_schema.ins_mnodes
sql_error select * from information_schema.ins_modules
sql_error select * from information_schema.ins_qnodes
sql_error select * from information_schema.ins_cluster
sql_error select * from information_schema.ins_users
sql_error select * from information_schema.ins_user_privilege
sql select * from information_schema.ins_databases
sql select * from information_schema.ins_functions
sql select * from information_schema.ins_indexes
sql select * from information_schema.ins_stables
sql select * from information_schema.ins_tables
sql select * from information_schema.ins_tags
sql select * from information_schema.ins_users
sql select * from information_schema.ins_topics
sql select * from information_schema.ins_subscriptions
sql select * from information_schema.ins_streams
Expand Down

0 comments on commit 8654012

Please sign in to comment.