mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
plugins: install should not automatically accept all permissions
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 4b70d4561e
)
This commit is contained in:
parent
a7c925cba4
commit
f24e5d79bc
2 changed files with 8 additions and 7 deletions
|
@ -25,7 +25,7 @@ type pluginOptions struct {
|
||||||
func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
var options pluginOptions
|
var options pluginOptions
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "install",
|
Use: "install PLUGIN",
|
||||||
Short: "Install a plugin",
|
Short: "Install a plugin",
|
||||||
Args: cli.RequiresMinArgs(1), // TODO: allow for set args
|
Args: cli.RequiresMinArgs(1), // TODO: allow for set args
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -35,7 +35,7 @@ func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.BoolVar(&options.grantPerms, "grant-all-permissions", true, "grant all permissions necessary to run the plugin")
|
flags.BoolVar(&options.grantPerms, "grant-all-permissions", false, "grant all permissions necessary to run the plugin")
|
||||||
flags.BoolVar(&options.disable, "disable", false, "do not enable the plugin on install")
|
flags.BoolVar(&options.disable, "disable", false, "do not enable the plugin on install")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
@ -62,14 +62,15 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "plugin install")
|
registryAuthFunc := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "plugin install")
|
||||||
|
|
||||||
options := types.PluginInstallOptions{
|
options := types.PluginInstallOptions{
|
||||||
RegistryAuth: encodedAuth,
|
RegistryAuth: encodedAuth,
|
||||||
Disabled: opts.disable,
|
Disabled: opts.disable,
|
||||||
AcceptAllPermissions: opts.grantPerms,
|
AcceptAllPermissions: opts.grantPerms,
|
||||||
AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.name),
|
AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.name),
|
||||||
PrivilegeFunc: requestPrivilege,
|
// TODO: Rename PrivilegeFunc, it has nothing to do with privileges
|
||||||
|
PrivilegeFunc: registryAuthFunc,
|
||||||
}
|
}
|
||||||
|
|
||||||
return dockerCli.Client().PluginInstall(ctx, ref.String(), options)
|
return dockerCli.Client().PluginInstall(ctx, ref.String(), options)
|
||||||
|
@ -77,7 +78,7 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
|
||||||
|
|
||||||
func acceptPrivileges(dockerCli *client.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) {
|
func acceptPrivileges(dockerCli *client.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) {
|
||||||
return func(privileges types.PluginPrivileges) (bool, error) {
|
return func(privileges types.PluginPrivileges) (bool, error) {
|
||||||
fmt.Fprintf(dockerCli.Out(), "Plugin %q requested the following privileges:\n", name)
|
fmt.Fprintf(dockerCli.Out(), "Plugin %q is requesting the following privileges:\n", name)
|
||||||
for _, privilege := range privileges {
|
for _, privilege := range privileges {
|
||||||
fmt.Fprintf(dockerCli.Out(), " - %s: %v\n", privilege.Name, privilege.Value)
|
fmt.Fprintf(dockerCli.Out(), " - %s: %v\n", privilege.Name, privilege.Value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
||||||
tag := "latest"
|
tag := "latest"
|
||||||
nameWithTag := name + ":" + tag
|
nameWithTag := name + ":" + tag
|
||||||
|
|
||||||
_, _, err := dockerCmdWithError("plugin", "install", name)
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", name)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||||
|
@ -41,7 +41,7 @@ func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
||||||
tag := "latest"
|
tag := "latest"
|
||||||
nameWithTag := name + ":" + tag
|
nameWithTag := name + ":" + tag
|
||||||
|
|
||||||
_, _, err := dockerCmdWithError("plugin", "install", name, "--disable")
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", name)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||||
|
|
Loading…
Add table
Reference in a new issue