get samba users

This commit is contained in:
Sheep26 2024-12-03 17:11:14 +13:00 committed by Drew Fitzgerald
parent 00e17b5b6c
commit 9e7619b481
2 changed files with 19 additions and 0 deletions

View File

@ -176,6 +176,11 @@ func InitV1Router() http.Handler {
v1SharesGroup.DELETE("/:id", v1.DeleteSambaShares)
v1SharesGroup.GET("/status", v1.GetSambaStatus)
}
v1SharesGroup := v1SambaGroup.Group("/users")
v1SharesGroup.Use()
{
v1SharesGroup.GET("", v1.ListSambaUsers)
}
}
v1NotifyGroup := v1Group.Group("/notify")
v1NotifyGroup.Use()

View File

@ -17,6 +17,8 @@ import (
"os"
"path/filepath"
"strings"
"os/exec"
"strings"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS-Common/utils/systemctl"
@ -67,6 +69,18 @@ func GetSambaSharesList(ctx echo.Context) error {
return ctx.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: shareList})
}
func ListSambaUsers(ctx echo.Context) error {
out, err := exec.Command("pdbedit -L").Output()
if err != nil {
return ctx.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.Failed, Message: common_err.GetMsg(common_err.Failed)})
}
users := strings.Split("\n")
return ctx.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: users})
}
func PostSambaSharesCreate(ctx echo.Context) error {
shares := []model.Shares{}
ctx.Bind(&shares)