diff --git a/agent/app/service/file.go b/agent/app/service/file.go index 8d019742d..4da9daca7 100644 --- a/agent/app/service/file.go +++ b/agent/app/service/file.go @@ -204,15 +204,25 @@ func (f *FileService) Create(op request.FileCreate) error { } } if op.IsDir { - return fo.CreateDirWithMode(op.Path, fs.FileMode(mode)) + if err := fo.CreateDirWithMode(op.Path, fs.FileMode(mode)); err != nil { + return err + } + handleDefaultOwn(op.Path) + return nil } if op.IsLink { if !fo.Stat(op.LinkPath) { return buserr.New("ErrLinkPathNotFound") } - return fo.LinkFile(op.LinkPath, op.Path, op.IsSymlink) + if err := fo.LinkFile(op.LinkPath, op.Path, op.IsSymlink); err != nil { + return err + } } - return fo.CreateFileWithMode(op.Path, fs.FileMode(mode)) + if err := fo.CreateFileWithMode(op.Path, fs.FileMode(mode)); err != nil { + return err + } + handleDefaultOwn(op.Path) + return nil } func (f *FileService) Delete(op request.FileDelete) error { diff --git a/agent/app/service/website_utils.go b/agent/app/service/website_utils.go index d78fd6295..a878281ea 100644 --- a/agent/app/service/website_utils.go +++ b/agent/app/service/website_utils.go @@ -10,6 +10,7 @@ import ( "path/filepath" "strconv" "strings" + "syscall" "time" "github.com/1Panel-dev/1Panel/agent/app/repo" @@ -1357,3 +1358,17 @@ func ConfigAIProxy(website model.Website) error { } return nil } + +func handleDefaultOwn(dir string) { + parentDir := path.Dir(dir) + info, err := os.Stat(parentDir) + if err != nil { + return + } + stat, ok := info.Sys().(*syscall.Stat_t) + uid, gid := -1, -1 + if ok { + uid, gid = int(stat.Uid), int(stat.Gid) + } + _ = os.Chown(dir, uid, gid) +} diff --git a/core/app/api/v2/backup.go b/core/app/api/v2/backup.go index 351669174..e7813fea9 100644 --- a/core/app/api/v2/backup.go +++ b/core/app/api/v2/backup.go @@ -47,7 +47,7 @@ func (b *BaseApi) RefreshToken(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Backup Account @@ -112,7 +112,7 @@ func (b *BaseApi) DeleteBackup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Backup Account @@ -134,5 +134,5 @@ func (b *BaseApi) UpdateBackup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } diff --git a/core/app/api/v2/command.go b/core/app/api/v2/command.go index 900a29c66..0e2f7ae03 100644 --- a/core/app/api/v2/command.go +++ b/core/app/api/v2/command.go @@ -25,7 +25,7 @@ func (b *BaseApi) CreateCommand(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Command @@ -119,7 +119,7 @@ func (b *BaseApi) DeleteCommand(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Command @@ -141,5 +141,5 @@ func (b *BaseApi) UpdateCommand(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } diff --git a/core/app/api/v2/group.go b/core/app/api/v2/group.go index c532ce7df..0e92b9c60 100644 --- a/core/app/api/v2/group.go +++ b/core/app/api/v2/group.go @@ -25,7 +25,7 @@ func (b *BaseApi) CreateGroup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Group @@ -47,7 +47,7 @@ func (b *BaseApi) DeleteGroup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Group @@ -69,7 +69,7 @@ func (b *BaseApi) UpdateGroup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Group diff --git a/core/app/api/v2/helper/helper.go b/core/app/api/v2/helper/helper.go index 15b918284..2430a0e52 100644 --- a/core/app/api/v2/helper/helper.go +++ b/core/app/api/v2/helper/helper.go @@ -47,7 +47,7 @@ func SuccessWithData(ctx *gin.Context, data interface{}) { ctx.Abort() } -func SuccessWithOutData(ctx *gin.Context) { +func Success(ctx *gin.Context) { res := dto.Response{ Code: http.StatusOK, Message: "success", diff --git a/core/app/api/v2/host.go b/core/app/api/v2/host.go index d7dee0c28..b032c95c9 100644 --- a/core/app/api/v2/host.go +++ b/core/app/api/v2/host.go @@ -153,7 +153,7 @@ func (b *BaseApi) DeleteHost(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Host @@ -244,7 +244,7 @@ func (b *BaseApi) UpdateHostGroup(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags Host diff --git a/core/app/api/v2/logs.go b/core/app/api/v2/logs.go index 177e18f35..50afde262 100644 --- a/core/app/api/v2/logs.go +++ b/core/app/api/v2/logs.go @@ -78,5 +78,5 @@ func (b *BaseApi) CleanLogs(c *gin.Context) { return } - helper.SuccessWithOutData(c) + helper.Success(c) } diff --git a/core/app/api/v2/script_library.go b/core/app/api/v2/script_library.go index 96c3d7e1e..36e5785d2 100644 --- a/core/app/api/v2/script_library.go +++ b/core/app/api/v2/script_library.go @@ -36,7 +36,7 @@ func (b *BaseApi) CreateScript(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags ScriptLibrary @@ -84,7 +84,7 @@ func (b *BaseApi) DeleteScript(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags ScriptLibrary @@ -99,7 +99,7 @@ func (b *BaseApi) SyncScript(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags ScriptLibrary @@ -121,7 +121,7 @@ func (b *BaseApi) UpdateScript(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } func (b *BaseApi) RunScript(c *gin.Context) { diff --git a/core/app/api/v2/setting.go b/core/app/api/v2/setting.go index c63ce270c..14ec03293 100644 --- a/core/app/api/v2/setting.go +++ b/core/app/api/v2/setting.go @@ -54,7 +54,7 @@ func (b *BaseApi) GetTerminalSettingInfo(c *gin.Context) { // @Security Timestamp // @Router /core/settings/search/available [get] func (b *BaseApi) GetSystemAvailable(c *gin.Context) { - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -86,7 +86,7 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) { entranceValue := base64.StdEncoding.EncodeToString([]byte(req.Value)) c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true) } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -108,7 +108,7 @@ func (b *BaseApi) UpdateTerminalSetting(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -139,7 +139,7 @@ func (b *BaseApi) UpdateProxy(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -161,7 +161,7 @@ func (b *BaseApi) UpdateMenu(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -183,7 +183,7 @@ func (b *BaseApi) UpdatePassword(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -205,7 +205,7 @@ func (b *BaseApi) UpdateSSL(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -274,7 +274,7 @@ func (b *BaseApi) UpdateBindInfo(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -296,7 +296,7 @@ func (b *BaseApi) UpdatePort(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -318,7 +318,7 @@ func (b *BaseApi) HandlePasswordExpired(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -380,7 +380,7 @@ func (b *BaseApi) MFABind(c *gin.Context) { return } - helper.SuccessWithOutData(c) + helper.Success(c) } func (b *BaseApi) ReloadSSL(c *gin.Context) { @@ -393,7 +393,7 @@ func (b *BaseApi) ReloadSSL(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -442,7 +442,7 @@ func (b *BaseApi) UpdateApiConfig(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } func checkEntrancePattern(val string) bool { diff --git a/core/app/api/v2/upgrade.go b/core/app/api/v2/upgrade.go index ab48111e0..434ef3af9 100644 --- a/core/app/api/v2/upgrade.go +++ b/core/app/api/v2/upgrade.go @@ -62,7 +62,7 @@ func (b *BaseApi) Upgrade(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } // @Tags System Setting @@ -84,5 +84,5 @@ func (b *BaseApi) Rollback(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithOutData(c) + helper.Success(c) } diff --git a/core/init/router/proxy.go b/core/init/router/proxy.go index 76f88dee7..c56da03fc 100644 --- a/core/init/router/proxy.go +++ b/core/init/router/proxy.go @@ -31,8 +31,9 @@ func Proxy() gin.HandlerFunc { return } var currentNode string - if c.Query("operateNode") != "" { - currentNode = c.Query("operateNode") + queryNode := c.Query("operateNode") + if queryNode != "" && queryNode != "undefined" { + currentNode = queryNode } else { currentNode = c.Request.Header.Get("CurrentNode") } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 8b93c6e0d..80a822b99 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -3116,6 +3116,7 @@ const message = { websites: 'Website List', trend: 'Trend Statistics', reqCount: 'Request Count', + uriHelper: 'You can use /test/* or /*/index.php to exclude Uri', }, tamper: { tamper: 'Website Tamper Protection', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 94088de06..911ad80b7 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -2974,6 +2974,7 @@ const message = { websites: 'ウェブサイトリスト', trend: 'トレンド統計', reqCount: 'リクエスト数', + uriHelper: '/test/* や /*/index.php を使用して Uri を除外できます', }, tamper: { tamper: 'ウェブサイトの改ざん防止', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index b2197341e..8e1eaab8e 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -2930,6 +2930,7 @@ const message = { websites: '웹사이트 목록', trend: '추세 통계', reqCount: '요청 수', + uriHelper: '/test/* 또는 /*/index.php를 사용하여 Uri를 제외할 수 있습니다', }, tamper: { tamper: '웹사이트 변조 방지', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index b10eb36dc..11e4b4338 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -3041,6 +3041,7 @@ const message = { websites: 'Senarai Laman Web', trend: 'Statistik Trend', reqCount: 'Jumlah Permintaan', + uriHelper: 'Anda boleh menggunakan /test/* atau /*/index.php untuk mengecualikan Uri', }, tamper: { tamper: 'Perlindungan daripada peng篡改 laman web', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 67a529346..bf7499c1e 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -3043,6 +3043,7 @@ const message = { websites: 'Lista de Sites', trend: 'Estatísticas de Tendência', reqCount: 'Contagem de Solicitações', + uriHelper: 'Você pode usar /test/* ou /*/index.php para excluir Uri', }, tamper: { tamper: 'Proteção contra adulteração do site', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index d5be02398..27ae3450a 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -3034,6 +3034,7 @@ const message = { websites: 'Список веб-сайтов', trend: 'Статистика тренда', reqCount: 'Количество запросов', + uriHelper: 'Вы можете использовать /test/* или /*/index.php для исключения Uri', }, tamper: { tamper: 'Защита от подделки сайта', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 71e5a2672..d9a6fa4d8 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -2894,6 +2894,7 @@ const message = { websites: '網站列表', trend: '趨勢統計', reqCount: '請求數', + uriHelper: '可以使用 /test/* 或者 /*/index.php 來排除 Uri', }, tamper: { tamper: '網站防篡改', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 0d470f765..5e4e017e5 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -2877,6 +2877,7 @@ const message = { websites: '网站列表', trend: '趋势统计', reqCount: '请求数', + uriHelper: '可以使用 /test/* 或者 /*/index.php 来排除 Uri', }, tamper: { tamper: '网站防篡改',