diff --git a/pkg/cidata/template.go b/pkg/cidata/template.go index aedc5caaa3b..2a18ba43862 100644 --- a/pkg/cidata/template.go +++ b/pkg/cidata/template.go @@ -11,6 +11,7 @@ import ( "github.com/lima-vm/lima/pkg/iso9660util" "github.com/containerd/containerd/identifiers" + "github.com/lima-vm/lima/pkg/osutil" "github.com/lima-vm/lima/pkg/textutil" ) @@ -92,8 +93,8 @@ func ValidateTemplateArgs(args TemplateArgs) error { if err := identifiers.Validate(args.Name); err != nil { return err } - if err := identifiers.Validate(args.User); err != nil { - return err + if !osutil.ValidateUsername(args.User) { + return errors.New("field User must be valid linux username") } if args.User == "root" { return errors.New("field User must not be \"root\"")