mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-09-17 17:15:16 +00:00
non anonymous samba shares
This commit is contained in:
parent
7da0f0d49e
commit
94e545b388
@ -14,4 +14,5 @@ type Shares struct {
|
||||
ID uint `json:"id"`
|
||||
Anonymous bool `json:"anonymous"`
|
||||
Path string `json:"path"`
|
||||
Valid_users []string{} `json:"valid_users"`
|
||||
}
|
||||
|
@ -85,8 +85,9 @@ func PostSambaSharesCreate(ctx echo.Context) error {
|
||||
}
|
||||
for _, v := range shares {
|
||||
shareDBModel := model2.SharesDBModel{}
|
||||
shareDBModel.Anonymous = true
|
||||
shareDBModel.Anonymous = v.Anonymous
|
||||
shareDBModel.Path = v.Path
|
||||
shareDBModel.Valid_users = v.Valid_users
|
||||
shareDBModel.Name = filepath.Base(v.Path)
|
||||
os.Chmod(v.Path, 0o777)
|
||||
service.MyService.Shares().CreateShare(shareDBModel)
|
||||
|
@ -13,6 +13,7 @@ package model
|
||||
type SharesDBModel struct {
|
||||
ID uint `gorm:"column:id;primary_key" json:"id"`
|
||||
Anonymous bool `json:"anonymous"`
|
||||
Valid_users []string {} `json:"valid_users"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Updated int64 `gorm:"autoUpdateTime"`
|
||||
|
@ -79,16 +79,20 @@ func (s *sharesStruct) UpdateConfigFile() {
|
||||
configStr += `
|
||||
[` + dirName + `]
|
||||
comment = CasaOS share ` + dirName + `
|
||||
public = Yes
|
||||
public = ` + if (share.Anonymous){`Yes`} else {`No`} + `
|
||||
path = ` + share.Path + `
|
||||
browseable = Yes
|
||||
read only = No
|
||||
guest ok = Yes
|
||||
guest ok = ` + if (share.Anonymous){`Yes`} else {`No`} + `
|
||||
create mask = 0777
|
||||
directory mask = 0777
|
||||
force user = root
|
||||
` + if (share.Anonymous){`force user = root`} else {`#force user = root`} +
|
||||
if (!share.Anonymous) {`valid users` +
|
||||
for _, user := range share.Valid_users {
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
`
|
||||
}
|
||||
// write config file
|
||||
file.WriteToPath([]byte(configStr), "/etc/samba", "smb.casa.conf")
|
||||
|
Loading…
x
Reference in New Issue
Block a user