aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/system
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-17 12:17:01 +0900
committerOphestra <cat@gensokyo.uk>2025-02-17 12:17:01 +0900
commitdb71fbe22bea41e92b9a037a2b608a3350097f5f (patch)
tree4debfee554f483c7e73a6aad92f8301528e74a52 /internal/system
parent83e72c2b59e0d9de56279186ab10161df493a4cc (diff)
system/tmpfiles: fail gracefully in API misuse
Panicking here leaves garbage behind. Not ideal if this package is going to be exported. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system')
-rw-r--r--internal/system/tmpfiles.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/system/tmpfiles.go b/internal/system/tmpfiles.go
index 5a2307f4..5130f2e5 100644
--- a/internal/system/tmpfiles.go
+++ b/internal/system/tmpfiles.go
@@ -2,6 +2,7 @@ package system
import (
"bytes"
+ "errors"
"fmt"
"io"
"os"
@@ -35,6 +36,11 @@ func (t *Tmpfile) Type() Enablement { return Process }
func (t *Tmpfile) apply(_ *I) error {
fmsg.Verbose("copying", t)
+ if t.payload == nil {
+ // this is a misuse of the API; do not return an error message
+ return errors.New("invalid payload")
+ }
+
if b, err := os.Stat(t.src); err != nil {
return fmsg.WrapErrorSuffix(err,
fmt.Sprintf("cannot stat %q:", t.src))