From c8c6482c42e22dccf78f61bc8fb47cf2fbd6d9db Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Tue, 24 Nov 2015 13:30:48 +0000 Subject: [PATCH] disk: Ensure we use the explicit path to resize2fs On some configurations, /sbin and /usr/sbin may not even be in the $PATH, meaning that the configure routine would fail if this is where resize2fs lives. Secondly, we must ensure that disks now uses this explicit path. This ensures correct functionality during non privileged testing, and consistency with installed behaviour. Signed-off-by: Ikey Doherty --- configure.ac | 6 ++++-- src/disk.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3bf0814..5778a8d 100644 --- a/configure.ac +++ b/configure.ac @@ -48,10 +48,12 @@ AS_IF([test "x$enable_debug" = "xyes"], AM_CONDITIONAL([DEBUG], [test x$enable_debug = x"yes"]) # Checks for commands -AC_CHECK_PROG([RESIZE2FS], [resize2fs], [yes]) -if test x"$RESIZE2FS" != x"yes" ; then +AC_PATH_PROG([RESIZE2FS], [resize2fs], [no], [$PATH:/sbin:/usr/sbin]) +if test x"$RESIZE2FS" == x"no" ; then AC_MSG_ERROR([Please install resize2fs.]) fi +AC_SUBST(RESIZE2FS) +AC_DEFINE_UNQUOTED([RESIZEFS_PATH], ["$RESIZE2FS"], [Path to resize2fs binary]) # Options AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], diff --git a/src/disk.c b/src/disk.c index c7c680b..2129abb 100644 --- a/src/disk.c +++ b/src/disk.c @@ -32,6 +32,9 @@ files in the program, then also delete it here. ***/ +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif #include @@ -178,7 +181,7 @@ gboolean disk_resize_grow(const gchar* disk_path) { } //FIXME using libparted algorithms - snprintf(command, LINE_MAX, "resize2fs %s", partition_path); + snprintf(command, LINE_MAX, RESIZEFS_PATH " %s", partition_path); exec_task(command); result = true;