|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] libs/light: make it build without setresuid()
From: Manuel Bouyer <bouyer@xxxxxxxxxx>
NetBSD doesn't have setresuid(). Add a configure check for it,
and use plain setuid() if !HAVE_SETRESUID
Signed-off-by: Manuel Bouyer <bouyer@xxxxxxxxxx>
---
tools/configure | 13 +++++++++++++
tools/configure.ac | 3 +++
tools/libs/light/libxl_dm.c | 10 ++++++++++
3 files changed, 26 insertions(+)
diff --git a/tools/configure b/tools/configure
index 131112c41e..5e3793709e 100755
--- a/tools/configure
+++ b/tools/configure
@@ -9299,6 +9299,19 @@ _ACEOF
esac
+# NetBSD doesnt have setresuid (yet)
+for ac_func in setresuid
+do :
+ ac_fn_c_check_func "$LINENO" "setresuid" "ac_cv_func_setresuid"
+if test "x$ac_cv_func_setresuid" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SETRESUID 1
+_ACEOF
+
+fi
+done
+
+
# Checks for header files.
for ac_header in yajl/yajl_version.h sys/eventfd.h valgrind/memcheck.h utmp.h
do :
diff --git a/tools/configure.ac b/tools/configure.ac
index ee8ba5ff24..04f78bf21d 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -457,6 +457,9 @@ AC_CHECK_DECLS([fdt_first_subnode,
fdt_next_subnode],,,[#include <libfdt.h>])
AC_CHECK_DECLS([fdt_property_u32],,,[#include <libfdt.h>])
esac
+# NetBSD doesnt have setresuid (yet)
+AC_CHECK_FUNCS([setresuid])
+
# Checks for header files.
AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h valgrind/memcheck.h
utmp.h])
diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 8866c3f5ad..7651429b9f 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -3653,6 +3653,7 @@ static int
kill_device_model_uid_child(libxl__destroy_devicemodel_state *ddms,
assert(reaper_uid);
assert(dm_kill_uid);
+#if HAVE_SETRESUID
LOGD(DEBUG, domid, "DM reaper: calling setresuid(%d, %d, 0)",
reaper_uid, dm_kill_uid);
r = setresuid(reaper_uid, dm_kill_uid, 0);
@@ -3662,6 +3663,15 @@ static int
kill_device_model_uid_child(libxl__destroy_devicemodel_state *ddms,
rc = rc ?: ERROR_FAIL;
goto out;
}
+#else /* HAVE_SETRESUID */
+ LOGD(DEBUG, domid, "DM reaper: calling setuid(%d)", dm_kill_uid);
+ r = setuid(dm_kill_uid);
+ if (r) {
+ LOGED(ERROR, domid, "setuid to %d", dm_kill_uid);
+ rc = rc ?: ERROR_FAIL;
+ goto out;
+ }
+#endif /* HAVE_SETRESUID */
/*
* And kill everyone but me.
--
2.29.2
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |