Skip to content

Commit e8d2718

Browse files
jfroysoharaa
authored andcommitted
ldconfig: Determine container "debian-ness" after root pivot
Signed-off-by: Evan Lezar <[email protected]> (cherry picked from commit d0251ab)
1 parent 70893c4 commit e8d2718

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

internal/ldconfig/ldconfig.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ func NewFromArgs(args ...string) (*Ldconfig, error) {
9898
}
9999

100100
l := &Ldconfig{
101-
ldconfigPath: *ldconfigPath,
102-
inRoot: *containerRoot,
103-
isDebianLikeHost: *isDebianLikeHost,
104-
isDebianLikeContainer: isDebian(),
105-
directories: fs.Args(),
101+
ldconfigPath: *ldconfigPath,
102+
inRoot: *containerRoot,
103+
isDebianLikeHost: *isDebianLikeHost,
104+
directories: fs.Args(),
106105
}
107106
return l, nil
108107
}
@@ -113,6 +112,9 @@ func (l *Ldconfig) UpdateLDCache() error {
113112
return err
114113
}
115114

115+
// `prepareRoot` pivots to the container root, so can now set the container "debian-ness".
116+
l.isDebianLikeContainer = isDebian()
117+
116118
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
117119
// be configured to use a different config file by default.
118120
const topLevelLdsoconfFilePath = "/etc/ld.so.conf"
@@ -224,7 +226,7 @@ func createLdsoconfdFile(pattern string, dirs ...string) error {
224226
// files that refer to the directory.
225227
func (l *Ldconfig) getLdsoconfDirectories(configFilePath string) (map[string]struct{}, error) {
226228
ldconfigDirs := make(map[string]struct{})
227-
for _, d := range l.getSystemSerachPaths() {
229+
for _, d := range l.getSystemSearchPaths() {
228230
ldconfigDirs[d] = struct{}{}
229231
}
230232

@@ -253,7 +255,7 @@ func (l *Ldconfig) getLdsoconfDirectories(configFilePath string) (map[string]str
253255
return ldconfigDirs, nil
254256
}
255257

256-
func (l *Ldconfig) getSystemSerachPaths() []string {
258+
func (l *Ldconfig) getSystemSearchPaths() []string {
257259
if l.isDebianLikeContainer {
258260
return debianSystemSearchPaths()
259261
}

0 commit comments

Comments
 (0)