Skip to content

Commit

Permalink
use osutil username regex validation in cidata.
Browse files Browse the repository at this point in the history
this will make the validation consistent both for lima username fallback
and then validation for cidata.

Signed-off-by: pvdvreede <[email protected]>
  • Loading branch information
pvdvreede committed Oct 2, 2024
1 parent 97582e0 commit 2ce5707
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/cidata/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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\"")
Expand Down

0 comments on commit 2ce5707

Please sign in to comment.