]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix compilation on toolchain without prlimit
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Thu, 2 Nov 2017 15:00:33 +0000 (16:00 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 8 Nov 2017 23:58:12 +0000 (00:58 +0100)
Some toolchains which are not bionic like uclibc does not support
prlimit or prlimit64. In this case, return an error.
Moreover, if prlimit64 is available, use lxc implementation of prlimit.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
configure.ac
src/lxc/Makefile.am
src/lxc/conf.c

index 5566d2986266a9d6b92d77799da4b4861456c710..5db3b3570028d951cfa4e986033ac4ada2a9110a 100644 (file)
@@ -671,6 +671,10 @@ AC_CHECK_FUNCS([prlimit],
        AM_CONDITIONAL(HAVE_PRLIMIT, true)
        AC_DEFINE(HAVE_PRLIMIT,1,[Have prlimit]),
        AM_CONDITIONAL(HAVE_PRLIMIT, false))
+AC_CHECK_FUNCS([prlimit64],
+       AM_CONDITIONAL(HAVE_PRLIMIT64, true)
+       AC_DEFINE(HAVE_PRLIMIT64,1,[Have prlimit64]),
+       AM_CONDITIONAL(HAVE_PRLIMIT64, false))
 
 # Check for some libraries
 AC_SEARCH_LIBS(sem_open, [rt pthread])
index 9a429b8cfe95b4310b54a7dec2e341238ac1d82f..80ac3568050e3b45311e9d53ddc7882c6ed86490 100644 (file)
@@ -45,7 +45,10 @@ noinst_HEADERS += \
        ../include/ifaddrs.h \
        ../include/openpty.h \
        ../include/lxcmntent.h
+endif
+
 if !HAVE_PRLIMIT
+if HAVE_PRLIMIT64
 noinst_HEADERS += ../include/prlimit.h
 endif
 endif
@@ -142,7 +145,10 @@ liblxc_la_SOURCES += \
        ../include/ifaddrs.c ../include/ifaddrs.h \
        ../include/openpty.c ../include/openpty.h \
        ../include/lxcmntent.c ../include/lxcmntent.h
+endif
+
 if !HAVE_PRLIMIT
+if HAVE_PRLIMIT64
 liblxc_la_SOURCES += ../include/prlimit.c ../include/prlimit.h
 endif
 endif
index 264f819cade8f99716cbfc9993e6f63a2163d985..7a74eb4b2461a3098b1869a3fb377340d9982ac9 100644 (file)
 
 #if IS_BIONIC
 #include <../include/lxcmntent.h>
-#ifndef HAVE_PRLIMIT
-#include <../include/prlimit.h>
-#endif
 #else
 #include <mntent.h>
 #endif
 
+#if !defined(HAVE_PRLIMIT) && defined(HAVE_PRLIMIT64)
+#include <../include/prlimit.h>
+#endif
+
 lxc_log_define(lxc_conf, lxc);
 
 #if HAVE_LIBCAP
@@ -2397,10 +2398,15 @@ int setup_resource_limits(struct lxc_list *limits, pid_t pid) {
                        return -1;
                }
 
+#if HAVE_PRLIMIT || HAVE_PRLIMIT64
                if (prlimit(pid, resid, &lim->limit, NULL) != 0) {
                        ERROR("failed to set limit %s: %s", lim->resource, strerror(errno));
                        return -1;
                }
+#else
+               ERROR("Cannot set limit %s as prlimit is missing", lim->resource);
+               return -1;
+#endif
        }
        return 0;
 }