1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: demo 环境禁用终端工具 (#5235)

This commit is contained in:
ssongliu 2024-05-31 14:51:18 +08:00 committed by GitHub
parent ac33f5461d
commit a02f160adf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,6 +79,13 @@ func (b *BaseApi) RedisWsSsh(c *gin.Context) {
global.LOG.Errorf("gin context http handler failed, err: %v", err) global.LOG.Errorf("gin context http handler failed, err: %v", err)
return return
} }
defer wsConn.Close()
if global.CONF.System.IsDemo {
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
return
}
}
cols, err := strconv.Atoi(c.DefaultQuery("cols", "80")) cols, err := strconv.Atoi(c.DefaultQuery("cols", "80"))
if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) { if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) {
@ -90,7 +97,6 @@ func (b *BaseApi) RedisWsSsh(c *gin.Context) {
} }
name := c.Query("name") name := c.Query("name")
from := c.Query("from") from := c.Query("from")
defer wsConn.Close()
commands := []string{"redis-cli"} commands := []string{"redis-cli"}
database, err := databaseService.Get(name) database, err := databaseService.Get(name)
if wshandleError(wsConn, errors.WithMessage(err, "no such database in db")) { if wshandleError(wsConn, errors.WithMessage(err, "no such database in db")) {
@ -148,6 +154,12 @@ func (b *BaseApi) ContainerWsSsh(c *gin.Context) {
} }
defer wsConn.Close() defer wsConn.Close()
if global.CONF.System.IsDemo {
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
return
}
}
containerID := c.Query("containerid") containerID := c.Query("containerid")
command := c.Query("command") command := c.Query("command")
user := c.Query("user") user := c.Query("user")