sdk/enter: set GNUPGHOME to ~/.gnupg
This is needed to allow jenkins to sign artifacts.
@@ -182,17 +182,9 @@ func (e *enter) mountGnupg() error {
origHome = filepath.Join(e.User.HomeDir, ".gnupg")
}
- // gpg misbehaves in the SDK with GNUPGHOME set to anything but
- // ~/.gnupg. New SDKs don't encounter this problem because GNUPGHOME
- // is no longer included in the sudo env_keep list. For old SDKs,
- // unset GNUPGHOME so the default ~/.gnupg is used.
- if err := os.Unsetenv("GNUPGHOME"); err != nil {
- return err
- }
-
if _, err := os.Stat(origHome); err != nil {
// Skip but do not bind mount anything
- return nil
+ return os.Unsetenv("GNUPGHOME")
}
// now mount the agent socket directory through
@@ -205,6 +197,14 @@ func (e *enter) mountGnupg() error {
return err
}
+ // gpg misbehaves in the SDK with GNUPGHOME set to anything but
+ // ~/.gnupg. It must be set so it gets passed as part of keep_env
+ // so Jenkins can sign artifacts
+ chrootHome := filepath.Join(e.User.HomeDir, ".gnupg")
+ if err := os.Setenv("GNUPGHOME", chrootHome); err != nil {
+ return err
+ }
+
// gpg expects the socket at /run/user/$uid/gnupg
origAgentDir := filepath.Join("/run", "user", e.User.Uid, "gnupg")
if _, err := os.Stat(origAgentDir); err != nil {
