fix gpg keys

This commit is contained in:
André Roth
2020-09-28 20:29:43 +00:00
committed by Lorenzo Bolla
parent d13de0464e
commit 8e02a03170
+9 -1
View File
@@ -7,6 +7,7 @@ import (
"path/filepath" "path/filepath"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/aptly-dev/aptly/pgp"
) )
// POST /api/gpg // POST /api/gpg
@@ -57,10 +58,17 @@ func apiGPGAddKey(c *gin.Context) {
args = append(args, "--recv", b.GpgKeyID) args = append(args, "--recv", b.GpgKeyID)
} }
finder := pgp.GPG1Finder()
gpg, _, err := finder.FindGPG()
if err != nil {
c.AbortWithError(400, err)
return
}
// it might happened that we have a situation with an erroneous // it might happened that we have a situation with an erroneous
// gpg command (e.g. when GpgKeyID and GpgKeyArmor is set). // gpg command (e.g. when GpgKeyID and GpgKeyArmor is set).
// there is no error handling for such as gpg will do this for us // there is no error handling for such as gpg will do this for us
cmd := exec.Command("gpg", args...) cmd := exec.Command(gpg, args...)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
if err = cmd.Run(); err != nil { if err = cmd.Run(); err != nil {
c.AbortWithError(400, err) c.AbortWithError(400, err)