-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GPGME: support passphrase for prompt-less signing
To support signing images via gpgme without user prompt, allow for providing a passphrase via the copy options. Add a new *WithOptions API to the `signature` package and extend its interface. To prevent breaking the API, extend the signature API with an internal type as has already been done for other types and interfaces. Signed-off-by: Valentin Rothberg <[email protected]>
- Loading branch information
Showing
16 changed files
with
198 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cli | ||
|
||
import ( | ||
"bufio" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"os" | ||
"strings" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// ReadPassphraseFile returns the first line of the specified path. | ||
// For convenience, an empty string is returned if the path is empty. | ||
func ReadPassphraseFile(path string) (string, error) { | ||
if path == "" { | ||
return "", nil | ||
} | ||
|
||
logrus.Debugf("Reading user-specified passphrase for signing from %s", path) | ||
|
||
ppf, err := os.Open(path) | ||
if err != nil { | ||
return "", err | ||
} | ||
defer ppf.Close() | ||
|
||
// Read the *first* line in the passphrase file, just as gpg(1) does. | ||
buf, err := bufio.NewReader(ppf).ReadBytes('\n') | ||
if err != nil && !errors.Is(err, io.EOF) { | ||
return "", fmt.Errorf("reading passphrase file: %w", err) | ||
} | ||
|
||
return strings.TrimSuffix(string(buf), "\n"), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.