From c43dd7b50dd64ae9789da0e168a500f55171b366 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 12 Jun 2014 13:09:04 -0400 Subject: [PATCH] nsenter: fix setns() for rhel6 (glibc-2.12) Docker-DCO-1.1-Signed-off-by: Vincent Batts (github: vbatts) --- namespaces/nsenter.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/namespaces/nsenter.go b/namespaces/nsenter.go index d5c2e761b..80cb0b4e8 100644 --- a/namespaces/nsenter.go +++ b/namespaces/nsenter.go @@ -49,6 +49,16 @@ void get_args(int *argc, char ***argv) { (*argv)[*argc] = NULL; } +// Use raw setns syscall for versions of glibc that don't include it (namely glibc-2.12) +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 14 && defined(SYS_setns) +#define _GNU_SOURCE +#include +#include "syscall.h" +int setns(int fd, int nstype) { + return syscall(SYS_setns, fd, nstype); +} +#endif + void nsenter() { int argc; char **argv;