Richard W.M. Jones
2012-Feb-06 15:48 UTC
[Libguestfs] [PATCH] build: Choose a virtual directory for the daemon which is not a symlink.
From: "Richard W.M. Jones" <rjones at redhat.com>
Check /sbin, /usr/sbin, /bin and /usr/bin to ensure that neither the
directory nor the parent (eg. /usr) is a symlink, and use this
directory for the virtual directory used to store guestfsd in the
appliance.
---
appliance/Makefile.am | 9 +++++----
configure.ac | 20 ++++++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 99896be..fcf6422 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -67,10 +67,11 @@ stamp-supermin: make.sh packagelist excludelist
supermin.d/daemon.img: ../daemon/guestfsd
mkdir -p supermin.d
rm -f $@ $@-t
- mkdir sbin
- cd sbin && ln ../../daemon/guestfsd
- echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $@-t
- rm -r sbin
+ rm -rf tmp
+ mkdir -p tmp/$(DAEMON_SUPERMIN_DIR)
+ cd tmp/$(DAEMON_SUPERMIN_DIR) && ln
$(abs_top_builddir)/daemon/guestfsd
+ ( cd tmp && find | cpio --quiet -o -H newc ) > $@-t
+ rm -rf tmp
mv $@-t $@
supermin.d/init.img: init
diff --git a/configure.ac b/configure.ac
index 5caca32..3712d19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,6 +278,26 @@ if test "x$enable_daemon" = "xyes";
then
AC_DEFINE([VALGRIND_DAEMON],[1],[Define to 1 to run the daemon
under valgrind])
AC_DEFINE_UNQUOTED([VALGRIND_LOG_PATH],["$(pwd)"],[Path
to save valgrind log files])
fi
+
+ dnl Which directory should we put the daemon in? NOTE: This
+ dnl is the "virtual" directory inside the appliance, not the
+ dnl install directory for libguestfs live. Since Fedora 17
+ dnl /sbin is a symlink to /usr/sbin. We have to put the
+ dnl daemon into a real (non-symlink) directory.
+ dirs="/sbin /usr/sbin /bin /usr/bin"
+ AC_MSG_CHECKING([which of $dirs is a real directory])
+ for dir in $dirs; do
+ parent=`dirname $dir`
+ if test -d $parent && test -d $dir; then
+ DAEMON_SUPERMIN_DIR=$dir
+ break
+ fi
+ done
+ if test "x$DAEMON_SUPERMIN_DIR" = "x"; then
+ AC_MSG_ERROR([non-symlink binary directory not found])
+ fi
+ AC_MSG_RESULT([$DAEMON_SUPERMIN_DIR])
+ AC_SUBST([DAEMON_SUPERMIN_DIR])
fi
AM_CONDITIONAL([INSTALL_DAEMON],[test "x$enable_install_daemon" =
"xyes"])
AM_CONDITIONAL([VALGRIND_DAEMON],[test "x$enable_valgrind_daemon" =
"xyes"])
--
1.7.6
Richard W.M. Jones
2012-Feb-06 15:55 UTC
[Libguestfs] [PATCH] build: Choose a virtual directory for the daemon which is not a symlink.
Sorry, ignore this patch, it is broken. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Richard W.M. Jones
2012-Feb-06 16:11 UTC
[Libguestfs] [PATCH] build: Choose a virtual directory for the daemon which is not a symlink.
From: "Richard W.M. Jones" <rjones at redhat.com>
Check /sbin, /usr/sbin, /bin and /usr/bin to ensure that neither the
directory nor the parent (eg. /usr) is a symlink, and use this
directory for the virtual directory used to store guestfsd in the
appliance.
---
appliance/Makefile.am | 9 +++++----
configure.ac | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 99896be..fcf6422 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -67,10 +67,11 @@ stamp-supermin: make.sh packagelist excludelist
supermin.d/daemon.img: ../daemon/guestfsd
mkdir -p supermin.d
rm -f $@ $@-t
- mkdir sbin
- cd sbin && ln ../../daemon/guestfsd
- echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $@-t
- rm -r sbin
+ rm -rf tmp
+ mkdir -p tmp/$(DAEMON_SUPERMIN_DIR)
+ cd tmp/$(DAEMON_SUPERMIN_DIR) && ln
$(abs_top_builddir)/daemon/guestfsd
+ ( cd tmp && find | cpio --quiet -o -H newc ) > $@-t
+ rm -rf tmp
mv $@-t $@
supermin.d/init.img: init
diff --git a/configure.ac b/configure.ac
index 5caca32..019f7e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,6 +278,28 @@ if test "x$enable_daemon" = "xyes";
then
AC_DEFINE([VALGRIND_DAEMON],[1],[Define to 1 to run the daemon
under valgrind])
AC_DEFINE_UNQUOTED([VALGRIND_LOG_PATH],["$(pwd)"],[Path
to save valgrind log files])
fi
+
+ dnl Which directory should we put the daemon in? NOTE: This
+ dnl is the "virtual" directory inside the appliance, not the
+ dnl install directory for libguestfs live. Since Fedora 17
+ dnl /sbin is a symlink to /usr/sbin. We have to put the
+ dnl daemon into a real (non-symlink) directory.
+ dirs="/sbin /usr/sbin /bin /usr/bin"
+ AC_MSG_CHECKING([which of $dirs is a real directory])
+ for dir in $dirs; do
+ parent=`dirname $dir`
+ if test \! -L $parent && test -d $parent \
+ && test \! -L $dir && test -d $dir
+ then
+ DAEMON_SUPERMIN_DIR=$dir
+ break
+ fi
+ done
+ if test "x$DAEMON_SUPERMIN_DIR" = "x"; then
+ AC_MSG_ERROR([non-symlink binary directory not found])
+ fi
+ AC_MSG_RESULT([$DAEMON_SUPERMIN_DIR])
+ AC_SUBST([DAEMON_SUPERMIN_DIR])
fi
AM_CONDITIONAL([INSTALL_DAEMON],[test "x$enable_install_daemon" =
"xyes"])
AM_CONDITIONAL([VALGRIND_DAEMON],[test "x$enable_valgrind_daemon" =
"xyes"])
--
1.7.6
Possibly Parallel Threads
- [PATCH v2 1/9] build: Remove ./configure --enable-valgrind-daemon.
- [PATCH] [repost] build: Remove ./configure --enable-valgrind-daemon.
- [PATCH] Enable running the daemon under valgrind.
- [PATCH 00/14] Run the daemon under valgrind and fix resultant errors.
- [PATCH 0/7] Better testing of the guestfsd daemon.