Skip to content

Commit 2ce5707

Browse files
committed
use osutil username regex validation in cidata.
this will make the validation consistent both for lima username fallback and then validation for cidata. Signed-off-by: pvdvreede <[email protected]>
1 parent 97582e0 commit 2ce5707

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: pkg/cidata/template.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/lima-vm/lima/pkg/iso9660util"
1212

1313
"github.com/containerd/containerd/identifiers"
14+
"github.com/lima-vm/lima/pkg/osutil"
1415
"github.com/lima-vm/lima/pkg/textutil"
1516
)
1617

@@ -92,8 +93,8 @@ func ValidateTemplateArgs(args TemplateArgs) error {
9293
if err := identifiers.Validate(args.Name); err != nil {
9394
return err
9495
}
95-
if err := identifiers.Validate(args.User); err != nil {
96-
return err
96+
if !osutil.ValidateUsername(args.User) {
97+
return errors.New("field User must be valid linux username")
9798
}
9899
if args.User == "root" {
99100
return errors.New("field User must not be \"root\"")

0 commit comments

Comments
 (0)