From dab80865eee58914ddfaa99b9e2c1f9471965c45 Mon Sep 17 00:00:00 2001 From: Hank Shen Date: Sun, 17 Sep 2023 20:46:17 +0800 Subject: [PATCH] fix --- go.mod | 2 +- go.sum | 4 ++-- .../application/library/fileperm/fileperm.go | 5 ++++- .../ftpmanager/application/library/ftp/driver.go | 5 +++++ .../ftpmanager/application/model/ftpUser.go | 11 +++-------- vendor/modules.txt | 4 ++-- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 7a351d78d5..c96142d417 100644 --- a/go.mod +++ b/go.mod @@ -147,7 +147,7 @@ require ( github.com/nging-plugins/dlmanager v1.4.2 github.com/nging-plugins/firewallmanager v1.4.2 github.com/nging-plugins/frpmanager v1.4.2 - github.com/nging-plugins/ftpmanager v1.4.0 + github.com/nging-plugins/ftpmanager v1.4.2 github.com/nging-plugins/servermanager v1.4.13 github.com/nging-plugins/sshmanager v1.4.0 github.com/nging-plugins/webauthn v1.4.5 diff --git a/go.sum b/go.sum index fba452f76c..9de78d66c3 100644 --- a/go.sum +++ b/go.sum @@ -1618,8 +1618,8 @@ github.com/nging-plugins/firewallmanager v1.4.2 h1:XZGH1Jz0Jrqlgd2h7OUlHCei/nK+M github.com/nging-plugins/firewallmanager v1.4.2/go.mod h1:oR9VmVWqDtQsCQdl+whePugkPrZWjMck9K/25CRIP/I= github.com/nging-plugins/frpmanager v1.4.2 h1:PUks5yU/1onhBzd2cQoA+XYYp+HVe+iq+5PbLujbKpk= github.com/nging-plugins/frpmanager v1.4.2/go.mod h1:DbRaQsvnNxeOzLvHXQncEeCMUUHutnMgb35ymaYmEMY= -github.com/nging-plugins/ftpmanager v1.4.0 h1:DnlHuk+TsGlboPrrTVP4ixcB53dJYPjNeyLkmTzOSG4= -github.com/nging-plugins/ftpmanager v1.4.0/go.mod h1:XbeaPWl6VHHPZAEhLpTTL160/W+wUOlSIzsNj2G9y/c= +github.com/nging-plugins/ftpmanager v1.4.2 h1:bU4UJoawHmgo8LwzMGoykP7LfOmACuU15p/0WQQ5np8= +github.com/nging-plugins/ftpmanager v1.4.2/go.mod h1:9ybi8zb7JjPp2PRqfhcg8tVqXJBfc2tPLOFa32FI4SM= github.com/nging-plugins/servermanager v1.4.13 h1:R83sHymhvOmeeQbr5KKjX3W4S+mQdCqdGv+txA5687k= github.com/nging-plugins/servermanager v1.4.13/go.mod h1:jWP91vUBNwtHyjFt5xLoLFpr+ouq6dPxLOKVTgZchSI= github.com/nging-plugins/sshmanager v1.4.0 h1:LCqruAZiTG3PcZPh5jrdNiv5/nfnj17079IAC7jaCrE= diff --git a/vendor/github.com/nging-plugins/ftpmanager/application/library/fileperm/fileperm.go b/vendor/github.com/nging-plugins/ftpmanager/application/library/fileperm/fileperm.go index 0a6ffda51c..a3d39be892 100644 --- a/vendor/github.com/nging-plugins/ftpmanager/application/library/fileperm/fileperm.go +++ b/vendor/github.com/nging-plugins/ftpmanager/application/library/fileperm/fileperm.go @@ -89,13 +89,16 @@ type User struct { // Allowed checks if the user has permission to access a directory/file func (u User) Allowed(path string, modification bool) bool { - var rule *Rule i := len(u.Rules) - 1 + if i < 0 { + return !modification || u.Writeable + } path = filepath.ToSlash(path) hasSuffix := strings.HasSuffix(path, `/`) hasPrefix := strings.HasPrefix(path, `/`) + var rule *Rule for i >= 0 { rule = u.Rules[i] diff --git a/vendor/github.com/nging-plugins/ftpmanager/application/library/ftp/driver.go b/vendor/github.com/nging-plugins/ftpmanager/application/library/ftp/driver.go index 0580f99a47..1056c4ffc9 100644 --- a/vendor/github.com/nging-plugins/ftpmanager/application/library/ftp/driver.go +++ b/vendor/github.com/nging-plugins/ftpmanager/application/library/ftp/driver.go @@ -213,6 +213,11 @@ func (f *FileDriver) GetFile(ftpCtx *ftpserver.Context, path string, offset int6 } func (f *FileDriver) PutFile(ftpCtx *ftpserver.Context, destPath string, data io.Reader, offset int64) (int64, error) { + defer func() { + if d, y := data.(io.Closer); y { + d.Close() + } + }() rPath, err := f.realPath(ftpCtx, destPath, PathTypeFile, OperateCreate) if err != nil { return 0, err diff --git a/vendor/github.com/nging-plugins/ftpmanager/application/model/ftpUser.go b/vendor/github.com/nging-plugins/ftpmanager/application/model/ftpUser.go index 2f18e38640..5859a0f52a 100644 --- a/vendor/github.com/nging-plugins/ftpmanager/application/model/ftpUser.go +++ b/vendor/github.com/nging-plugins/ftpmanager/application/model/ftpUser.go @@ -159,14 +159,7 @@ func (f *FtpUser) GetRootPathOnce(username string) (string, error) { } func (f *FtpUser) Allowed(path string, modification bool) bool { - if f.userPermission.Rules.IsEmpty() { - return f.groupPermission.Allowed(path, modification) - } - userAllowed := f.userPermission.Allowed(path, modification) - if f.groupPermission.Rules.IsEmpty() { - return userAllowed - } - return userAllowed && f.groupPermission.Allowed(path, modification) + return f.userPermission.Allowed(path, modification) && f.groupPermission.Allowed(path, modification) } func (f *FtpUser) RootPath(username string) (basePath string, err error) { @@ -188,6 +181,8 @@ func (f *FtpUser) RootPath(username string) (basePath string, err error) { } basePath = m.NgingFtpUserGroup.Directory f.groupDefaultModify = m.NgingFtpUserGroup.Modify == `Y` + } else { + f.groupDefaultModify = f.Modify == `Y` } if f.NgingFtpUser.Banned == `Y` { err = ErrBannedUser diff --git a/vendor/modules.txt b/vendor/modules.txt index b50a421b12..72ac40c4ba 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1152,8 +1152,8 @@ github.com/nging-plugins/frpmanager/application/library/frp/rpcservice github.com/nging-plugins/frpmanager/application/library/setup github.com/nging-plugins/frpmanager/application/library/utils github.com/nging-plugins/frpmanager/application/model -# github.com/nging-plugins/ftpmanager v1.4.0 -## explicit; go 1.17 +# github.com/nging-plugins/ftpmanager v1.4.2 +## explicit; go 1.21.0 github.com/nging-plugins/ftpmanager github.com/nging-plugins/ftpmanager/application/dbschema github.com/nging-plugins/ftpmanager/application/handler