Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package opentofu for openSUSE:Factory checked in at 2026-12-02 17:05:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/opentofu (Old) and /work/SRC/openSUSE:Factory/.opentofu.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "opentofu" Wed Dec 2 17:05:58 2026 rev:60 rq:1402262 version:1.13.11 Changes: -------- --- /work/SRC/openSUSE:Factory/opentofu/opentofu.changes 2026-11-24 12:47:21.743663417 +0100 +++ /work/SRC/openSUSE:Factory/.opentofu.new.1340718/opentofu.changes 2026-12-02 17:08:42.732074099 +0100 @@ -1,0 +2,23 @@ +Wed Dec 02 06:03:04 UTC 2026 - Johannes Kastl <[email protected]> + +- Update to version 1.13.11: + * SECURITY ADVISORIES: + - ssh connection for provisioners now uses bastion_host_key + correctly instead of using the host_key as it did before. + (#4885) + - This change can be considered also a breaking change for + those that use host_key and bastion configurations. Before + this change host_key was used instead of bastion_host_key. + If you are in a situation like that, you need to add the + bastion_host_key configuration pointing to the same value + as host_key. + * BUG FIXES: + - Downloading metadata of a provider from a network mirror now + bounds the read bytes based on the received Content-Length + header (#4881) + - Interruption during backend configuration prompt now is + handled correctly. (#4755) + - Fix regression in provider configuration parallelization. + (#4877) + +------------------------------------------------------------------- Old: ---- opentofu-1.13.10.obscpio New: ---- opentofu-1.13.11.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ opentofu.spec ++++++ --- /var/tmp/diff_new_pack.OuTZ8m/_old 2026-12-02 17:08:44.562151541 +0100 +++ /var/tmp/diff_new_pack.OuTZ8m/_new 2026-12-02 17:08:44.564151626 +0100 @@ -19,7 +19,7 @@ %define executable_name tofu Name: opentofu -Version: 1.13.10 +Version: 1.13.11 Release: 0 Summary: Declaratively manage your cloud infrastructure License: MPL-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.OuTZ8m/_old 2026-12-02 17:08:44.593152853 +0100 +++ /var/tmp/diff_new_pack.OuTZ8m/_new 2026-12-02 17:08:44.595152938 +0100 @@ -3,7 +3,7 @@ <param name="url">https://github.com/opentofu/opentofu.git</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">refs/tags/v1.13.10</param> + <param name="revision">refs/tags/v1.13.11</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.OuTZ8m/_old 2026-12-02 17:08:44.614153742 +0100 +++ /var/tmp/diff_new_pack.OuTZ8m/_new 2026-12-02 17:08:44.617153869 +0100 @@ -3,6 +3,6 @@ <param name="url">https://github.com/opentofu/opentofu/</param> <param name="changesrevision">bdcbf091aab886499ed7718d7f558b428fffce39</param></service><service name="tar_scm"> <param name="url">https://github.com/opentofu/opentofu.git</param> - <param name="changesrevision">4dcfb2efaaf7d3e95a92d1c10b7fd000e82bc51f</param></service></servicedata> + <param name="changesrevision">6658f545663281227105d6de888dacedc2010bd2</param></service></servicedata> (No newline at EOF) ++++++ opentofu-1.13.10.obscpio -> opentofu-1.13.11.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/CHANGELOG.md new/opentofu-1.13.11/CHANGELOG.md --- old/opentofu-1.13.10/CHANGELOG.md 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/CHANGELOG.md 2026-11-30 15:46:26.000000000 +0100 @@ -1,6 +1,19 @@ The v1.13.x release series is supported until **August 1 2027**. -## 1.13.11 (Unreleased) +## 1.13.12 (Unreleased) + +## 1.13.11 + +SECURITY ADVISORIES: + +- `ssh` connection for provisioners now uses `bastion_host_key` correctly instead of using the `host_key` as it did before. ([#4885](https://github.com/opentofu/opentofu/pull/4885)) + - :exclamation: This change can be considered also a breaking change for those that use `host_key` and bastion configurations. Before this change `host_key` was used instead of `bastion_host_key`. If you are in a situation like that, you need to add the `bastion_host_key` configuration pointing to the same value as `host_key`. + +BUG FIXES: + +- Downloading metadata of a provider from a network mirror now bounds the read bytes based on the received `Content-Length` header ([#4881](https://github.com/opentofu/opentofu/pull/4881)) +- Interruption during backend configuration prompt now is handled correctly. ([#4755](https://github.com/opentofu/opentofu/pull/4755)) +- Fix regression in provider configuration parallelization. ([#4877](https://github.com/opentofu/opentofu/pull/4877)) ## 1.13.10 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/apply.go new/opentofu-1.13.11/internal/command/apply.go --- old/opentofu-1.13.10/internal/command/apply.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/apply.go 2026-11-30 15:46:26.000000000 +0100 @@ -78,6 +78,10 @@ func (c ApplyCommand) Execute(args *arguments.Apply, view views.Apply) int { var diags tfdiags.Diagnostics ctx := c.CommandContext() + // This is safe to be done since the execution engine contexts are created by ignoring the cancellation from the parent context. + // internal/backend/local/backend.go + ctx, cancel := c.InterruptibleContext(ctx) + defer cancel() ctx = tfdiags.ContextWithLintFilterHints(ctx, args.View.LintInclude, args.View.LintExclude) diags = diags.Append(tfdiags.ExperimentalLintWarn(ctx)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/apply_test.go new/opentofu-1.13.11/internal/command/apply_test.go --- old/opentofu-1.13.10/internal/command/apply_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/apply_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -313,7 +313,7 @@ // calls until we reach the desired concurrency. The cancel func "begin" is // called once we reach the desired concurrency, allowing all apply calls // to proceed in unison. - beginCtx, begin := context.WithCancel(context.Background()) + beginCtx, begin := context.WithCancel(t.Context()) // Ensure cancel is fired regardless of test defer begin() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/clistate/state_test.go new/opentofu-1.13.11/internal/command/clistate/state_test.go --- old/opentofu-1.13.10/internal/command/clistate/state_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/clistate/state_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -37,7 +37,7 @@ view := views.NewView(streams) // Create a context that is already cancelled (simulates Ctrl+C) - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) cancel() backendView := views.NewBackendHuman(view) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/login.go new/opentofu-1.13.11/internal/command/login.go --- old/opentofu-1.13.10/internal/command/login.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/login.go 2026-11-30 15:46:26.000000000 +0100 @@ -78,8 +78,10 @@ var diags tfdiags.Diagnostics ctx := c.CommandContext() + ctx, cancel := c.InterruptibleContext(ctx) ctx, span := tracing.Tracer().Start(ctx, "Login") defer span.End() + defer cancel() if !c.input { diags = diags.Append(tfdiags.Sourceless( @@ -534,6 +536,20 @@ wg.Wait() close(codeCh) return nil, diags + case <-ctx.Done(): + diags = diags.Append( + tfdiags.Sourceless( + tfdiags.Error, + "Action aborted", + "Current command was aborted", + ), + ) + if err := server.Shutdown(ctx); err != nil { + log.Printf("[WARN] login: callback server shutdown failed: %s", err) + } + wg.Wait() + close(codeCh) + return nil, diags case code = <-codeCh: } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/login_test.go new/opentofu-1.13.11/internal/command/login_test.go --- old/opentofu-1.13.10/internal/command/login_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/login_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -7,9 +7,12 @@ import ( "context" + "io" "net/http/httptest" + "os" "path/filepath" "strings" + "sync" "testing" "time" @@ -364,6 +367,51 @@ t.Fatalf("missing expected error message\nwant: %s\nfull output:\n%s", want, got) } }, false)) + + t.Run("cancel input during login confirmation", loginTestCase(func(t *testing.T, c *LoginCommand, closeView func(*testing.T) *terminal.TestOutput) { + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + defer cancel() + + // make suer that the actual call will use the cancellable context + prefCtx := c.CallerContext + c.CallerContext = ctx + defer func() { c.CallerContext = prefCtx }() + // defer func() { abortCh <- struct{}{} }() + + // create a pipe that is idle + rx, tx := io.Pipe() + + // cancel the context right before you start reading + var once sync.Once + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, + } + + // and force the code to use it so it hangs on input for address + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + out := c.Run([]string{"example.com"}) + loginOutput := closeView(t).All() + + if out != 1 { + t.Fatalf("error code and stdout dont match expected test: %d %s", out, loginOutput) + + } + if !strings.Contains(loginOutput, "interrupted: context canceled") { + t.Fatalf("an error occured but not the one I expected %s", loginOutput) + } + }, false)) + } // TestLoginOAuthCallbackRace verifies that no panic, deadlock, or data race diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta.go new/opentofu-1.13.11/internal/command/meta.go --- old/opentofu-1.13.10/internal/command/meta.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta.go 2026-11-30 15:46:26.000000000 +0100 @@ -432,13 +432,13 @@ } // confirm asks a yes/no confirmation. -func (m *Meta) confirm(opts *tofu.InputOpts) (bool, error) { +func (m *Meta) confirm(ctx context.Context, opts *tofu.InputOpts) (bool, error) { if !m.Input() { return false, errors.New("input is disabled") } for range 2 { - v, err := m.UIInput().Input(context.Background(), opts) + v, err := m.UIInput().Input(ctx, opts) if err != nil { return false, fmt.Errorf( "Error asking for confirmation: %w", err) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta_backend.go new/opentofu-1.13.11/internal/command/meta_backend.go --- old/opentofu-1.13.10/internal/command/meta_backend.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta_backend.go 2026-11-30 15:46:26.000000000 +0100 @@ -243,7 +243,7 @@ // len is always 1 if using Name; 0 means we're using Tags and there // aren't any matching workspaces. Which might be normal and fine, so // let's just ask: - name, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{ + name, err := m.UIInput().Input(ctx, &tofu.InputOpts{ Id: "create-workspace", Query: "\n[reset][bold][yellow]No workspaces found.[reset]", Description: fmt.Sprintf(inputCloudInitCreateWorkspace, strings.Join(c.WorkspaceMapping.Tags, ", ")), @@ -290,7 +290,7 @@ } // Otherwise, ask the user to select a workspace from the list of existing workspaces. - v, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{ + v, err := m.UIInput().Input(ctx, &tofu.InputOpts{ Id: "select-workspace", Query: fmt.Sprintf( "\n[reset][bold][yellow]The currently selected workspace (%s) does not exist.[reset]", @@ -1422,7 +1422,7 @@ // TODO: test if m.Input() { var err error - configVal, err = m.inputForSchema(configVal, schema, view) + configVal, err = m.inputForSchema(ctx, configVal, schema, view) if err != nil { diags = diags.Append(fmt.Errorf("Error asking for input to configure backend %q: %w", canonType, err)) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta_backend_migrate.go new/opentofu-1.13.11/internal/command/meta_backend_migrate.go --- old/opentofu-1.13.10/internal/command/meta_backend_migrate.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta_backend_migrate.go 2026-11-30 15:46:26.000000000 +0100 @@ -175,7 +175,7 @@ if !migrate { var err error // Ask the user if they want to migrate their existing remote state - migrate, err = m.confirm(&tofu.InputOpts{ + migrate, err = m.confirm(ctx, &tofu.InputOpts{ Id: "backend-migrate-multistate-to-multistate", Query: fmt.Sprintf( "Do you want to migrate all workspaces to %q?", @@ -235,7 +235,7 @@ if !migrate { var err error // Ask the user if they want to migrate their existing remote state - migrate, err = m.confirm(&tofu.InputOpts{ + migrate, err = m.confirm(ctx, &tofu.InputOpts{ Id: "backend-migrate-multistate-to-single", Query: fmt.Sprintf( "Destination state %q doesn't support workspaces.\n"+ @@ -292,7 +292,7 @@ // for a new name and migrate the default state to the given named state. destinationState, err = func() (statemgr.Full, error) { log.Print("[TRACE] backendMigrateState: destination doesn't support a default workspace, so we must prompt for a new name") - name, err := m.promptNewWorkspaceName(opts.DestinationType) + name, err := m.promptNewWorkspaceName(ctx, opts.DestinationType) if err != nil { return nil, err } @@ -384,7 +384,7 @@ destination = destinationState.State() } - var confirmFunc func(statemgr.Full, statemgr.Full, *backendMigrateOpts) (bool, error) + var confirmFunc func(context.Context, statemgr.Full, statemgr.Full, *backendMigrateOpts) (bool, error) switch { // No migration necessary case source.Empty() && destination.Empty(): @@ -404,7 +404,7 @@ // whether to migrate state in the cloud case, so we'll skip // this later prompt for Cloud, even though we do still need it // for state backends. - confirmFunc = func(statemgr.Full, statemgr.Full, *backendMigrateOpts) (bool, error) { + confirmFunc = func(context.Context, statemgr.Full, statemgr.Full, *backendMigrateOpts) (bool, error) { return true, nil // the answer is implied to be "yes" if we reached this point } } else { @@ -431,7 +431,7 @@ } // Confirm with the user whether we want to copy state over - confirm, err := confirmFunc(sourceState, destinationState, opts) + confirm, err := confirmFunc(ctx, sourceState, destinationState, opts) if err != nil { log.Print("[TRACE] backendMigrateState: error reading input, so aborting migration") return err @@ -463,7 +463,7 @@ return nil } -func (m *Meta) backendMigrateEmptyConfirm(source, destination statemgr.Full, opts *backendMigrateOpts) (bool, error) { +func (m *Meta) backendMigrateEmptyConfirm(ctx context.Context, source, destination statemgr.Full, opts *backendMigrateOpts) (bool, error) { var inputOpts *tofu.InputOpts if opts.DestinationType == "cloud" { inputOpts = &tofu.InputOpts{ @@ -481,11 +481,11 @@ } } - return m.confirm(inputOpts) + return m.confirm(ctx, inputOpts) } func (m *Meta) backendMigrateNonEmptyConfirm( - sourceState, destinationState statemgr.Full, opts *backendMigrateOpts) (bool, error) { + ctx context.Context, sourceState, destinationState statemgr.Full, opts *backendMigrateOpts) (bool, error) { // We need to grab both states so we can write them to a file source := sourceState.State() destination := destinationState.State() @@ -533,7 +533,7 @@ } // Confirm with the user that the copy should occur - return m.confirm(inputOpts) + return m.confirm(ctx, inputOpts) } func retrieveWorkspaces(ctx context.Context, back backend.Backend, sourceType string) ([]string, bool, error) { @@ -617,7 +617,7 @@ // We do prompt first though, because state migration is mandatory // for moving to Cloud and the user should get an opportunity to // confirm that first. - if migrate, err := m.promptSingleToCloudSingleStateMigration(opts); err != nil { + if migrate, err := m.promptSingleToCloudSingleStateMigration(ctx, opts); err != nil { return err } else if !migrate { return nil // skip migrating but return successfully @@ -638,7 +638,7 @@ opts.sourceWorkspace = currentWorkspace opts.destinationWorkspace = cloudBackendDestination.WorkspaceMapping.Name - if err := m.promptMultiToSingleCloudMigration(opts); err != nil { + if err := m.promptMultiToSingleCloudMigration(ctx, opts); err != nil { return err } @@ -694,7 +694,7 @@ errMigrateSingleLoadDefault), opts.SourceType, err) } if !sourceState.State().Empty() { - newName, err := m.promptNewWorkspaceName(opts.DestinationType) + newName, err := m.promptNewWorkspaceName(ctx, opts.DestinationType) if err != nil { return err } @@ -716,7 +716,7 @@ // how things already are in Terraform Cloud with no user intervention needed. pattern := "" if remoteBackend, ok := opts.Source.(*remote.Remote); ok { - if err := m.promptRemotePrefixToCloudTagsMigration(opts); err != nil { + if err := m.promptRemotePrefixToCloudTagsMigration(ctx, opts); err != nil { return err } pattern = remoteBackend.WorkspaceNamePattern() @@ -724,7 +724,7 @@ } if pattern == "" { - pattern, err = m.promptMultiStateMigrationPattern(opts.SourceType) + pattern, err = m.promptMultiStateMigrationPattern(ctx, opts.SourceType) if err != nil { return err } @@ -792,7 +792,7 @@ return nil } -func (m *Meta) promptSingleToCloudSingleStateMigration(opts *backendMigrateOpts) (bool, error) { +func (m *Meta) promptSingleToCloudSingleStateMigration(ctx context.Context, opts *backendMigrateOpts) (bool, error) { if !m.input { log.Print("[TRACE] backendMigrateState: can't prompt for input, so aborting migration") return false, errors.New(strings.TrimSpace(errInteractiveInputDisabled)) @@ -800,7 +800,7 @@ migrate := opts.force if !migrate { var err error - migrate, err = m.confirm(&tofu.InputOpts{ + migrate, err = m.confirm(ctx, &tofu.InputOpts{ Id: "backend-migrate-state-single-to-cloud-single", Query: "Do you wish to proceed?", Description: strings.TrimSpace(tfcInputBackendMigrateStateSingleToCloudSingle), @@ -813,7 +813,7 @@ return migrate, nil } -func (m *Meta) promptRemotePrefixToCloudTagsMigration(opts *backendMigrateOpts) error { +func (m *Meta) promptRemotePrefixToCloudTagsMigration(ctx context.Context, opts *backendMigrateOpts) error { if !m.input { log.Print("[TRACE] backendMigrateState: can't prompt for input, so aborting migration") return errors.New(strings.TrimSpace(errInteractiveInputDisabled)) @@ -821,7 +821,7 @@ migrate := opts.force if !migrate { var err error - migrate, err = m.confirm(&tofu.InputOpts{ + migrate, err = m.confirm(ctx, &tofu.InputOpts{ Id: "backend-migrate-remote-multistate-to-cloud", Query: "Do you wish to proceed?", Description: strings.TrimSpace(tfcInputBackendMigrateRemoteMultiToCloud), @@ -839,7 +839,7 @@ } // Multi-state to single state. -func (m *Meta) promptMultiToSingleCloudMigration(opts *backendMigrateOpts) error { +func (m *Meta) promptMultiToSingleCloudMigration(ctx context.Context, opts *backendMigrateOpts) error { if !m.input { log.Print("[TRACE] backendMigrateState: can't prompt for input, so aborting migration") return errors.New(strings.TrimSpace(errInteractiveInputDisabled)) @@ -848,7 +848,7 @@ if !migrate { var err error // Ask the user if they want to migrate their existing remote state - migrate, err = m.confirm(&tofu.InputOpts{ + migrate, err = m.confirm(ctx, &tofu.InputOpts{ Id: "backend-migrate-multistate-to-single", Query: "Do you want to copy only your current workspace?", Description: fmt.Sprintf( @@ -867,7 +867,7 @@ return nil } -func (m *Meta) promptNewWorkspaceName(destinationType string) (string, error) { +func (m *Meta) promptNewWorkspaceName(ctx context.Context, destinationType string) (string, error) { message := fmt.Sprintf("[reset][bold][yellow]The %q backend configuration only allows "+ "named workspaces![reset]", destinationType) if destinationType == "cloud" { @@ -877,7 +877,8 @@ } message = `[reset][bold][yellow]Cloud backend requires all workspaces to be given an explicit name.[reset]` } - name, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{ + + name, err := m.UIInput().Input(ctx, &tofu.InputOpts{ Id: "new-state-name", Query: message, Description: strings.TrimSpace(inputBackendNewWorkspaceName), @@ -889,10 +890,10 @@ return name, nil } -func (m *Meta) promptMultiStateMigrationPattern(sourceType string) (string, error) { +func (m *Meta) promptMultiStateMigrationPattern(ctx context.Context, sourceType string) (string, error) { // This is not the first prompt a user would be presented with in the migration to TFC, so no // guard on m.input is needed here. - renameWorkspaces, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{ + renameWorkspaces, err := m.UIInput().Input(ctx, &tofu.InputOpts{ Id: "backend-migrate-multistate-to-tfc", Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "Would you like to rename your workspaces?"), Description: fmt.Sprintf(strings.TrimSpace(tfcInputBackendMigrateMultiToMulti), sourceType), @@ -910,7 +911,7 @@ return "*", nil } - pattern, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{ + pattern, err := m.UIInput().Input(ctx, &tofu.InputOpts{ Id: "backend-migrate-multistate-to-tfc-pattern", Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "How would you like to rename your workspaces?"), Description: strings.TrimSpace(tfcInputBackendMigrateMultiToMultiPattern), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta_backend_migrate_test.go new/opentofu-1.13.11/internal/command/meta_backend_migrate_test.go --- old/opentofu-1.13.10/internal/command/meta_backend_migrate_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta_backend_migrate_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -6,6 +6,11 @@ package command import ( + "context" + "io" + "os" + "strings" + "sync" "testing" ) @@ -41,26 +46,75 @@ }, } for name, tc := range cases { - t.Log("Test: ", name) - m := testMetaBackend(t) - input := map[string]string{} - cleanup := testInputMap(t, input) - if tc.renamePrompt != "" { - input["backend-migrate-multistate-to-tfc"] = tc.renamePrompt - } - if tc.patternPrompt != "" { - input["backend-migrate-multistate-to-tfc-pattern"] = tc.patternPrompt - } - - sourceType := "cloud" - _, err := m.promptMultiStateMigrationPattern(sourceType) - if tc.expectedErr == "" && err != nil { - t.Fatalf("expected error to be nil, but was %s", err.Error()) - } - if tc.expectedErr != "" && tc.expectedErr != err.Error() { - t.Fatalf("expected error to eq %s but got %s", tc.expectedErr, err.Error()) - } + t.Run(name, func(t *testing.T) { + t.Log("Test: ", name) + m := testMetaBackend(t) + input := map[string]string{} + cleanup := testInputMap(t, input) + if tc.renamePrompt != "" { + input["backend-migrate-multistate-to-tfc"] = tc.renamePrompt + } + if tc.patternPrompt != "" { + input["backend-migrate-multistate-to-tfc-pattern"] = tc.patternPrompt + } - cleanup() + sourceType := "cloud" + _, err := m.promptMultiStateMigrationPattern(t.Context(), sourceType) + if tc.expectedErr == "" && err != nil { + t.Fatalf("expected error to be nil, but was %s", err.Error()) + } + if tc.expectedErr != "" && tc.expectedErr != err.Error() { + t.Fatalf("expected error to eq %s but got %s", tc.expectedErr, err.Error()) + } + + cleanup() + }) + } +} + +func TestBackendMigrate_cancelDuringInputReading(t *testing.T) { + m := testMetaBackend(t) + + // force it to run like a "real" tofu command + test = false + defer func() { test = true }() + + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + + // make suer that the actual call will use the cancellable context + m.CallerContext = ctx + + // create a pipe that is idle + rx, tx := io.Pipe() + + // cancel the context right before you start reading + var once sync.Once + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, } + + // and force the code to use it so it hangs on input for address + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + sourceType := "cloud" + _, err := m.promptMultiStateMigrationPattern(ctx, sourceType) + + if err == nil { + t.Fatal("expected an err to occur") + } + + if !strings.Contains(err.Error(), "interrupted: context canceled") { + t.Fatalf("error was not the one I expected to have, %s", err) + } + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta_backend_test.go new/opentofu-1.13.11/internal/command/meta_backend_test.go --- old/opentofu-1.13.10/internal/command/meta_backend_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta_backend_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -7,12 +7,14 @@ import ( "context" + "io" "os" "path/filepath" "reflect" "runtime" "sort" "strings" + "sync" "testing" "github.com/hashicorp/hcl/v2" @@ -25,6 +27,7 @@ "github.com/opentofu/opentofu/internal/backend" "github.com/opentofu/opentofu/internal/configs" "github.com/opentofu/opentofu/internal/configs/configschema" + "github.com/opentofu/opentofu/internal/copy" "github.com/opentofu/opentofu/internal/encryption" "github.com/opentofu/opentofu/internal/plans" @@ -2097,6 +2100,79 @@ } } +// notifyReader is a wrapper for io.Reader that once it detects a read it cancels the context +// via the r.cancel func, it does it once to not cancel the func twice +type notifyReader struct { + io.Reader + once *sync.Once + cancel context.CancelFunc +} + +// Read is the implementation of the reader interface +func (r *notifyReader) Read(p []byte) (int, error) { + // cancels the context that is attacehd to this struct once + r.once.Do(func() { r.cancel() }) + return r.Reader.Read(p) +} + +func TestMetaBackend_cancelOnNoInput(t *testing.T) { + // Create a temporary working directory that is empty + td := t.TempDir() + testCopyDir(t, testFixturePath("init-backend-http"), td) + t.Chdir(td) + + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + + // force it to run like a "real" tofu command + test = false + defer func() { test = true }() + + // init the backend and force it to wait for keyboard input + m := testMetaBackend(t) + m.input = true + + // make suer that the actual call will use the cancellable context + m.CallerContext = ctx + + // create a pipe that is idle + rx, tx := io.Pipe() + var once sync.Once + + // and force the code to use it so it hangs on input for address + // cancel the context right before you start reading + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, + } + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + opts := &BackendOpts{ + Init: true, + } + + // create the backend + _, diags := m.Backend(ctx, opts, encryption.StateEncryptionDisabled()) + + // find the error that shows it + if !diags.HasErrors() { + t.Fatal("expected there to be errors, none found") + } + err := diags.Err().Error() + + if !strings.Contains(err, "interrupted: context canceled") { + t.Fatalf("error was not the one I expected to have, %s", err) + } +} + // no config; return inmem backend stored in state func TestBackendFromState(t *testing.T) { wd := tempWorkingDirFixture(t, "backend-from-state") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/meta_config.go new/opentofu-1.13.11/internal/command/meta_config.go --- old/opentofu-1.13.10/internal/command/meta_config.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/meta_config.go 2026-11-30 15:46:26.000000000 +0100 @@ -123,7 +123,7 @@ if variable.Required() { // User prompts are best efforts, so we accept the input here // and rely on downstream checks to validate it - rawVal, err := m.getInput(context.Background(), variable) + rawVal, err := m.getInput(ctx, variable) if err != nil { return cty.NilVal, hcl.Diagnostics{&hcl.Diagnostic{ Severity: hcl.DiagError, @@ -349,7 +349,7 @@ // // The given value must conform to the given schema. If not, this method will // panic. -func (m *Meta) inputForSchema(given cty.Value, schema *configschema.Block, view views.Basic) (cty.Value, error) { +func (m *Meta) inputForSchema(ctx context.Context, given cty.Value, schema *configschema.Block, view views.Basic) (cty.Value, error) { if given.IsNull() || !given.IsKnown() { // This is not reasonable input, but we'll tolerate it anyway and // just pass it through for the caller to handle downstream. @@ -370,7 +370,7 @@ attrS := schema.Attributes[name] for { - strVal, err := input.Input(context.Background(), &tofu.InputOpts{ + strVal, err := input.Input(ctx, &tofu.InputOpts{ Id: name, Query: name, Description: attrS.Description, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/plan.go new/opentofu-1.13.11/internal/command/plan.go --- old/opentofu-1.13.10/internal/command/plan.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/plan.go 2026-11-30 15:46:26.000000000 +0100 @@ -49,6 +49,10 @@ func (c PlanCommand) Execute(args *arguments.Plan, view views.Plan) int { var diags tfdiags.Diagnostics ctx := c.CommandContext() + // This is safe to be done since the execution engine contexts are created by ignoring the cancellation from the parent context. + // internal/backend/local/backend.go + ctx, cancel := c.InterruptibleContext(ctx) + defer cancel() ctx = tfdiags.ContextWithLintFilterHints(ctx, args.View.LintInclude, args.View.LintExclude) diags = diags.Append(tfdiags.ExperimentalLintWarn(ctx)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/plan_test.go new/opentofu-1.13.11/internal/command/plan_test.go --- old/opentofu-1.13.10/internal/command/plan_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/plan_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -9,6 +9,8 @@ "bytes" "context" "fmt" + "io" + "log" "os" "path" "path/filepath" @@ -57,6 +59,67 @@ t.Fatalf("bad: %d\n\n%s", code, output.Stderr()) } } + +func TestPlan_cancelNoInput(t *testing.T) { + td := t.TempDir() + testCopyDir(t, testFixturePath("apply-input"), td) + t.Chdir(td) + + var logBuf bytes.Buffer + saved := log.Writer() + log.SetOutput(&logBuf) + defer log.SetOutput(saved) + + p := planFixtureProvider() + view, done := testView(t) + + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + + // force it to run like a "real" tofu command + test = false + defer func() { test = true }() + + meta := Meta{ + WorkingDir: workdir.NewDir("."), + testingOverrides: metaOverridesForProvider(p), + View: view, + input: true, + CallerContext: ctx, + } + + // create a pipe that is idle + rx, tx := io.Pipe() + var once sync.Once + + // and force the code to use it so it hangs on input for address + // cancel the context right before you start reading + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, + } + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + args := []string{} + code := RunCommander(t, PlanCommander(), meta, args) + output := done(t).Stderr() + if code != 1 { + t.Fatalf("bad status code: %d\n\n%s", code, output) + } + + if !strings.Contains(logBuf.String(), "interrupted: context canceled") { + t.Fatalf("error was not the one I expected to have, %s", output) + } +} + func TestPlan_conditionalSensitive(t *testing.T) { td := t.TempDir() testCopyDir(t, testFixturePath("apply-plan-conditional-sensitive"), td) @@ -1830,7 +1893,7 @@ // calls until we reach the desired concurrency. The cancel func "begin" is // called once we reach the desired concurrency, allowing all apply calls // to proceed in unison. - beginCtx, begin := context.WithCancel(context.Background()) + beginCtx, begin := context.WithCancel(t.Context()) // Ensure cancel is fired regardless of test defer begin() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/state_replace_provider.go new/opentofu-1.13.11/internal/command/state_replace_provider.go --- old/opentofu-1.13.10/internal/command/state_replace_provider.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/state_replace_provider.go 2026-11-30 15:46:26.000000000 +0100 @@ -52,6 +52,11 @@ ctx := c.CommandContext() + // This is safe to be done since the execution engine contexts are created by ignoring the cancellation from the parent context. + // internal/backend/local/backend.go + ctx, cancel := c.InterruptibleContext(ctx) + defer cancel() + if diags := c.Meta.checkRequiredVersion(ctx); diags != nil { view.Diagnostics(diags) return 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/state_replace_provider_test.go new/opentofu-1.13.11/internal/command/state_replace_provider_test.go --- old/opentofu-1.13.10/internal/command/state_replace_provider_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/state_replace_provider_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -6,8 +6,12 @@ package command import ( + "context" + "io" + "os" "path/filepath" "strings" + "sync" "testing" "github.com/opentofu/opentofu/internal/command/workdir" @@ -175,11 +179,14 @@ WorkingDir: workdir.NewDir("."), View: view, } + defer testInputMap(t, map[string]string{ + "confirm": "no", + })() args := []string{ "-state", statePath, - "hashicorp/google", - "acmecorp/google", + "hashicorp/aws", + "acmecorp/aws", } code := RunCommander(t, StateReplaceProviderCommander(), meta, args) output := done(t) @@ -195,6 +202,60 @@ } }) + t.Run("cancel input at approval step", func(t *testing.T) { + statePath := testStateFile(t, state) + + view, done := testView(t) + + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + + meta := Meta{ + WorkingDir: workdir.NewDir("."), + View: view, + + // make suer that the actual call will use the cancellable context + CallerContext: ctx, + } + + // create a pipe that is idle + rx, tx := io.Pipe() + + // cancel the context right before you start reading + var once sync.Once + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, + } + + // and force the code to use it so it hangs on input for address + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + args := []string{ + "-state", statePath, + "hashicorp/aws", + "acmecorp/aws", + } + code := RunCommander(t, StateReplaceProviderCommander(), meta, args) + output := done(t).Stderr() + if code != 1 { + t.Fatalf("bad status code: %d\n\n%s", code, output) + } + + if !strings.Contains(output, "interrupted: context canceled") { + t.Fatalf("error was not the one I expected to have, %s", output) + } + + }) + t.Run("invalid flags", func(t *testing.T) { view, done := testView(t) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/ui_input_test.go new/opentofu-1.13.11/internal/command/ui_input_test.go --- old/opentofu-1.13.10/internal/command/ui_input_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/ui_input_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -45,7 +45,7 @@ } // Make a context that can be canceled. - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) go func() { // Cancel the context after 2 seconds. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/unlock.go new/opentofu-1.13.11/internal/command/unlock.go --- old/opentofu-1.13.10/internal/command/unlock.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/unlock.go 2026-11-30 15:46:26.000000000 +0100 @@ -117,11 +117,14 @@ return 1 } + cancelCtx, cancel := c.InterruptibleContext(ctx) + defer cancel() + desc := "OpenTofu will remove the lock on the remote state.\n" + "This will allow local OpenTofu commands to modify this state, even though it\n" + "may still be in use. Only 'yes' will be accepted to confirm." - v, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{ + v, err := c.UIInput().Input(cancelCtx, &tofu.InputOpts{ Id: "force-unlock", Query: "Do you really want to force-unlock?", Description: desc, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/command/unlock_test.go new/opentofu-1.13.11/internal/command/unlock_test.go --- old/opentofu-1.13.10/internal/command/unlock_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/command/unlock_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -6,7 +6,11 @@ package command import ( + "context" + "io" "os" + "strings" + "sync" "testing" "github.com/opentofu/opentofu/internal/backend/remote-state/inmem" @@ -124,3 +128,68 @@ t.Fatalf("bad: %d\n%s", code, unlockOutput.All()) } } + +func TestUnlockCancelledMidInput(t *testing.T) { + td := t.TempDir() + testCopyDir(t, testFixturePath("backend-inmem-locked"), td) + t.Chdir(td) + defer inmem.Reset() + + unlockView, unlockDone := testView(t) + + // Create a cancelled context to see if it is passed (next I will ask the input to be a pipe so it works) + ctx, cancel := context.WithCancel(t.Context()) + + // init backend + initView, initDone := testView(t) + meta := Meta{ + WorkingDir: workdir.NewDir("."), + View: initView, + } + code := RunCommander(t, InitCommander(), meta, nil) + initOutput := initDone(t) + if code != 0 { + t.Fatalf("bad: %d\n%s", code, initOutput.Stderr()) + } + + meta = Meta{ + WorkingDir: workdir.NewDir("."), + View: unlockView, + + // make sure that the actual call will use the cancellable context + CallerContext: ctx, + } + + // create a pipe that is idle + rx, tx := io.Pipe() + + // cancel the context right before you start reading + var once sync.Once + rWrapped := notifyReader{ + cancel: cancel, + once: &once, + Reader: rx, + } + + // and force the code to use it so it hangs on input for address + defaultInputReader = &rWrapped + + // reset all things I set when done to not hog resources + defer func() { + defaultInputReader = os.Stdin + rx.Close() + tx.Close() + }() + + args := []string{"LOCK_ID"} + + code = RunCommander(t, UnlockCommander(), meta, args) + output := unlockDone(t).Stderr() + if code != 1 { + t.Fatalf("bad status code: %d\n\n%s", code, output) + } + + if !strings.Contains(output, "interrupted: context canceled") { + t.Fatalf("error was not the one I expected to have, %s", output) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/communicator/ssh/communicator_test.go new/opentofu-1.13.11/internal/communicator/ssh/communicator_test.go --- old/opentofu-1.13.10/internal/communicator/ssh/communicator_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/communicator/ssh/communicator_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -136,6 +136,73 @@ return l.Addr().String(), func() { wg.Wait() } } +// newMockBastionServer starts a ssh server that accepts only "tcp" connections intended for port forwarding. +// The given [targetAddr] is a host:port value that will be used to initialise a ssh connection to the final +// target ssh server. +func newMockBastionServer(t *testing.T, targetAddr string) (string, func()) { + t.Helper() + + signer, err := ssh.ParsePrivateKey([]byte(testServerPrivateKey)) + if err != nil { + t.Fatalf("parse bastion host key: %s", err) + } + srvConf := &ssh.ServerConfig{ + PasswordCallback: acceptUserPass("user", "pass"), + } + srvConf.AddHostKey(signer) + + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("bastion listen: %s", err) + } + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + defer l.Close() + c, err := l.Accept() + if err != nil { + return + } + t.Log("[Bastion] Accepted SSH connection") + defer c.Close() + conn, chans, reqs, err := ssh.NewServerConn(c, srvConf) + if err != nil { + t.Logf("bastion handshake error (expected only if pin were enforced): %v", err) + return + } + defer conn.Close() + go ssh.DiscardRequests(reqs) + + for nc := range chans { + t.Logf("[Bastion] Channel incoming [type: %s]", nc.ChannelType()) + if nc.ChannelType() != "direct-tcpip" { + _ = nc.Reject(ssh.UnknownChannelType, "only direct-tcpip") + continue + } + ch, chReqs, err := nc.Accept() + if err != nil { + return + } + go ssh.DiscardRequests(chReqs) + + t.Logf("[Bastion] Dialing target address %s", targetAddr) + upstream, err := net.Dial("tcp", targetAddr) + if err != nil { + t.Logf("[Bastion] Error dialing target address %s: %s", targetAddr, err) + ch.Close() + return + } + t.Logf("[Bastion] Dialing target address %s succeedded", targetAddr) + go func() { _, _ = io.Copy(upstream, ch); upstream.Close() }() + go func() { _, _ = io.Copy(ch, upstream); ch.Close() }() + } + }() + + return l.Addr().String(), func() { l.Close(); wg.Wait() } +} + func TestNew_Invalid(t *testing.T) { address, sclose := newMockLineServer(t, nil, testClientPublicKey) defer sclose() @@ -829,6 +896,60 @@ } } +func TestConnectionThroughBastion(t *testing.T) { + signer, err := ssh.ParsePrivateKey([]byte(testServerPrivateKey)) + if err != nil { + t.Fatalf("parse bastion host key: %s", err) + } + pubKey := fmt.Sprintf("ssh-rsa %s", base64.StdEncoding.EncodeToString(signer.PublicKey().Marshal())) + + // Create the final target server + targetAddr, tclose := newMockLineServer(t, nil, testClientPublicKey) + defer tclose() + targetHost, targetPortStr, _ := net.SplitHostPort(targetAddr) + targetPort, _ := strconv.Atoi(targetPortStr) + + // Create a mocked bastion ssh connection + bastionAddr, bclose := newMockBastionServer(t, targetAddr) + defer bclose() + bastionHost, bastionPortStr, _ := net.SplitHostPort(bastionAddr) + bastionPort, _ := strconv.Atoi(bastionPortStr) + + connInfo := &connectionInfo{ + User: "user", + Password: "pass", + Host: targetHost, + Port: uint16(targetPort), + HostKey: testClientPublicKey, // (1) The target server host key is different from the one registered by the server so we expect this to fail + + BastionHost: bastionHost, + BastionPort: uint16(bastionPort), + BastionHostKey: pubKey, // (2) The bastion host key is the right one so we expect it to pass and move forward with the target host connection + BastionUser: "user", + BastionPassword: "pass", + + Timeout: "30s", + } + + cfg, err := prepareSSHConfig(connInfo) + if err != nil { + t.Fatalf("prepareSSHConfig: %s", err) + } + c := &Communicator{connInfo: connInfo, config: cfg} + + var cmd remote.Cmd + cmd.Command = "echo foo" + cmd.Stdout = new(bytes.Buffer) + + err = c.Start(&cmd) + t.Cleanup(func() { + _ = c.Disconnect() + }) + if err == nil || (!strings.Contains(err.Error(), "mismatch") && !strings.Contains(err.Error(), fmt.Sprintf("user@%s:%s", targetAddr, targetPortStr))) { + t.Fatalf("expected the connection to the target host to fail due to mismatching host key: %s", err) + } +} + var testClientPublicKey = `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6A1c4n+OtEPEFlNKTZf2i03L3NylSYmvmJ8OLmzLuPZmJBJt4G3VZ/60s1aKzwLKrTq20S+ONG4zvnK5zIPoauoNNdUJKbg944hB4OE+HDbrBhk7SH+YWCsCILBoSXwAVdUEic6FWf/SeqBSmTBySHvpuNOw16J+SK6Ardx8k64F2tRkZuC6AmOZijgKa/sQKjWAIVPk34ECM6OLfPc3kKUEfkdpYLvuMfuRMfSTlxn5lFC0b0SovK9aWfNMBH9iXLQkieQ5rXoyzUC7mwgnASgl8cqw1UrToiUuhvneduXBhbQfmC/Upv+tL6dSSk+0DlgVKEHuJmc8s8+/qpdL` func acceptUserPass(goodUser, goodPass string) func(ssh.ConnMetadata, []byte) (*ssh.Permissions, error) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/communicator/ssh/provisioner.go new/opentofu-1.13.11/internal/communicator/ssh/provisioner.go --- old/opentofu-1.13.10/internal/communicator/ssh/provisioner.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/communicator/ssh/provisioner.go 2026-11-30 15:46:26.000000000 +0100 @@ -298,7 +298,7 @@ host: bastionHost, privateKey: connInfo.BastionPrivateKey, password: connInfo.BastionPassword, - hostKey: connInfo.HostKey, + hostKey: connInfo.BastionHostKey, certificate: connInfo.BastionCertificate, sshAgent: sshAgent, }) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/getproviders/http_mirror_source.go new/opentofu-1.13.11/internal/getproviders/http_mirror_source.go --- old/opentofu-1.13.10/internal/getproviders/http_mirror_source.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/getproviders/http_mirror_source.go 2026-11-30 15:46:26.000000000 +0100 @@ -15,6 +15,7 @@ "net/http" "net/url" "path" + "strconv" "strings" "time" @@ -357,6 +358,21 @@ log.Printf("[WARN] Network mirror returned %q as part of its JSON content type, which is not defined. Ignoring.", name) } body = resp.Body + // if content-length is specified, use it to return a reader that can read only the indicated content-length + cl := resp.Header.Get("Content-Length") + if len(cl) > 0 { + contentLen, err := strconv.ParseInt(cl, 10, 0) + if err != nil { + log.Printf("[WARN] Network mirror returned invalid value %q for content-length. This will be ignored but the unbounded body could create unexpected behavior", cl) + } + body = struct { + io.Reader + io.Closer + }{ + Reader: io.LimitReader(body, contentLen), + Closer: body, + } + } } return resp.StatusCode, body, finalURL, nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/getproviders/http_mirror_source_test.go new/opentofu-1.13.11/internal/getproviders/http_mirror_source_test.go --- old/opentofu-1.13.10/internal/getproviders/http_mirror_source_test.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/getproviders/http_mirror_source_test.go 2026-11-30 15:46:26.000000000 +0100 @@ -48,6 +48,8 @@ failingProvider := addrs.MustParseProviderSourceString("terraform.io/test/fails") redirectingProvider := addrs.MustParseProviderSourceString("terraform.io/test/redirects") redirectLoopProvider := addrs.MustParseProviderSourceString("terraform.io/test/redirect-loop") + contentLenSmallerProvider := addrs.MustParseProviderSourceString("registry.opentofu.org/length/smaller") + contentLenHigherProvider := addrs.MustParseProviderSourceString("registry.opentofu.org/length/higher") tosPlatform := Platform{OS: "tos", Arch: "m68k"} clientBuilderFromHTTPLocation := func(t *testing.T, expectedRetries int) func(ctx context.Context) *retryablehttp.Client { @@ -80,6 +82,29 @@ t.Errorf("wrong result\n%s", diff) } }) + + t.Run("AvailableVersions for provider that specifies content-length smaller than the body content", func(t *testing.T) { + _, _, err := source.AvailableVersions(context.Background(), contentLenSmallerProvider) + expected := "invalid response content from mirror server: unexpected EOF" + if err == nil || !strings.Contains(err.Error(), expected) { + t.Fatalf("unexpected error: %s. Expected to contain %q", err, expected) + } + }) + + t.Run("AvailableVersions for provider that specifies content-length higher than the body content", func(t *testing.T) { + got, _, err := source.AvailableVersions(context.Background(), contentLenHigherProvider) + if err != nil { + t.Fatalf("unexpected error: %s", err) + } + want := VersionList{ + MustParseVersion("1.0.0"), + MustParseVersion("1.0.1"), + MustParseVersion("1.0.2-beta.1"), + } + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("wrong result\n%s", diff) + } + }) t.Run("AvailableVersions for provider that doesn't exist", func(t *testing.T) { _, _, err := source.AvailableVersions(context.Background(), missingProvider) switch err := err.(type) { @@ -359,6 +384,30 @@ resp.Header().Add("Content-Type", "application/json; ignored=yes") // Just return a retryable status code resp.WriteHeader(http.StatusInternalServerError) + case "/registry.opentofu.org/length/smaller/index.json": + resp.Header().Add("Content-Type", "application/json") + resp.Header().Add("Content-Length", "1") // having the content-length smaller than the body content, limits the reading to the size specified in the header + resp.WriteHeader(http.StatusOK) + fmt.Fprint(resp, ` + { + "versions": { + "1.0.0": {}, + "1.0.1": {}, + "1.0.2-beta.1": {} + } + }`) + case "/registry.opentofu.org/length/higher/index.json": + resp.Header().Add("Content-Type", "application/json") + resp.Header().Add("Content-Length", "1024") // having the content-length higher, reads exactly the content of the body + resp.WriteHeader(http.StatusOK) + fmt.Fprint(resp, ` + { + "versions": { + "1.0.0": {}, + "1.0.1": {}, + "1.0.2-beta.1": {} + } + }`) default: resp.WriteHeader(404) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/internal/plugins/provider.go new/opentofu-1.13.11/internal/plugins/provider.go --- old/opentofu-1.13.10/internal/plugins/provider.go 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/internal/plugins/provider.go 2026-11-30 15:46:26.000000000 +0100 @@ -151,21 +151,11 @@ } func (p *providerManager) NewConfiguredProvider(ctx context.Context, addr addrs.Provider, configVal cty.Value) (providers.Configured, tfdiags.Diagnostics) { - var diags tfdiags.Diagnostics - - p.instancesLock.Lock() - defer p.instancesLock.Unlock() - if p.isShutdown.Load() { - return nil, diags.Append(fmt.Errorf("bug: unable to start provider %s, manager is shutdown", addr)) - } - - provider, err := p.providerFactories.NewInstance(addr) - if err != nil { - return nil, diags.Append(err) + provider, diags := p.NewProvider(ctx, addr) + if diags.HasErrors() { + return nil, diags } - p.instances = append(p.instances, provider) - // If our config value contains any marked values, ensure those are // stripped out before sending this to the provider unmarkedConfigVal, _ := configVal.UnmarkDeep() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentofu-1.13.10/version/VERSION new/opentofu-1.13.11/version/VERSION --- old/opentofu-1.13.10/version/VERSION 2026-11-23 19:59:18.000000000 +0100 +++ new/opentofu-1.13.11/version/VERSION 2026-11-30 15:46:26.000000000 +0100 @@ -1 +1 @@ -1.13.10 +1.13.11 ++++++ opentofu.obsinfo ++++++ --- /var/tmp/diff_new_pack.OuTZ8m/_old 2026-12-02 17:08:45.964210871 +0100 +++ /var/tmp/diff_new_pack.OuTZ8m/_new 2026-12-02 17:08:45.967210998 +0100 @@ -1,5 +1,5 @@ name: opentofu -version: 1.13.10 -mtime: 1795460358 -commit: 4dcfb2efaaf7d3e95a92d1c10b7fd000e82bc51f +version: 1.13.11 +mtime: 1796049986 +commit: 6658f545663281227105d6de888dacedc2010bd2 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/opentofu/vendor.tar.gz /work/SRC/openSUSE:Factory/.opentofu.new.1340718/vendor.tar.gz differ: char 134, line 3
