/* © 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 }