Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgp: remove DisableAgent option #1282

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions pgp/keysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (

"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
gpgagent "github.com/getsops/gopgagent"
"github.com/getsops/sops/v3/logging"
"github.com/sirupsen/logrus"
gpgagent "github.com/getsops/gopgagent"
"golang.org/x/term"
)

Expand Down Expand Up @@ -73,9 +73,6 @@ type MasterKey struct {
// It can be injected by a (local) keyservice.KeyServiceServer using
// GnuPGHome.ApplyToMasterKey().
gnuPGHomeDir string
// disableAgent instructs the MasterKey to not use the GnuPG agent during
// decryption operations.
disableAgent bool
// disableOpenPGP instructs the MasterKey to skip attempting to open any
// pubRing or secRing using OpenPGP.
disableOpenPGP bool
Expand Down Expand Up @@ -201,14 +198,6 @@ func (d GnuPGHome) ApplyToMasterKey(key *MasterKey) {
}
}

// DisableAgent disables the GnuPG agent for a MasterKey.
type DisableAgent struct{}

// ApplyToMasterKey configures the provided key to not use the GnuPG agent.
func (d DisableAgent) ApplyToMasterKey(key *MasterKey) {
key.disableAgent = true
}

// DisableOpenPGP disables encrypt and decrypt operations using OpenPGP.
type DisableOpenPGP struct{}

Expand Down Expand Up @@ -418,9 +407,6 @@ func (key *MasterKey) decryptWithGnuPG() ([]byte, error) {
args := []string{
"-d",
}
if !key.disableAgent {
args = append([]string{"--use-agent"}, args...)
}
err, stdout, stderr := gpgExec(key.gnuPGHome(), args, strings.NewReader(key.EncryptedKey))
if err != nil {
return nil, fmt.Errorf("failed to decrypt sops data key with pgp: %s",
Expand Down
6 changes: 0 additions & 6 deletions pgp/keysource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ func TestGnuPGHome_ApplyToMasterKey(t *testing.T) {
assert.NotEqual(t, gnuPGHome.String(), key.gnuPGHomeDir)
}

func TestDisableAgent_ApplyToMasterKey(t *testing.T) {
key := NewMasterKeyFromFingerprint(mockFingerprint)
DisableAgent{}.ApplyToMasterKey(key)
assert.True(t, key.disableAgent)
}

func TestDisableOpenPGP_ApplyToMasterKey(t *testing.T) {
key := NewMasterKeyFromFingerprint(mockFingerprint)
DisableOpenPGP{}.ApplyToMasterKey(key)
Expand Down