secure jsondb user perms (#404)

This commit is contained in:
Cameron 2023-08-11 01:25:56 -07:00 committed by GitHub
parent 6bbe230fe8
commit 7488f283c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 8 deletions

View file

@ -3,6 +3,9 @@ package jsondb
import (
"encoding/json"
"fmt"
"os"
"path"
"github.com/ngoduykhanh/wireguard-ui/model"
)
@ -65,7 +68,11 @@ func (o *JsonDB) SaveWakeOnLanHost(host model.WakeOnLanHost) error {
return err
}
return o.conn.Write(model.WakeOnLanHostCollectionName, resourceName, host)
wakeOnLanHostPath := path.Join(path.Join(o.dbPath, model.WakeOnLanHostCollectionName), resourceName+".json")
output := o.conn.Write(model.WakeOnLanHostCollectionName, resourceName, host)
os.Chmod(wakeOnLanHostPath, 0600)
return output
}
func (o *JsonDB) DeleteWakeOnHost(host model.WakeOnLanHost) error {