[Spice-commits] 5 commits - configure.ac gtk/Makefile.am gtk/spice-client-glib-usb-acl-helper.c
Hans de Goede
jwrdegoede at kemper.freedesktop.org
Sat Jan 28 01:42:16 PST 2012
configure.ac | 56 +++++++++++++++++++++++++--------
gtk/Makefile.am | 2 +
gtk/spice-client-glib-usb-acl-helper.c | 17 +++++++++-
3 files changed, 61 insertions(+), 14 deletions(-)
New commits:
commit 0f552545e9cde94d19739c82feeaa4f1dcc2f515
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Jan 27 16:57:02 2012 +0100
spice-client-glib-usb-acl-helper: ensure we set the acl on a chardev
Josh Bressers has been so kind to review the usb-acl-helper for possible
security issues. One of his recomendations was to ensure that the file
we're setting the acl on is a chardev.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 24da23e..c03982a 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
- Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2011,2012 Red Hat, Inc.
Copyright (C) 2009 Kay Sievers <kay.sievers at vrfy.org>
Red Hat Authors:
@@ -29,6 +29,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <gio/gunixinputstream.h>
#include <polkit/polkit.h>
#include <acl/libacl.h>
@@ -163,6 +166,7 @@ static void check_authorization_cb(PolkitAuthority *authority,
{
PolkitAuthorizationResult *result;
GError *err = NULL;
+ struct stat stat_buf;
g_clear_object(&polkit_cancellable);
@@ -179,6 +183,16 @@ static void check_authorization_cb(PolkitAuthority *authority,
}
snprintf(path, PATH_MAX, "/dev/bus/usb/%03d/%03d", busnum, devnum);
+
+ if (stat(path, &stat_buf) != 0) {
+ FATAL_ERROR("statting %s: %s\n", path, strerror(errno));
+ return;
+ }
+ if (!S_ISCHR(stat_buf.st_mode)) {
+ FATAL_ERROR("%s is not a character device\n", path);
+ return;
+ }
+
if (set_facl(path, getuid(), 1)) {
FATAL_ERROR("setting facl: %s\n", strerror(errno));
return;
commit f0ca21aeb2608fd847b15b77f79dc75498ccf187
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Jan 27 16:02:02 2012 +0100
spice-client-glib-usb-acl-helper: Fix memleak
Not really important given the short livedness of the process, but
still should be fixed.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 53f4e9a..24da23e 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -255,6 +255,7 @@ static void stdin_read_complete(GObject *src, GAsyncResult *res, gpointer data)
default:
FATAL_ERROR("Unexpected extra input in state %d: %s\n", state, s);
}
+ g_free(s);
}
/* Fix for polkit 0.97 and later */
commit bfa79f534ad3c85e95e17bbe86c44f17e193357e
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Jan 27 10:45:59 2012 +0100
configure: Add an option for building the acl helper as PIE
Josh Bressers has been so kind to review the usb-acl-helper for possible
security issues. One of his recomendations was to harden the usb-acl-helper
by building it as a Position Independent Executable.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/configure.ac b/configure.ac
index 2b73fc1..470f714 100644
--- a/configure.ac
+++ b/configure.ac
@@ -390,6 +390,35 @@ if test "x$have_usbredir" = "xyes" && test "x$have_polkit" != "xyes"; then
AC_MSG_WARN([Building with usbredir support, but *not* building the usb acl helper])
fi
+AC_ARG_ENABLE([pie],
+ AS_HELP_STRING([--enable-pie=@<:@auto/yes/no@:>@],
+ [Enable position-independent-executable support (for the usb acl helper)@<:@default=auto@:>@]),
+ [],
+ [enable_pie="auto"])
+
+if test "x$have_polkit" = "xyes" && test "x$enable_pie" != "xno"; then
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -fPIE"
+ LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
+ AC_MSG_CHECKING([for PIE support])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])],
+ [have_pie=yes],
+ [have_pie=no])
+ AC_MSG_RESULT([$have_pie])
+ if test "x$have_pie" = "xno" && test "x$enable_pie" = "xyes"; then
+ AC_MSG_ERROR([pie support explicitly requested, but your toolchain does not support it])
+ fi
+ if test "x$have_pie" = "xyes"; then
+ PIE_CFLAGS="-fPIE"
+ PIE_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now"
+ AC_SUBST(PIE_CFLAGS)
+ AC_SUBST(PIE_LDFLAGS)
+ fi
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+fi
+
AC_ARG_WITH([usb-acl-helper-dir],
AS_HELP_STRING([--with-usb-acl-helper-dir=DIR],
[Directory where the USB ACL helper binary should be installed]),
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 6f39888..2cc0163 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -373,6 +373,7 @@ spice_client_glib_usb_acl_helper_LDADD = \
$(GIO_LIBS) \
$(POLKIT_LIBS) \
$(ACL_LIBS) \
+ $(PIE_LDFLAGS) \
$(NULL)
spice_client_glib_usb_acl_helper_CPPFLAGS = \
@@ -380,6 +381,7 @@ spice_client_glib_usb_acl_helper_CPPFLAGS = \
$(GLIB2_CFLAGS) \
$(GIO_CFLAGS) \
$(POLKIT_CFLAGS) \
+ $(PIE_CFLAGS) \
$(NULL)
install-data-hook:
commit f3f0e043a8b3732e06656fab6b81f2f9575ddad8
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Jan 27 10:11:25 2012 +0100
configure.ac: s/x"$have_foo"/"x$have_foo"/
configure.ac was using 2 slightly different styles for have_foo tests:
if test x"$have_foo" = "xyes"; then
and:
if test "x$have_foo" = "xyes"; then
Switch to the latter style everywhere for consistency.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/configure.ac b/configure.ac
index d7be7b2..2b73fc1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ SPICE_COMMON_SRCDIR='$(top_srcdir)'/common
AC_PROG_CC
AC_PROG_CC_C99
-if test x"$ac_cv_prog_cc_c99" = xno; then
+if test "x$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([C99 compiler is required.])
fi
@@ -347,13 +347,13 @@ else
[gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.3.3],
[have_usbredir=yes],
[have_usbredir=no])
- if test x"$have_usbredir" = "xno" && test x"$enable_usbredir" = "xyes"; then
+ if test "x$have_usbredir" = "xno" && test "x$enable_usbredir" = "xyes"; then
AC_MSG_ERROR([usbredir support explicitly requested, but some required packages are not available])
fi
- if test x"$have_usbredir" = "xyes"; then
+ if test "x$have_usbredir" = "xyes"; then
AC_DEFINE(USE_USBREDIR, [1], [Define if supporting usbredir proxying])
fi
- AM_CONDITIONAL([WITH_USBREDIR], [test x"$have_usbredir" = "xyes"])
+ AM_CONDITIONAL([WITH_USBREDIR], [test "x$have_usbredir" = "xyes"])
fi
AC_ARG_ENABLE([polkit],
@@ -362,21 +362,21 @@ AC_ARG_ENABLE([polkit],
[],
[enable_polkit="auto"])
-if test x"$have_usbredir" = "xyes" && test "x$enable_polkit" != "xno"; then
+if test "x$have_usbredir" = "xyes" && test "x$enable_polkit" != "xno"; then
PKG_CHECK_MODULES([POLKIT], [polkit-gobject-1 >= 0.96],
[have_polkit=yes],
[have_polkit=no])
AC_CHECK_HEADER([acl/libacl.h], [], [have_polkit=no])
AC_CHECK_LIB([acl], [acl_get_file], [ACL_LIBS=-lacl], [have_polkit=no])
- if test x"$enable_polkit" = "xyes" && test x"$have_polkit" = "xno"; then
+ if test "x$enable_polkit" = "xyes" && test "x$have_polkit" = "xno"; then
AC_MSG_ERROR([PolicyKit support explicitly requested, but some required packages are not available])
fi
- if test x"$have_polkit" = "xyes"; then
+ if test "x$have_polkit" = "xyes"; then
AC_SUBST(ACL_LIBS)
AC_DEFINE(USE_POLKIT, [1], [Define if supporting polkit])
fi
- AM_CONDITIONAL([WITH_POLKIT], [test x"$have_polkit" = "xyes"])
+ AM_CONDITIONAL([WITH_POLKIT], [test "x$have_polkit" = "xyes"])
POLICYDIR=`${PKG_CONFIG} polkit-gobject-1 --variable=policydir`
AC_SUBST(POLICYDIR)
# Check for polkit_authority_get_sync()
commit e51972922fbaec76c1e042a6876ba38aab3b3935
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Jan 27 10:06:13 2012 +0100
configure.ac: Cleanup policykit checks
* No need to set AM_CONDITIONAL WITH_POLKIT from the enable_usbredir tests, it
get sets from the enable_polkit tests in all paths
* Improve the help text: mention auto as option, policykit -> PolicyKit,
not yes but auto is the default
* Warn when building with usbredir support but not building the acl helper
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/configure.ac b/configure.ac
index 2cb4075..d7be7b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -342,7 +342,6 @@ AC_ARG_ENABLE([usbredir],
if test "x$enable_usbredir" = "xno"; then
AM_CONDITIONAL(WITH_USBREDIR, false)
- AM_CONDITIONAL(WITH_POLKIT, false)
else
PKG_CHECK_MODULES([USBREDIR],
[gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.3.3],
@@ -358,15 +357,14 @@ else
fi
AC_ARG_ENABLE([polkit],
- AS_HELP_STRING([--enable-polkit=@<:@yes/no@:>@],
- [Enable policykit support (for the usb acl helper)@<:@default=yes@:>@]),
+ AS_HELP_STRING([--enable-polkit=@<:@auto/yes/no@:>@],
+ [Enable PolicyKit support (for the usb acl helper)@<:@default=auto@:>@]),
[],
[enable_polkit="auto"])
if test x"$have_usbredir" = "xyes" && test "x$enable_polkit" != "xno"; then
- have_polkit=yes
PKG_CHECK_MODULES([POLKIT], [polkit-gobject-1 >= 0.96],
- [],
+ [have_polkit=yes],
[have_polkit=no])
AC_CHECK_HEADER([acl/libacl.h], [], [have_polkit=no])
AC_CHECK_LIB([acl], [acl_get_file], [ACL_LIBS=-lacl], [have_polkit=no])
@@ -388,6 +386,9 @@ else
AM_CONDITIONAL(WITH_POLKIT, false)
fi
+if test "x$have_usbredir" = "xyes" && test "x$have_polkit" != "xyes"; then
+ AC_MSG_WARN([Building with usbredir support, but *not* building the usb acl helper])
+fi
AC_ARG_WITH([usb-acl-helper-dir],
AS_HELP_STRING([--with-usb-acl-helper-dir=DIR],
More information about the Spice-commits
mailing list