Skip to content

Commit de460fd

Browse files
authored
Merge pull request #2664 from jandubois/verify-sudoers
Don't create insecure sudoers file
2 parents ac9bedd + b8d1f8f commit de460fd

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmd/limactl/sudoers.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ func sudoersAction(cmd *cobra.Command, args []string) error {
4646
if runtime.GOOS != "darwin" {
4747
return errors.New("sudoers command is only supported on macOS right now")
4848
}
49+
config, err := networks.Config()
50+
if err != nil {
51+
return err
52+
}
53+
// Make sure the current network configuration is secure
54+
if err := config.Validate(); err != nil {
55+
return err
56+
}
4957
check, err := cmd.Flags().GetBool("check")
5058
if err != nil {
5159
return err
5260
}
5361
if check {
54-
return verifySudoAccess(args)
62+
return verifySudoAccess(config, args)
5563
}
5664
switch len(args) {
5765
case 0:
@@ -69,14 +77,7 @@ func sudoersAction(cmd *cobra.Command, args []string) error {
6977
return nil
7078
}
7179

72-
func verifySudoAccess(args []string) error {
73-
config, err := networks.Config()
74-
if err != nil {
75-
return err
76-
}
77-
if err := config.Validate(); err != nil {
78-
return err
79-
}
80+
func verifySudoAccess(config networks.YAML, args []string) error {
8081
var file string
8182
switch len(args) {
8283
case 0:

0 commit comments

Comments
 (0)