mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-25 13:37:51 +00:00
handle GpgDisableVerify and ignore-signatures consistently
and be less verbose
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ func getVerifier(keyRings []string) (pgp.Verifier, error) {
|
|||||||
verifier.AddKeyring(keyRing)
|
verifier.AddKeyring(keyRing)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := verifier.InitKeyring()
|
err := verifier.InitKeyring(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -10,13 +10,17 @@ import (
|
|||||||
|
|
||||||
func getVerifier(flags *flag.FlagSet) (pgp.Verifier, error) {
|
func getVerifier(flags *flag.FlagSet) (pgp.Verifier, error) {
|
||||||
keyRings := flags.Lookup("keyring").Value.Get().([]string)
|
keyRings := flags.Lookup("keyring").Value.Get().([]string)
|
||||||
|
ignoreSignatures := context.Config().GpgDisableVerify
|
||||||
|
if context.Flags().IsSet("ignore-signatures") {
|
||||||
|
ignoreSignatures = context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
||||||
|
}
|
||||||
|
|
||||||
verifier := context.GetVerifier()
|
verifier := context.GetVerifier()
|
||||||
for _, keyRing := range keyRings {
|
for _, keyRing := range keyRings {
|
||||||
verifier.AddKeyring(keyRing)
|
verifier.AddKeyring(keyRing)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := verifier.InitKeyring()
|
err := verifier.InitKeyring(ignoreSignatures == false) // be verbose only if verifying signatures is requested
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
|
|||||||
downloadSources := LookupOption(context.Config().DownloadSourcePackages, context.Flags(), "with-sources")
|
downloadSources := LookupOption(context.Config().DownloadSourcePackages, context.Flags(), "with-sources")
|
||||||
downloadUdebs := context.Flags().Lookup("with-udebs").Value.Get().(bool)
|
downloadUdebs := context.Flags().Lookup("with-udebs").Value.Get().(bool)
|
||||||
downloadInstaller := context.Flags().Lookup("with-installer").Value.Get().(bool)
|
downloadInstaller := context.Flags().Lookup("with-installer").Value.Get().(bool)
|
||||||
ignoreSignatures := context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
ignoreSignatures := context.Config().GpgDisableVerify
|
||||||
|
if context.Flags().IsSet("ignore-signatures") {
|
||||||
|
ignoreSignatures = context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mirrorName, archiveURL, distribution string
|
mirrorName, archiveURL, distribution string
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchMirror := false
|
fetchMirror := false
|
||||||
ignoreSignatures := true
|
ignoreSignatures := context.Config().GpgDisableVerify
|
||||||
context.Flags().Visit(func(flag *flag.Flag) {
|
context.Flags().Visit(func(flag *flag.Flag) {
|
||||||
switch flag.Name {
|
switch flag.Name {
|
||||||
case "filter":
|
case "filter":
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreSignatures := context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
ignoreSignatures := context.Config().GpgDisableVerify
|
||||||
|
if context.Flags().IsSet("ignore-signatures") {
|
||||||
|
ignoreSignatures = context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
||||||
|
}
|
||||||
ignoreChecksums := context.Flags().Lookup("ignore-checksums").Value.Get().(bool)
|
ignoreChecksums := context.Flags().Lookup("ignore-checksums").Value.Get().(bool)
|
||||||
|
|
||||||
verifier, err := getVerifier(context.Flags())
|
verifier, err := getVerifier(context.Flags())
|
||||||
|
|||||||
+4
-1
@@ -29,7 +29,10 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
forceReplace := context.Flags().Lookup("force-replace").Value.Get().(bool)
|
forceReplace := context.Flags().Lookup("force-replace").Value.Get().(bool)
|
||||||
acceptUnsigned := context.Flags().Lookup("accept-unsigned").Value.Get().(bool)
|
acceptUnsigned := context.Flags().Lookup("accept-unsigned").Value.Get().(bool)
|
||||||
ignoreSignatures := context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
ignoreSignatures := context.Config().GpgDisableVerify
|
||||||
|
if context.Flags().IsSet("ignore-signatures") {
|
||||||
|
ignoreSignatures = context.Flags().Lookup("ignore-signatures").Value.Get().(bool)
|
||||||
|
}
|
||||||
noRemoveFiles := context.Flags().Lookup("no-remove-files").Value.Get().(bool)
|
noRemoveFiles := context.Flags().Lookup("no-remove-files").Value.Get().(bool)
|
||||||
repoTemplateString := context.Flags().Lookup("repo").Value.Get().(string)
|
repoTemplateString := context.Flags().Lookup("repo").Value.Get().(string)
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import (
|
|||||||
type NullVerifier struct {
|
type NullVerifier struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NullVerifier) InitKeyring() error {
|
func (n *NullVerifier) InitKeyring(_ bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -163,8 +163,8 @@ func NewGpgVerifier(finder GPGFinder) *GpgVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitKeyring verifies that gpg is installed and some keys are trusted
|
// InitKeyring verifies that gpg is installed and some keys are trusted
|
||||||
func (g *GpgVerifier) InitKeyring() error {
|
func (g *GpgVerifier) InitKeyring(verbose bool) error {
|
||||||
if len(g.keyRings) == 0 {
|
if len(g.keyRings) == 0 && verbose {
|
||||||
// using default keyring
|
// using default keyring
|
||||||
output, err := exec.Command(g.gpg, "--no-default-keyring", "--no-auto-check-trustdb", "--keyring", "trustedkeys.gpg", "--list-keys").Output()
|
output, err := exec.Command(g.gpg, "--no-default-keyring", "--no-auto-check-trustdb", "--keyring", "trustedkeys.gpg", "--list-keys").Output()
|
||||||
if err == nil && len(output) == 0 {
|
if err == nil && len(output) == 0 {
|
||||||
|
|||||||
+4
-4
@@ -94,7 +94,7 @@ func (s *Gnupg1VerifierSuite) SetUpTest(c *C) {
|
|||||||
s.verifier = NewGpgVerifier(finder)
|
s.verifier = NewGpgVerifier(finder)
|
||||||
s.verifier.AddKeyring("./trusted.gpg")
|
s.verifier.AddKeyring("./trusted.gpg")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Gnupg1SignerSuite struct {
|
type Gnupg1SignerSuite struct {
|
||||||
@@ -122,7 +122,7 @@ func (s *Gnupg1SignerSuite) SetUpTest(c *C) {
|
|||||||
s.verifier.AddKeyring("./keyrings/aptly.pub")
|
s.verifier.AddKeyring("./keyrings/aptly.pub")
|
||||||
s.verifier.AddKeyring("./keyrings/aptly_passphrase.pub")
|
s.verifier.AddKeyring("./keyrings/aptly_passphrase.pub")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
|
|
||||||
s.SignerSuite.SetUpTest(c)
|
s.SignerSuite.SetUpTest(c)
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ func (s *Gnupg2VerifierSuite) SetUpTest(c *C) {
|
|||||||
s.verifier = NewGpgVerifier(finder)
|
s.verifier = NewGpgVerifier(finder)
|
||||||
s.verifier.AddKeyring("./trusted.gpg")
|
s.verifier.AddKeyring("./trusted.gpg")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Gnupg2SignerSuite struct {
|
type Gnupg2SignerSuite struct {
|
||||||
@@ -210,7 +210,7 @@ func (s *Gnupg2SignerSuite) SetUpTest(c *C) {
|
|||||||
s.verifier = &GoVerifier{}
|
s.verifier = &GoVerifier{}
|
||||||
s.verifier.AddKeyring("./keyrings/aptly2_trusted.pub")
|
s.verifier.AddKeyring("./keyrings/aptly2_trusted.pub")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
|
|
||||||
s.skipDefaultKey = true
|
s.skipDefaultKey = true
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -283,7 +283,7 @@ type GoVerifier struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitKeyring verifies that gpg is installed and some keys are trusted
|
// InitKeyring verifies that gpg is installed and some keys are trusted
|
||||||
func (g *GoVerifier) InitKeyring() error {
|
func (g *GoVerifier) InitKeyring(verbose bool) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if len(g.keyRingFiles) == 0 {
|
if len(g.keyRingFiles) == 0 {
|
||||||
@@ -304,7 +304,7 @@ func (g *GoVerifier) InitKeyring() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(g.trustedKeyring) == 0 {
|
if len(g.trustedKeyring) == 0 && verbose {
|
||||||
fmt.Printf("\nLooks like your keyring with trusted keys is empty. You might consider importing some keys.\n")
|
fmt.Printf("\nLooks like your keyring with trusted keys is empty. You might consider importing some keys.\n")
|
||||||
if len(g.keyRingFiles) == 0 {
|
if len(g.keyRingFiles) == 0 {
|
||||||
// using default keyring
|
// using default keyring
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func (s *GoVerifierSuite) SetUpTest(c *C) {
|
|||||||
s.verifier = &GoVerifier{}
|
s.verifier = &GoVerifier{}
|
||||||
s.verifier.AddKeyring("./trusted.gpg")
|
s.verifier.AddKeyring("./trusted.gpg")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoSignerSuite struct {
|
type GoSignerSuite struct {
|
||||||
@@ -36,7 +36,7 @@ func (s *GoSignerSuite) SetUpTest(c *C) {
|
|||||||
s.verifier.AddKeyring("./keyrings/aptly.pub")
|
s.verifier.AddKeyring("./keyrings/aptly.pub")
|
||||||
s.verifier.AddKeyring("./keyrings/aptly_passphrase.pub")
|
s.verifier.AddKeyring("./keyrings/aptly_passphrase.pub")
|
||||||
|
|
||||||
c.Assert(s.verifier.InitKeyring(), IsNil)
|
c.Assert(s.verifier.InitKeyring(false), IsNil)
|
||||||
|
|
||||||
s.SignerSuite.SetUpTest(c)
|
s.SignerSuite.SetUpTest(c)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ type Signer interface {
|
|||||||
|
|
||||||
// Verifier interface describes signature verification factility
|
// Verifier interface describes signature verification factility
|
||||||
type Verifier interface {
|
type Verifier interface {
|
||||||
InitKeyring() error
|
InitKeyring(verbose bool) error
|
||||||
AddKeyring(keyring string)
|
AddKeyring(keyring string)
|
||||||
VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error
|
VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error
|
||||||
IsClearSigned(clearsigned io.Reader) (bool, error)
|
IsClearSigned(clearsigned io.Reader) (bool, error)
|
||||||
|
|||||||
Reference in New Issue
Block a user