namespaces: nsenter: ignore nonexistent namespaces
If a particular kernel doesn't have namespace directories that libcontainer tries to attain during nsenter(), ignore the error (this is consistent with the previous implementation of nsenter()). Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
This commit is contained in:
parent
16f939a958
commit
01a7f19afe
|
@ -135,6 +135,10 @@ void nsenter() {
|
||||||
snprintf(buf, PATH_MAX - 1, "%s%s", ns_dir, namespaces[i]);
|
snprintf(buf, PATH_MAX - 1, "%s%s", ns_dir, namespaces[i]);
|
||||||
int fd = open(buf, O_RDONLY);
|
int fd = open(buf, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
// Ignore nonexistent namespaces.
|
||||||
|
if (errno == ENOENT)
|
||||||
|
continue;
|
||||||
|
|
||||||
fprintf(stderr, "nsenter: Failed to open ns file \"%s\" for ns \"%s\" with error: \"%s\"\n", buf, namespaces[i], strerror(errno));
|
fprintf(stderr, "nsenter: Failed to open ns file \"%s\" for ns \"%s\" with error: \"%s\"\n", buf, namespaces[i], strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue