fix (plg_backend_nfs): support auxiliary gids

This commit is contained in:
MickaelK
2024-04-15 19:14:33 +10:00
parent ee2ce3f5c5
commit 0a728c695b
3 changed files with 96 additions and 46 deletions

View File

@ -9,26 +9,28 @@ import (
"github.com/vmware/go-nfs-client/nfs/xdr"
)
// ref: https://datatracker.ietf.org/doc/html/rfc5531#section-8.2
// so far we only have implemented AUTH_SYS but one day we might want to add support
// for RPCSEC_GSS as detailed in https://datatracker.ietf.org/doc/html/rfc2203
type AuthUnix struct {
Stamp uint32
Machinename string
Uid uint32
Gid uint32
GidLen uint32
Gids []uint32
}
func NewAuth(machineName string, uid, gid uint32) rpc.Auth {
func NewUnixAuth(machineName string, uid, gid uint32, gids []uint32) rpc.Auth {
w := new(bytes.Buffer)
xdr.Write(w, AuthUnix{
Stamp: rand.New(rand.NewSource(time.Now().UnixNano())).Uint32(),
Machinename: machineName,
Uid: uid,
Gid: gid,
GidLen: 1,
Uid: 1000,
Gid: 1000,
Gids: gids,
})
return rpc.Auth{
1,
1, // = AUTH_SYS in RFC5531
w.Bytes(),
}
}