* Enable running container as mqm * Fix merge problem * Don't force root usage * RHEL image runs as mqm instead of root * Build on host with SELinux enabled * Enable building on node in an OpenShift cluster * Enable running container as mqm * Fix merge problem * Don't force root usage * Merge lastest changes from master * RHEL image runs as mqm instead of root * Fix merge issues * Test changes for non-root * Make timeout properly, and more non-root test fixes * Run tests with fewer/no capabilities * Correct usage docs for non-root * Add security docs * Add temporary debug output * Remove debug code * Fixes for termination-log * Allow init container to run as root * Fixes for CentOS build * Fixes for RHEL build * Logging improvements * Fix Dockerfile RHEL/CentOS build * Fix bash error * Make all builds specify UID * Use redist client for Go SDK * Inspect image before running tests * New test for init container * Log container runtime in runmqdevserver * Add extra capabilities if using a RHEL image
80 lines
2.4 KiB
Go
80 lines
2.4 KiB
Go
/*
|
|
© Copyright IBM Corporation 2017, 2019
|
|
|
|
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
|
|
|
|
http://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 main
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
"strings"
|
|
|
|
containerruntime "github.com/ibm-messaging/mq-container/internal/containerruntime"
|
|
"github.com/ibm-messaging/mq-container/internal/user"
|
|
)
|
|
|
|
func logContainerDetails() error {
|
|
if runtime.GOOS != "linux" {
|
|
return fmt.Errorf("Unsupported platform: %v", runtime.GOOS)
|
|
}
|
|
log.Printf("CPU architecture: %v", runtime.GOARCH)
|
|
kv, err := containerruntime.GetKernelVersion()
|
|
if err == nil {
|
|
log.Printf("Linux kernel version: %v", kv)
|
|
}
|
|
cr, err := containerruntime.GetContainerRuntime()
|
|
if err == nil {
|
|
log.Printf("Container runtime: %v", cr)
|
|
}
|
|
bi, err := containerruntime.GetBaseImage()
|
|
if err == nil {
|
|
log.Printf("Base image: %v", bi)
|
|
}
|
|
u, err := user.GetUser()
|
|
if err == nil {
|
|
if len(u.SupplementalGID) == 0 {
|
|
log.Printf("Running as user ID %v (%v) with primary group %v", u.UID, u.Name, u.PrimaryGID)
|
|
} else {
|
|
log.Printf("Running as user ID %v (%v) with primary group %v, and supplementary groups %v", u.UID, u.Name, u.PrimaryGID, strings.Join(u.SupplementalGID, ","))
|
|
}
|
|
}
|
|
caps, err := containerruntime.GetCapabilities()
|
|
if err == nil {
|
|
for k, v := range caps {
|
|
if len(v) > 0 {
|
|
log.Printf("Capabilities (%s set): %v", strings.ToLower(k), strings.Join(v, ","))
|
|
}
|
|
}
|
|
}
|
|
sc, err := containerruntime.GetSeccomp()
|
|
if err == nil {
|
|
log.Printf("seccomp enforcing mode: %v", sc)
|
|
}
|
|
log.Printf("Process security attributes: %v", containerruntime.GetSecurityAttributes())
|
|
m, err := containerruntime.GetMounts()
|
|
if err == nil {
|
|
if len(m) == 0 {
|
|
log.Print("No volume detected. Persistent messages may be lost")
|
|
} else {
|
|
for mountPoint, fsType := range m {
|
|
log.Printf("Detected '%v' volume mounted to %v", fsType, mountPoint)
|
|
if !containerruntime.SupportedFilesystem(fsType) {
|
|
return fmt.Errorf("%v uses unsupported filesystem type: %v", mountPoint, fsType)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|