Skip to content

Commit 776414c

Browse files
authored
Merge pull request #6412 from DrDaveD/apptainer322
Preload NSS libraries prior to mount namespace creation (or join) and pivot_root
2 parents ff99f2f + 68fa114 commit 776414c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
- Remove python as a dependency of the debian package.
1111
- Increased the TLS Handshake Timeout for the busybox bootstrap agent in
1212
build definition files to 60 seconds.
13+
- Preload NSS libraries prior to mountspace name creation to avoid
14+
circumstances that can cause loading those libraries from the
15+
container image instead of the host, for example in the startup
16+
environment.
1317

1418
## v3.8.6 - [2022-02-08]
1519

cmd/starter/c/starter.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string.h>
1818
#include <fcntl.h>
1919
#include <poll.h>
20+
#include <pwd.h>
2021
#include <grp.h>
2122
#include <link.h>
2223
#include <dirent.h>
@@ -1384,6 +1385,20 @@ __attribute__((constructor)) static void init(void) {
13841385
}
13851386
}
13861387

1388+
/*
1389+
* preload and cache of nss libraries for os/user golang CGO implementation,
1390+
* when libraries are not loaded prior to pivot_root in the container mount
1391+
* namespace, they are loaded from the container image when the stage 2 process
1392+
* is calling os/user golang package, and it might cause compatibility issues with
1393+
* the host libc library used by this starter binary.
1394+
*/
1395+
if (getpwuid(0) == NULL) {
1396+
fatalf("Failed to retrieve root user information: %s\n", strerror(errno));
1397+
}
1398+
if (getgrgid(0) == NULL) {
1399+
fatalf("Failed to retrieve root group information: %s\n", strerror(errno));
1400+
}
1401+
13871402
userns = user_namespace_init(&sconfig->container.namespace);
13881403
switch ( userns ) {
13891404
case NO_NAMESPACE:

e2e/testdata/regressions/issue_4203.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ bootstrap: docker
3939
from: ubuntu:16.04
4040
stage: final
4141

42+
%environment
43+
# to trigger the regression from https://github.com/apptainer/apptainer/issues/304
44+
cd /usr
45+
4246
%files from build
4347
/bad.so /lib/x86_64-linux-gnu/libnss_bad.so.2
4448
/nsswitch.conf /etc/nsswitch.conf

0 commit comments

Comments
 (0)