mirror of
https://github.com/containers/podman.git
synced 2026-03-23 09:02:06 -04:00
Merge pull request #20869 from dfr/freebsd-hostname
libpod: Detect whether we have a private UTS namespace on FreeBSD
This commit is contained in:
@@ -688,15 +688,7 @@ func (c *Container) Hostname() string {
|
||||
|
||||
// if the container is not running in a private UTS namespace,
|
||||
// return the host's hostname.
|
||||
privateUTS := false
|
||||
if c.config.Spec.Linux != nil {
|
||||
for _, ns := range c.config.Spec.Linux.Namespaces {
|
||||
if ns.Type == spec.UTSNamespace {
|
||||
privateUTS = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
privateUTS := c.hasPrivateUTS()
|
||||
if !privateUTS {
|
||||
hostname, err := os.Hostname()
|
||||
if err == nil {
|
||||
|
||||
@@ -392,3 +392,10 @@ func (c *Container) getPlatformRunPath() (string, error) {
|
||||
func (c *Container) addMaskedPaths(g *generate.Generator) {
|
||||
// There are currently no FreeBSD-specific masked paths
|
||||
}
|
||||
|
||||
func (c *Container) hasPrivateUTS() bool {
|
||||
// Currently we always use a private UTS namespace on FreeBSD. This
|
||||
// should be optional but needs a FreeBSD section in the OCI runtime
|
||||
// specification.
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -811,3 +811,16 @@ func (c *Container) addMaskedPaths(g *generate.Generator) {
|
||||
g.AddLinuxMaskedPaths("/sys/devices/virtual/powercap")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) hasPrivateUTS() bool {
|
||||
privateUTS := false
|
||||
if c.config.Spec.Linux != nil {
|
||||
for _, ns := range c.config.Spec.Linux.Namespaces {
|
||||
if ns.Type == spec.UTSNamespace {
|
||||
privateUTS = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return privateUTS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user