From: Stéphane Graber Date: Tue, 11 Feb 2014 22:40:20 +0000 (-0500) Subject: Add --with-runtime-path to configure X-Git-Tag: lxc-1.0.0.rc1~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=061ba5d071e4c2b4bfe76c84875bc29cc5334c27;p=thirdparty%2Flxc.git Add --with-runtime-path to configure This allows older distros to override /run with whatever their own path is, mostly useful for old RedHat and possibly Android. Reported-by: Robert Vogelgesang Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/config/init/upstart/lxc-net.conf b/config/init/upstart/lxc-net.conf index 3ae3e95c3..86e9a719f 100644 --- a/config/init/upstart/lxc-net.conf +++ b/config/init/upstart/lxc-net.conf @@ -12,7 +12,7 @@ env LXC_NETWORK="10.0.3.0/24" env LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" env LXC_DHCP_MAX="253" env LXC_DHCP_CONFILE="" -env varrun="/var/run/lxc" +env varrun="/run/lxc" env LXC_DOMAIN="" pre-start script diff --git a/configure.ac b/configure.ac index b07ac143b..5346ba243 100644 --- a/configure.ac +++ b/configure.ac @@ -397,6 +397,13 @@ AC_ARG_ENABLE([tests], [], [enable_tests=no]) AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"]) +# Allow overriding the default runtime dir (/run) +AC_ARG_WITH([runtime-path], + [AC_HELP_STRING( + [--with-runtime-path=dir], + [runtime directory (default: /run)] + )], [], [with_runtime_path=['/run']]) + # LXC container path, where the containers are actually stored # This is overridden by an entry in the file called LXCCONF # (i.e. /etc/lxc/lxc.conf) @@ -425,7 +432,7 @@ AC_ARG_WITH([usernic-db], [AC_HELP_STRING( [--with-usernic-db], [lxc user nic database] - )], [], [with_usernic_db=['/run/lxc/nics']]) + )], [], [with_usernic_db=['$(with_runtime_path)/lxc/nics']]) # Rootfs path, where the container mount structure is assembled AC_ARG_WITH([rootfs-path], @@ -484,6 +491,7 @@ AS_AC_EXPAND(LXCTEMPLATECONFIG, "$datadir/lxc/config") AS_AC_EXPAND(LXCHOOKDIR, "$datadir/lxc/hooks") AS_AC_EXPAND(LXCINITDIR, "$libexecdir") AS_AC_EXPAND(LOGPATH, "$with_log_path") +AS_AC_EXPAND(RUNTIME_PATH, "$with_runtime_path") AC_SUBST(DEFAULT_CGROUP_PATTERN, ["$with_cgroup_pattern"]) # Check for some standard kernel headers diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index c6ef8f59e..e69c9a653 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -120,7 +120,8 @@ AM_CFLAGS=-I$(top_srcdir)/src \ -DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" \ -DLXC_USERNIC_DB=\"$(LXC_USERNIC_DB)\" \ -DLXC_USERNIC_CONF=\"$(LXC_USERNIC_CONF)\" \ - -DDEFAULT_CGROUP_PATTERN=\"$(DEFAULT_CGROUP_PATTERN)\" + -DDEFAULT_CGROUP_PATTERN=\"$(DEFAULT_CGROUP_PATTERN)\" \ + -DRUNTIME_PATH=\"$(RUNTIME_PATH)\" if ENABLE_APPARMOR AM_CFLAGS += -DHAVE_APPARMOR diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 411917e0f..b7a29cb39 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -382,7 +382,7 @@ const char *get_rundir() rundir = getenv("XDG_RUNTIME_DIR"); if (geteuid() == 0 || rundir == NULL) - rundir = "/run"; + rundir = RUNTIME_PATH; return rundir; } diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index bd1f8cea0..de1f7e696 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -28,7 +28,8 @@ AM_CFLAGS=-I$(top_srcdir)/src \ -DLXCPATH=\"$(LXCPATH)\" \ -DLXC_GLOBAL_CONF=\"$(LXC_GLOBAL_CONF)\" \ -DLXCINITDIR=\"$(LXCINITDIR)\" \ - -DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" + -DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" \ + -DRUNTIME_PATH=\"$(RUNTIME_PATH)\" if ENABLE_APPARMOR AM_CFLAGS += -DHAVE_APPARMOR diff --git a/src/tests/locktests.c b/src/tests/locktests.c index c3f5352ce..2d04052a2 100644 --- a/src/tests/locktests.c +++ b/src/tests/locktests.c @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "lxc/lxclock.h" +#include "config.h" #include #include #include @@ -121,10 +122,7 @@ int main(int argc, char *argv[]) exit(1); } struct stat sb; - // we don't create the file until the container is running, so this - // bit of the test needs to be changed - //char *pathname = "/run/lock/lxc/var/lib/lxc/" mycontainername; - char *pathname = "/run/lock/lxc/var/lib/lxc/"; + char *pathname = RUNTIME_PATH "/lock/lxc/var/lib/lxc/"; ret = stat(pathname, &sb); if (ret != 0) { fprintf(stderr, "%d: filename %s not created\n", __LINE__, diff --git a/src/tests/lxc-test-unpriv b/src/tests/lxc-test-unpriv index d9a5c5c57..9e3fe211d 100755 --- a/src/tests/lxc-test-unpriv +++ b/src/tests/lxc-test-unpriv @@ -21,6 +21,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# This test assumes an Ubuntu host + if [ $(id -u) -ne 0 ]; then echo 'run as root' exit 1 @@ -34,7 +36,7 @@ cleanup() { run_cmd lxc-stop -n c1 -k pkill -u $(id -u $TUSER) -9 - sed -i '/lxcunpriv/d' /var/run/lxc/nics /etc/lxc/lxc-usernet + sed -i '/lxcunpriv/d' /run/lxc/nics /etc/lxc/lxc-usernet sed -i '/^lxcunpriv:/d' /etc/subuid /etc/subgid rm -Rf $HDIR /run/user/$(id -u $TUSER) diff --git a/src/tests/lxc-test-usernic.in b/src/tests/lxc-test-usernic.in index 846e592b1..4f96d2eae 100755 --- a/src/tests/lxc-test-usernic.in +++ b/src/tests/lxc-test-usernic.in @@ -21,6 +21,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# This test assumes an Ubuntu host + DONE=0 LXC_USER_NIC="@LIBEXECDIR@/lxc/lxc-user-nic" @@ -31,7 +33,7 @@ cleanup() { lxc-stop -n usernic-c1 -k lxc-destroy -n usernic-c1 - sed -i '/usernic-user/d' /var/run/lxc/nics /etc/lxc/lxc-usernet + sed -i '/usernic-user/d' /run/lxc/nics /etc/lxc/lxc-usernet ifconfig usernic-br0 down ifconfig usernic-br1 down brctl delbr usernic-br0