aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-01 21:32:22 +0200
committerGitHub <noreply@github.com>2020-05-01 21:32:22 +0200
commit0fd8242f9100806fed4e2abfcae7ea3409050539 (patch)
tree17806ab22aaabf3d360dd54de9af32fc3cef3a05
parent54fa377faf89b27183a789bd98084ea02c4cd4a1 (diff)
parent8173e830544e74284c5bd4510f52b9e19fe25baa (diff)
downloadpodman-0fd8242f9100806fed4e2abfcae7ea3409050539.tar.gz
podman-0fd8242f9100806fed4e2abfcae7ea3409050539.tar.bz2
podman-0fd8242f9100806fed4e2abfcae7ea3409050539.zip
Merge pull request #6058 from rhatdan/coverity
Fix errors found in coverity scan
-rw-r--r--libpod/container_inspect.go31
-rw-r--r--libpod/oci_conmon_linux.go2
-rw-r--r--libpod/runtime_pod_linux.go2
-rw-r--r--pkg/util/mountOpts.go1
4 files changed, 20 insertions, 16 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go
index 729a00be8..276429b11 100644
--- a/libpod/container_inspect.go
+++ b/libpod/container_inspect.go
@@ -661,7 +661,7 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
if ns.Path != "" {
networkMode = fmt.Sprintf("ns:%s", ns.Path)
} else {
- networkMode = "none"
+ networkMode = "private"
}
break
}
@@ -743,22 +743,23 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
ipcMode := ""
if c.config.IPCNsCtr != "" {
ipcMode = fmt.Sprintf("container:%s", c.config.IPCNsCtr)
- } else {
+ } else if ctrSpec.Linux != nil {
// Locate the spec's IPC namespace.
// If there is none, it's ipc=host.
// If there is one and it has a path, it's "ns:".
// If no path, it's default - the empty string.
- foundIPCNS := false
+
for _, ns := range ctrSpec.Linux.Namespaces {
if ns.Type == spec.IPCNamespace {
- foundIPCNS = true
if ns.Path != "" {
ipcMode = fmt.Sprintf("ns:%s", ns.Path)
+ } else {
+ ipcMode = "private"
}
break
}
}
- if !foundIPCNS {
+ if ipcMode == "" {
ipcMode = "host"
}
}
@@ -781,22 +782,22 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
pidMode := ""
if c.config.PIDNsCtr != "" {
pidMode = fmt.Sprintf("container:%s", c.config.PIDNsCtr)
- } else {
+ } else if ctrSpec.Linux != nil {
// Locate the spec's PID namespace.
// If there is none, it's pid=host.
// If there is one and it has a path, it's "ns:".
// If there is no path, it's default - the empty string.
- foundPIDNS := false
for _, ns := range ctrSpec.Linux.Namespaces {
if ns.Type == spec.PIDNamespace {
- foundPIDNS = true
if ns.Path != "" {
pidMode = fmt.Sprintf("ns:%s", ns.Path)
+ } else {
+ pidMode = "private"
}
break
}
}
- if !foundPIDNS {
+ if pidMode == "" {
pidMode = "host"
}
}
@@ -806,22 +807,23 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
utsMode := ""
if c.config.UTSNsCtr != "" {
utsMode = fmt.Sprintf("container:%s", c.config.UTSNsCtr)
- } else {
+ } else if ctrSpec.Linux != nil {
+
// Locate the spec's UTS namespace.
// If there is none, it's uts=host.
// If there is one and it has a path, it's "ns:".
// If there is no path, it's default - the empty string.
- foundUTSNS := false
for _, ns := range ctrSpec.Linux.Namespaces {
if ns.Type == spec.UTSNamespace {
- foundUTSNS = true
if ns.Path != "" {
utsMode = fmt.Sprintf("ns:%s", ns.Path)
+ } else {
+ utsMode = "private"
}
break
}
}
- if !foundUTSNS {
+ if utsMode == "" {
utsMode = "host"
}
}
@@ -831,11 +833,12 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
usernsMode := ""
if c.config.UserNsCtr != "" {
usernsMode = fmt.Sprintf("container:%s", c.config.UserNsCtr)
- } else {
+ } else if ctrSpec.Linux != nil {
// Locate the spec's user namespace.
// If there is none, it's default - the empty string.
// If there is one, it's "private" if no path, or "ns:" if
// there's a path.
+
for _, ns := range ctrSpec.Linux.Namespaces {
if ns.Type == spec.UserNamespace {
if ns.Path != "" {
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index da4b85067..d59ff18ca 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -731,7 +731,7 @@ func (r *ConmonOCIRuntime) ExecContainer(c *Container, sessionID string, options
args = append(args, "-t")
}
- if options.Streams.AttachInput {
+ if options.Streams != nil && options.Streams.AttachInput {
args = append(args, "-i")
}
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go
index 872e8ea8a..73b6c5d9b 100644
--- a/libpod/runtime_pod_linux.go
+++ b/libpod/runtime_pod_linux.go
@@ -236,7 +236,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
}
if err := r.removeContainer(ctx, ctr, force, false, true); err != nil {
- if removalErr != nil {
+ if removalErr == nil {
removalErr = err
} else {
logrus.Errorf("Error removing container %s from pod %s: %v", ctr.ID(), p.ID(), err)
diff --git a/pkg/util/mountOpts.go b/pkg/util/mountOpts.go
index 329a7c913..929223244 100644
--- a/pkg/util/mountOpts.go
+++ b/pkg/util/mountOpts.go
@@ -108,6 +108,7 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
if foundZ {
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'z' and 'Z' can be used")
}
+ foundZ = true
default:
return nil, errors.Wrapf(ErrBadMntOption, "unknown mount option %q", opt)
}