From 862686e4e2b7712d2ca4682552220b30b24e3480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Thu, 23 Nov 2023 21:48:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Rsync=20secret=20?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/plugins/rsync_controller.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/http/controllers/plugins/rsync_controller.go b/app/http/controllers/plugins/rsync_controller.go index 5831c489..5f05c99d 100644 --- a/app/http/controllers/plugins/rsync_controller.go +++ b/app/http/controllers/plugins/rsync_controller.go @@ -134,13 +134,8 @@ func (r *RsyncController) List(ctx http.Context) http.Response { modules = append(modules, *currentModule) } moduleName := line[1 : len(line)-1] - secret, err := tools.Exec("grep -E '^" + moduleName + ":.*$' /etc/rsyncd.secrets | awk -F ':' '{print $2}'") - if err != nil { - return controllers.Error(ctx, http.StatusInternalServerError, "获取模块"+moduleName+"的密钥失败") - } currentModule = &RsyncModule{ - Name: moduleName, - Secret: secret, + Name: moduleName, } } else if currentModule != nil { parts := strings.SplitN(line, "=", 2) @@ -157,6 +152,10 @@ func (r *RsyncController) List(ctx http.Context) http.Response { currentModule.ReadOnly = value == "yes" || value == "true" case "auth users": currentModule.AuthUser = value + currentModule.Secret, err = tools.Exec("grep -E '^" + currentModule.AuthUser + ":.*$' /etc/rsyncd.secrets | awk -F ':' '{print $2}'") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "获取模块"+currentModule.AuthUser+"的密钥失败") + } case "hosts allow": currentModule.HostsAllow = value }