Merge pull request #197 from fengwang666/non-root

qemu: Add credentials to qemu Cmd
This commit is contained in:
Fabiano Fidêncio 2021-08-17 13:06:15 +02:00 committed by GitHub
commit b681d61a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2439,6 +2439,13 @@ type Config struct {
// Ctx is the context used when launching qemu.
Ctx context.Context
// User ID.
Uid uint32
// Group ID.
Gid uint32
// Supplementary group IDs.
Groups []uint32
// Name is the qemu guest name
Name string
@ -2898,8 +2905,15 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
ctx = context.Background()
}
attr := syscall.SysProcAttr{}
attr.Credential = &syscall.Credential{
Uid: config.Uid,
Gid: config.Gid,
Groups: config.Groups,
}
return LaunchCustomQemu(ctx, config.Path, config.qemuParams,
config.fds, nil, logger)
config.fds, &attr, logger)
}
// LaunchCustomQemu can be used to launch a new qemu instance.