Files
podman/vendor/go.podman.io/common/pkg/config/systemd.go
Andrew Melnick feb36e4fe6 Implement TLS API Support
* Added flags to point to TLS PEM files to use for exposing and connecting
  to an encrypted remote API socket with server and client authentication.
* Added TLS fields for system connection ls templates.
* Added special "tls" format for system connection ls to list TLS fields
  in human-readable table format.
* Updated remote integration and system tests to allow specifying a
  "transport" to run the full suite against a unix, tcp, tls, or mtls
  system service.
* Added system tests to verify basic operation of unix, tcp, tls, and mtls
  services, clients, and connections.

Signed-off-by: Andrew Melnick <meln5674.5674@gmail.com>
2025-09-26 09:09:54 -06:00

77 lines
1.3 KiB
Go

//go:build systemd && cgo
package config
import (
"os"
"path/filepath"
"sync"
"go.podman.io/common/pkg/cgroupv2"
"go.podman.io/common/pkg/systemd"
"go.podman.io/storage/pkg/unshare"
)
var (
journaldOnce sync.Once
usesJournald bool
)
const (
// DefaultLogDriver is the default type of log files.
DefaultLogDriver = "journald"
)
func defaultCgroupManager() string {
if !useSystemd() {
return CgroupfsCgroupsManager
}
enabled, err := cgroupv2.Enabled()
if err == nil && !enabled && unshare.IsRootless() {
return CgroupfsCgroupsManager
}
return SystemdCgroupsManager
}
func defaultEventsLogger() string {
if useJournald() {
return "journald"
}
return "file"
}
func defaultLogDriver() string {
if useJournald() {
return "journald"
}
return "k8s-file"
}
func useSystemd() bool {
return systemd.RunsOnSystemd()
}
func useJournald() bool {
journaldOnce.Do(func() {
if !useSystemd() {
return
}
for _, root := range []string{"/run/log/journal", "/var/log/journal"} {
dirs, err := os.ReadDir(root)
if err != nil {
continue
}
for _, d := range dirs {
if d.IsDir() {
if _, err := os.ReadDir(filepath.Join(root, d.Name())); err == nil {
usesJournald = true
return
}
}
}
}
})
return usesJournald
}