mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add a new RPC ConnectWithCreds to allow gofer to connect to a unix domain socket with application's credentials
This commit is contained in:
@@ -452,11 +452,18 @@ func (d *dentry) allocate(ctx context.Context, mode, offset, length uint64) erro
|
||||
// - !d.isSynthetic().
|
||||
// - fs.renameMu is locked.
|
||||
func (d *dentry) connect(ctx context.Context, sockType linux.SockType) (int, error) {
|
||||
credentials := auth.CredentialsFromContextOrNil(ctx)
|
||||
euid := lisafs.NoUID
|
||||
egid := lisafs.NoGID
|
||||
if credentials != nil {
|
||||
euid = lisafs.UID(credentials.EffectiveKUID)
|
||||
egid = lisafs.GID(credentials.EffectiveKGID)
|
||||
}
|
||||
switch dt := d.impl.(type) {
|
||||
case *lisafsDentry:
|
||||
return dt.controlFD.Connect(ctx, sockType)
|
||||
return dt.controlFD.Connect(ctx, sockType, euid, egid)
|
||||
case *directfsDentry:
|
||||
return dt.connect(ctx, sockType)
|
||||
return dt.connect(ctx, sockType, euid, egid)
|
||||
default:
|
||||
panic("unknown dentry implementation")
|
||||
}
|
||||
|
||||
@@ -603,13 +603,13 @@ func (d *directfsDentry) getDirentsLocked(recordDirent func(name string, key ino
|
||||
}
|
||||
|
||||
// Precondition: fs.renameMu is locked.
|
||||
func (d *directfsDentry) connect(ctx context.Context, sockType linux.SockType) (int, error) {
|
||||
func (d *directfsDentry) connect(ctx context.Context, sockType linux.SockType, euid lisafs.UID, egid lisafs.GID) (int, error) {
|
||||
// There are no filesystems mounted in the sandbox process's mount namespace.
|
||||
// So we can't perform absolute path traversals. So fallback to using lisafs.
|
||||
if err := d.ensureLisafsControlFD(ctx); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return d.controlFDLisa.Connect(ctx, sockType)
|
||||
return d.controlFDLisa.Connect(ctx, sockType, euid, egid)
|
||||
}
|
||||
|
||||
func (d *directfsDentry) readlink() (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user