1 parent
9b5146bc57
commit
f6c935a4d7
1 file changed
+16
-7
@@ -145,20 +145,24 @@ func copyPluginFile(sourcePath, targetPath string, uid, gid int, mode os.FileMod
|
|||||||
_ = os.Remove(targetPath)
|
_ = os.Remove(targetPath)
|
||||||
return fmt.Errorf("copy plugin configuration: %w", err)
|
return fmt.Errorf("copy plugin configuration: %w", err)
|
||||||
}
|
}
|
||||||
if err := target.Close(); err != nil {
|
|
||||||
_ = os.Remove(targetPath)
|
|
||||||
return fmt.Errorf("close sandbox plugin configuration: %w", err)
|
|
||||||
}
|
|
||||||
if written > maxPluginConfigBytes {
|
if written > maxPluginConfigBytes {
|
||||||
_ = os.Remove(targetPath)
|
_ = os.Remove(targetPath)
|
||||||
return errors.New("plugin configuration exceeds the allowed size")
|
return errors.New("plugin configuration exceeds the allowed size")
|
||||||
}
|
}
|
||||||
if err := target.Chmod(mode); err != nil {
|
if err := target.Chmod(mode); err != nil {
|
||||||
|
_ = target.Close()
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
return fmt.Errorf("secure sandbox plugin configuration: %w", err)
|
return fmt.Errorf("secure sandbox plugin configuration: %w", err)
|
||||||
}
|
}
|
||||||
if err := target.Chown(uid, gid); err != nil {
|
if err := target.Chown(uid, gid); err != nil {
|
||||||
|
_ = target.Close()
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
return fmt.Errorf("assign sandbox plugin configuration identity: %w", err)
|
return fmt.Errorf("assign sandbox plugin configuration identity: %w", err)
|
||||||
}
|
}
|
||||||
|
if err := target.Close(); err != nil {
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
|
return fmt.Errorf("close sandbox plugin configuration: %w", err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,15 +223,20 @@ func copyPluginExecutable(sourcePath, targetPath string, uid, gid int) error {
|
|||||||
_ = target.Close()
|
_ = target.Close()
|
||||||
return fmt.Errorf("sync sandbox plugin executable: %w", err)
|
return fmt.Errorf("sync sandbox plugin executable: %w", err)
|
||||||
}
|
}
|
||||||
if err := target.Close(); err != nil {
|
|
||||||
return fmt.Errorf("close sandbox plugin executable: %w", err)
|
|
||||||
}
|
|
||||||
if err := target.Chmod(0700); err != nil {
|
if err := target.Chmod(0700); err != nil {
|
||||||
|
_ = target.Close()
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
return fmt.Errorf("secure sandbox plugin executable: %w", err)
|
return fmt.Errorf("secure sandbox plugin executable: %w", err)
|
||||||
}
|
}
|
||||||
if err := target.Chown(uid, gid); err != nil {
|
if err := target.Chown(uid, gid); err != nil {
|
||||||
|
_ = target.Close()
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
return fmt.Errorf("assign sandbox plugin identity: %w", err)
|
return fmt.Errorf("assign sandbox plugin identity: %w", err)
|
||||||
}
|
}
|
||||||
|
if err := target.Close(); err != nil {
|
||||||
|
_ = os.Remove(targetPath)
|
||||||
|
return fmt.Errorf("close sandbox plugin executable: %w", err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user