feat(smb-server): smb server support#8250
feat(smb-server): smb server support#8250KirCute wants to merge 2 commits intoAlistGo:mainfrom KirCute:feat/smb-server
Conversation
Walkthrough该PR引入了对SMB服务器的支持,基于 Changes
|
| if u.IsGuest() || !u.CanSMBAccess() { | ||
| return "", false | ||
| } | ||
| return u.PwdHash[:16], true |
There was a problem hiding this comment.
使用用户密码的加盐SHA256哈希的前16位作为SMB服务的访问密码可能存在安全隐患,因为这可能会导致密码的安全性降低。建议考虑更安全的密码存储和验证方式。
There was a problem hiding this comment.
Pull Request Overview
This PR introduces preliminary SMB server support based on modifications to the go-smb2-alist implementation and adds new VFS methods for SMB file operations. Key changes include:
- The implementation of a new VFS interface (readingFile/writingFile) for SMB operations.
- Enhancements for user permission checks and file upload/download flows.
- Configuration updates and integration into the main server startup.
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/smb/vfs.go | Implements the VFS interface and file handle operations. |
| server/smb/fsup.go | Adds file upload support with temporary file handling. |
| server/smb/fsread.go | Implements readingFile and download initialization methods. |
| server/smb/fsmanage.go | Introduces directory management functions (mkdir, rename). |
| server/smb.go | Configures the SMB server and integrates user authentication. |
| internal/model/user.go | Adds permission bits for SMB access and management. |
| internal/conf/config.go | Updates configuration structure with SMB settings. |
| cmd/server.go | Integrates SMB server startup into the main server routine. |
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
server/smb.go:62
- In GetUserFileSystem, if the user does not have SMB access, return an explicit permission denied error rather than returning the unresolved err value.
if !userObj.CanSMBAccess() { return nil, err }
| if err = fs.MakeDir(ctx, reqPath); err != nil { | ||
| return nil, err | ||
| } | ||
| return fs.Get(ctx, path, &fs.GetArgs{}) |
There was a problem hiding this comment.
In Mkdir, consider using the resolved reqPath (obtained from user.JoinPath) instead of the original path when calling fs.Get for consistent path handling.
| return fs.Get(ctx, path, &fs.GetArgs{}) | |
| return fs.Get(ctx, reqPath, &fs.GetArgs{}) |
There was a problem hiding this comment.
已修改,这个有点吓人,但不知道为什么好像对实际使用影响没那么大
已修改 |
|
最近调试遇到了一些困难,一时半会没办法改进windows挂载的体验,还是先不要合并这个pr了 |
在
macos-fuse-t/go-smb2的基础上改了一些实现的 SMB 挂载。已使用以下客户端进行测试,由于 SMB 协议非常贴近底层,适配起来问题比较多,希望有意者可以再多用几种客户端进行测试,分享一下测试结果。
Open)和关闭(Close)待删除的文件,删除文件夹通过,客户端不支持复制,其它通过。Unable to apply new capability set.,拼尽全力无法战胜。使用命令:
这是最主要的使用场景但效果不尽人意,后面再优化一下吧。
暂时没有测试游客访问。
除此之外登录验证部分还存在一些问题,SMB 比较基础的验证方式 NTLMv2 大概是这么一个原理:
显然这样的验证方式需要服务器知道密码的原文(退而求其次也必须知道密码的 MD4 哈希),然而服务器中只有用户的加盐 SHA256 哈希,所以验证这一块我暂时不知道怎么搞,想听听大伙怎么想。
目前访问 SMB 服务使用的密码是用户密码的加盐 SHA256 哈希的前 16 位。
Front-end part: AlistGo/alist-web#266