Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/cmd/limactl/sudoers.go
1645 views
1
// SPDX-FileCopyrightText: Copyright The Lima Authors
2
// SPDX-License-Identifier: Apache-2.0
3
4
package main
5
6
import (
7
"fmt"
8
9
"github.com/spf13/cobra"
10
11
"github.com/lima-vm/lima/v2/pkg/networks"
12
)
13
14
const socketVMNetURL = "https://lima-vm.io/docs/config/network/vmnet/#socket_vmnet"
15
16
// newSudoersCommand is specific to macOS, but the help message is
17
// compiled on Linux too, as depended by `make docsy`.
18
// https://github.com/lima-vm/lima/issues/3436
19
func newSudoersCommand() *cobra.Command {
20
sudoersCommand := &cobra.Command{
21
Use: "sudoers [--check [SUDOERSFILE-TO-CHECK]]",
22
Example: `
23
To generate the /etc/sudoers.d/lima file:
24
$ limactl sudoers | sudo tee /etc/sudoers.d/lima
25
26
To validate the existing /etc/sudoers.d/lima file:
27
$ limactl sudoers --check /etc/sudoers.d/lima
28
`,
29
Short: "Generate the content of the /etc/sudoers.d/lima file",
30
Long: fmt.Sprintf(`Generate the content of the /etc/sudoers.d/lima file for enabling vmnet.framework support (socket_vmnet) on macOS.
31
The content is written to stdout, NOT to the file.
32
This command must not run as the root user.
33
See %s for the usage.`, socketVMNetURL),
34
Args: WrapArgsError(cobra.MaximumNArgs(1)),
35
RunE: sudoersAction,
36
GroupID: advancedCommand,
37
}
38
cfgFile, _ := networks.ConfigFile()
39
sudoersCommand.Flags().Bool("check", false,
40
fmt.Sprintf("check that the sudoers file is up-to-date with %q", cfgFile))
41
return sudoersCommand
42
}
43
44