mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 01:20:55 +02:00
Upgrade docker (#2440)
* somehow now the only thing that doesnt work is devices.Device Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * this gets rid of all the compiler errors in the vendored code Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * fixed some things but a bunch of tests and maybe some compiler steps are still failing Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * all the things i figured out how to fix so far Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * guess i had to redo go mods after rebasing again Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * update docker constants to be SHOUTY CASE now Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * include DestPath in resolveEnv Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * fix one mistake in Docker lib upgrade and some typos/deprecations in the file Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * last changes (hopefully) to update to new docker libs Signed-off-by: Joe Kimmel <jkimmel@vmware.com> --------- Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
This commit is contained in:
+20
-17
@@ -1,6 +1,15 @@
|
||||
// Copyright 2022 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package client is a cross-platform client for the signer binary (a.k.a."EnterpriseCertSigner").
|
||||
//
|
||||
@@ -13,10 +22,9 @@ import (
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -44,17 +52,6 @@ func (c *Connection) Close() error {
|
||||
return werr
|
||||
}
|
||||
|
||||
// If ECP Logging is enabled return true
|
||||
// Otherwise return false
|
||||
func enableECPLogging() bool {
|
||||
if os.Getenv("ENABLE_ENTERPRISE_CERTIFICATE_LOGS") != "" {
|
||||
return true
|
||||
}
|
||||
|
||||
log.SetOutput(ioutil.Discard)
|
||||
return false
|
||||
}
|
||||
|
||||
func init() {
|
||||
gob.Register(crypto.SHA256)
|
||||
gob.Register(&rsa.PSSOptions{})
|
||||
@@ -87,7 +84,7 @@ func (k *Key) Close() error {
|
||||
}
|
||||
// Wait for cmd to exit and release resources. Since the process is forcefully killed, this
|
||||
// will return a non-nil error (varies by OS), which we will ignore.
|
||||
k.cmd.Wait()
|
||||
_ = k.cmd.Wait()
|
||||
// The Pipes connecting the RPC client should have been closed when the signer subprocess was killed.
|
||||
// Calling `k.client.Close()` before `k.cmd.Process.Kill()` or `k.cmd.Wait()` _will_ cause a segfault.
|
||||
if err := k.client.Close(); err.Error() != "close |0: file already closed" {
|
||||
@@ -110,6 +107,10 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [
|
||||
return
|
||||
}
|
||||
|
||||
// ErrCredUnavailable is a sentinel error that indicates ECP Cred is unavailable,
|
||||
// possibly due to missing config or missing binary path.
|
||||
var ErrCredUnavailable = errors.New("Cred is unavailable")
|
||||
|
||||
// Cred spawns a signer subprocess that listens on stdin/stdout to perform certificate
|
||||
// related operations, including signing messages with the private key.
|
||||
//
|
||||
@@ -118,12 +119,14 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [
|
||||
//
|
||||
// The config file also specifies which certificate the signer should use.
|
||||
func Cred(configFilePath string) (*Key, error) {
|
||||
enableECPLogging()
|
||||
if configFilePath == "" {
|
||||
configFilePath = util.GetDefaultConfigFilePath()
|
||||
}
|
||||
enterpriseCertSignerPath, err := util.LoadSignerBinaryPath(configFilePath)
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrConfigUnavailable) {
|
||||
return nil, ErrCredUnavailable
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
k := &Key{
|
||||
|
||||
+23
-3
@@ -1,10 +1,23 @@
|
||||
// Copyright 2022 Google LLC.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package util provides helper functions for the client.
|
||||
package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
@@ -23,14 +36,21 @@ type Libs struct {
|
||||
ECP string `json:"ecp"`
|
||||
}
|
||||
|
||||
// ErrConfigUnavailable is a sentinel error that indicates ECP config is unavailable,
|
||||
// possibly due to entire config missing or missing binary path.
|
||||
var ErrConfigUnavailable = errors.New("Config is unavailable")
|
||||
|
||||
// LoadSignerBinaryPath retrieves the path of the signer binary from the config file.
|
||||
func LoadSignerBinaryPath(configFilePath string) (path string, err error) {
|
||||
jsonFile, err := os.Open(configFilePath)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return "", ErrConfigUnavailable
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
byteValue, err := ioutil.ReadAll(jsonFile)
|
||||
byteValue, err := io.ReadAll(jsonFile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -41,7 +61,7 @@ func LoadSignerBinaryPath(configFilePath string) (path string, err error) {
|
||||
}
|
||||
signerBinaryPath := config.Libs.ECP
|
||||
if signerBinaryPath == "" {
|
||||
return "", errors.New("signer binary path is missing")
|
||||
return "", ErrConfigUnavailable
|
||||
}
|
||||
return signerBinaryPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user