Skip to content

Commit af186a1

Browse files
authored
moby-engine: remove daemon.json with backported fix (#9551)
1 parent a455a7e commit af186a1

4 files changed

Lines changed: 91 additions & 11 deletions

File tree

SPECS/moby-engine/daemon.json

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
From f8c088be055b72e58005ef9e56cf4f4008bbc5dd Mon Sep 17 00:00:00 2001
2+
From: Brian Goff <cpuguy83@gmail.com>
3+
Date: Tue, 7 May 2024 21:55:36 +0000
4+
Subject: [PATCH] Lookup docker-proxy in libexec paths
5+
6+
This allows distros to put docker-proxy under libexec paths as is done
7+
for docker-init.
8+
9+
Also expands the lookup to to not require a `docker/` subdir in libexec
10+
subdir.
11+
Since it is a generic helper that may be used for something else in the
12+
future, this is only done for binaries with a `docker-`.
13+
14+
Backported to moby 24.0.9 for AZL 2.0
15+
16+
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
17+
Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
18+
19+
diff -Naur a/daemon/config/config_linux.go b/daemon/config/config_linux.go
20+
--- a/daemon/config/config_linux.go 2024-02-01 00:12:23.000000000 +0000
21+
+++ b/daemon/config/config_linux.go 2024-06-25 18:18:00.929394951 +0000
22+
@@ -5,6 +5,7 @@
23+
"net"
24+
"os/exec"
25+
"path/filepath"
26+
+ "strings"
27+
28+
"github.com/containerd/cgroups/v3"
29+
"github.com/docker/docker/api/types"
30+
@@ -118,14 +119,13 @@
31+
return DefaultInitBinary
32+
}
33+
34+
-// LookupInitPath returns an absolute path to the "docker-init" binary by searching relevant "libexec" directories (per FHS 3.0 & 2.3) followed by PATH
35+
-func (conf *Config) LookupInitPath() (string, error) {
36+
- binary := conf.GetInitPath()
37+
+// lookupBinPath returns an absolute path to the provided binary by searching relevant "libexec" locations (per FHS 3.0 & 2.3) followed by PATH
38+
+func lookupBinPath(binary string) (string, error) {
39+
if filepath.IsAbs(binary) {
40+
return binary, nil
41+
}
42+
43+
- for _, dir := range []string{
44+
+ lookupPaths := []string{
45+
// FHS 3.0: "/usr/libexec includes internal binaries that are not intended to be executed directly by users or shell scripts. Applications may use a single subdirectory under /usr/libexec."
46+
// https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s07.html
47+
"/usr/local/libexec/docker",
48+
@@ -135,7 +135,16 @@
49+
// https://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#USRLIBLIBRARIESFORPROGRAMMINGANDPA
50+
"/usr/local/lib/docker",
51+
"/usr/lib/docker",
52+
- } {
53+
+ }
54+
+
55+
+ // According to FHS 3.0, it is not necessary to have a subdir here (see note and reference above).
56+
+ // If the binary has a `docker-` prefix, let's look it up without the dir prefix.
57+
+ if strings.HasPrefix(binary, "docker-") {
58+
+ lookupPaths = append(lookupPaths, "/usr/local/libexec")
59+
+ lookupPaths = append(lookupPaths, "/usr/libexec")
60+
+ }
61+
+
62+
+ for _, dir := range lookupPaths {
63+
// exec.LookPath has a fast-path short-circuit for paths that contain "/" (skipping the PATH lookup) that then verifies whether the given path is likely to be an actual executable binary (so we invoke that instead of reimplementing the same checks)
64+
if file, err := exec.LookPath(filepath.Join(dir, binary)); err == nil {
65+
return file, nil
66+
@@ -146,6 +155,11 @@
67+
return exec.LookPath(binary)
68+
}
69+
70+
+// LookupInitPath returns an absolute path to the "docker-init" binary by searching relevant "libexec" directories (per FHS 3.0 & 2.3) followed by PATH
71+
+func (conf *Config) LookupInitPath() (string, error) {
72+
+ return lookupBinPath(conf.GetInitPath())
73+
+}
74+
+
75+
// GetResolvConf returns the appropriate resolv.conf
76+
// Check setupResolvConf on how this is selected
77+
func (conf *Config) GetResolvConf() string {
78+
@@ -214,7 +228,7 @@
79+
80+
var err error
81+
// use rootlesskit-docker-proxy for exposing the ports in RootlessKit netns to the initial namespace.
82+
- cfg.BridgeConfig.UserlandProxyPath, err = exec.LookPath(rootless.RootlessKitDockerProxyBinary)
83+
+ cfg.BridgeConfig.UserlandProxyPath, err = lookupBinPath(rootless.RootlessKitDockerProxyBinary)
84+
if err != nil {
85+
return errors.Wrapf(err, "running with RootlessKit, but %s not installed", rootless.RootlessKitDockerProxyBinary)
86+
}

SPECS/moby-engine/moby-engine.signatures.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"Signatures": {
3-
"daemon.json": "532f2e930400baed129ed953b9ba0d5158fc443aecbff6f6513f58565696db5c",
43
"docker.service": "b150b3ce0947a65c655ed09dfe4e48b7464c60542f9f9902330288bbf87af38e",
54
"docker.socket": "51a06786cae46bc63b7314c25d0bd5bb2e676120d80874b99e35bf60d0b0ffa8",
65
"moby-engine-24.0.9.tar.gz": "c498c4aa45d208d3af5fc9be3fb0d60f3fac6d710077c0557e217f7f80fd6c96"

SPECS/moby-engine/moby-engine.spec

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Summary: The open-source application container engine
44
Name: moby-engine
55
Version: 24.0.9
6-
Release: 5%{?dist}
6+
Release: 6%{?dist}
77
License: ASL 2.0
88
Group: Tools/Container
99
URL: https://mobyproject.org
@@ -13,7 +13,6 @@ Distribution: Mariner
1313
Source0: https://github.com/moby/moby/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
1414
Source1: docker.service
1515
Source2: docker.socket
16-
Source3: daemon.json
1716
# Backport of vendored "buildkit" v0.12.5 https://github.com/moby/buildkit/pull/4604 to 0.8.4-0.20221020190723-eeb7b65ab7d6 in this package.
1817
# Remove once we upgrade this package at least to version 25.0+.
1918
Patch1: CVE-2024-23651.patch
@@ -22,6 +21,7 @@ Patch1: CVE-2024-23651.patch
2221
Patch2: CVE-2024-23652.patch
2322
Patch3: CVE-2023-45288.patch
2423
Patch4: CVE-2023-44487.patch
24+
Patch5: enable-docker-proxy-libexec-search.patch
2525

2626
%{?systemd_requires}
2727

@@ -100,9 +100,6 @@ mkdir -p %{buildroot}%{_unitdir}
100100
install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/docker.service
101101
install -p -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/docker.socket
102102

103-
mkdir -p -m 755 %{buildroot}%{_sysconfdir}/docker
104-
install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/docker/daemon.json
105-
106103
%post
107104
if ! grep -q "^docker:" /etc/group; then
108105
groupadd --system docker
@@ -121,12 +118,13 @@ fi
121118
# docker-proxy symlink in bindir to fix back-compat
122119
%{_bindir}/docker-proxy
123120
%{_libexecdir}/docker-proxy
124-
%dir %{_sysconfdir}/docker
125-
%config(noreplace) %{_sysconfdir}/docker/daemon.json
126121
%{_sysconfdir}/*
127122
%{_unitdir}/*
128123

129124
%changelog
125+
* Tue Jun 25 2024 Henry Beberman <henry.beberman@microsoft.com> - 24.0.9-6
126+
- Backport upstream change to search /usr/libexec for docker-proxy without daemon.json
127+
130128
* Thu Jun 06 2024 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 24.0.9-5
131129
- Bump release to rebuild with go 1.21.11
132130

0 commit comments

Comments
 (0)