[lxc-devel] [PATCH] Add --with-runtime-path to configure
Stéphane Graber
stgraber at ubuntu.com
Tue Feb 11 22:50:41 UTC 2014
This allows older distros to override /run with whatever their own path
is, mostly useful for old RedHat and possibly Android.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
config/init/upstart/lxc-net.conf | 2 +-
configure.ac | 10 +++++++++-
src/lxc/Makefile.am | 3 ++-
src/lxc/utils.c | 2 +-
src/tests/Makefile.am | 3 ++-
src/tests/locktests.c | 6 ++----
src/tests/lxc-test-unpriv | 4 +++-
src/tests/lxc-test-usernic.in | 4 +++-
8 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/config/init/upstart/lxc-net.conf b/config/init/upstart/lxc-net.conf
index 3ae3e95..86e9a71 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 b07ac14..5346ba2 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 c6ef8f5..e69c9a6 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 411917e..b7a29cb 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 bd1f8ce..de1f7e6 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 c3f5352..2d04052 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 <unistd.h>
#include <signal.h>
#include <stdio.h>
@@ -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 d9a5c5c..9e3fe21 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 846e592..4f96d2e 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
--
1.9.rc1
More information about the lxc-devel
mailing list