blue_hydra: initial commit, fork bluez so it works

This commit is contained in:
Rick Farina (Zero_Chaos) 2016-07-23 15:44:03 -04:00
parent 3faab398e7
commit 734445a01f
No known key found for this signature in database
GPG key ID: A5DD1427DD11F94A
14 changed files with 620 additions and 1 deletions

View file

@ -0,0 +1,72 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
DESCRIPTION="bluetooth discovery service built on top of bluez"
HOMEPAGE="https://github.com/pwnieexpress/blue_hydra"
SRC_URI=""
LICENSE="BSD-3"
SLOT="0"
USE_RUBY="ruby21"
inherit git-r3 ruby-ng
#KEYWORDS="amd64 x86 arm"
KEYWORDS=""
EGIT_REPO_URI="https://github.com/pwnieexpress/blue_hydra.git"
EGIT_CHECKOUT_DIR="${WORKDIR}"/all
IUSE=""
DEPEND=""
PDEPEND="net-wireless/bluez[test-programs]
dev-python/dbus-python"
ruby_add_bdepend "dev-ruby/bundler"
ruby_add_rdepend "dev-ruby/dm-core
dev-ruby/dm-sqlite-adapter"
#RUBY_S="${WORKDIR}/${P}"
all_ruby_unpack () {
if [[ ${PV} == "9999" ]]; then
git-r3_src_unpack
else
default_src_unpack
fi
}
#each_ruby_prepare() {
# sed -e \
# "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?ruby\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${RUBY}:" \
# -i "bin/blue_hydra" || die "Conversion of shebang in 'bin/blue_hydra' failed"
#}
each_ruby_test() {
${RUBY} -S rspec || die
}
each_ruby_install() {
dodir /usr/share/doc/${PF}
cp -R {README.md,TODO} "${ED}"/usr/share/doc/${PF} || die
rm -r spec || die
if [ -f Gemfile.lock ]; then
rm Gemfile.lock || die
fi
dodir /usr/$(get_libdir)/${PN}
cp -R * "${ED}"/usr/$(get_libdir)/${PN}
fowners -R root:0 /
dodir /usr/sbin
cat <<-EOF > "${ED}"/usr/sbin/blue_hydra
#! /bin/sh
cd /usr/$(get_libdir)/${PN}
if [ -f Gemfile.lock ]; then
rm Gemfile.lock
fi
${RUBY} -S bundle exec ./bin/blue_hydra \$@
EOF
fperms +x /usr/sbin/blue_hydra
}

View file

@ -0,0 +1 @@
DIST bluez-5.39.tar.xz 1659576 SHA256 21d1bc9150d3576296595217efb98a746b592389d25d5637e8bee5da7272593b SHA512 a0c43d0de4dcbfa20bbfe34e805a60703f4b94d0aa6c1d128a0917dfaa490593b26eb555b0a343ff44d1f94349b61776189438039e489ddcf8fe107354740230 WHIRLPOOL da299f8556418cf38d5a05b91079fdb6ff85761127d4708783bcd97fa4502e208187c013b1d8622688b438308506fbb06732426c35f6fedc2fe25cfd68a93486

View file

@ -0,0 +1,237 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=6
PYTHON_COMPAT=( python{2_7,3_4,3_5} )
inherit autotools eutils multilib python-single-r1 readme.gentoo-r1 systemd udev user multilib-minimal
DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
HOMEPAGE="http://www.bluez.org"
SRC_URI="mirror://kernel/linux/bluetooth/${P}.tar.xz"
LICENSE="GPL-2+ LGPL-2.1+"
SLOT="0/3"
KEYWORDS="amd64 arm ~arm64 ~hppa ~mips ppc ~ppc64 x86"
IUSE="cups doc debug deprecated extra-tools experimental +obex +readline selinux systemd test test-programs +udev"
REQUIRED_USE="
test? ( ${PYTHON_REQUIRED_USE} )
test-programs? ( ${PYTHON_REQUIRED_USE} )
"
CDEPEND="
>=dev-libs/glib-2.28:2
>=sys-apps/dbus-1.6:=
>=sys-apps/hwids-20121202.2
cups? ( net-print/cups:= )
obex? ( dev-libs/libical:= )
readline? ( sys-libs/readline:= )
systemd? ( sys-apps/systemd )
udev? ( >=virtual/udev-172 )
"
TEST_DEPS="${PYTHON_DEPS}
>=dev-python/dbus-python-1[${PYTHON_USEDEP}]
dev-python/pygobject:3[${PYTHON_USEDEP}]
"
DEPEND="${CDEPEND}
virtual/pkgconfig
test? ( ${TEST_DEPS} )
"
RDEPEND="${CDEPEND}
selinux? ( sec-policy/selinux-bluetooth )
test-programs? ( ${TEST_DEPS} )
"
DOC_CONTENTS="
If you want to use rfcomm as a normal user, you need to add the user
to the uucp group.
"
PATCHES=(
# Use static group "plugdev" if there is no ConsoleKit (or systemd logind)
"${FILESDIR}"/bluez-plugdev.patch
# Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
# http://www.spinics.net/lists/linux-bluetooth/msg58739.html
"${FILESDIR}"/bluez-udevadm-path.patch
# build: Quote systemd variable names, bug #527432
"${FILESDIR}"/bluez-5.39-systemd-quote.patch
# http://article.gmane.org/gmane.linux.bluez.kernel/67230
# Fedora patches
# http://www.spinics.net/lists/linux-bluetooth/msg38490.html
"${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
# http://www.spinics.net/lists/linux-bluetooth/msg40136.html
"${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
# http://www.spinics.net/lists/linux-bluetooth/msg41264.html
"${FILESDIR}"/0002-autopair-Don-t-handle-the-iCade.patch
# ???
"${FILESDIR}"/0004-agent-Assert-possible-infinite-loop.patch
)
pkg_setup() {
enewgroup plugdev
if use test || use test-programs; then
python-single-r1_pkg_setup
fi
if ! use udev; then
ewarn
ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
ewarn "and hid2hci will not be available."
ewarn
fi
}
src_prepare() {
default
if use cups; then
sed -i \
-e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
Makefile.{in,tools} || die
fi
eautoreconf
multilib_copy_sources
}
multilib_src_configure() {
local myconf=(
# readline is automagic when client is enabled
# --enable-client always needs readline, bug #504038
ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
)
if ! multilib_is_native_abi; then
myconf+=(
# deps not used for the library
{DBUS,GLIB}_{CFLAGS,LIBS}=' '
)
fi
econf \
--localstatedir=/var \
--disable-android \
--enable-datafiles \
--enable-experimental \
--enable-optimization \
$(use_enable debug) \
--enable-pie \
--enable-threads \
--enable-library \
--enable-tools \
--enable-manpages \
--enable-monitor \
--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
$(multilib_native_use_enable cups) \
$(multilib_native_use_enable deprecated) \
$(multilib_native_use_enable experimental) \
$(multilib_native_use_enable obex) \
$(multilib_native_use_enable readline client) \
$(multilib_native_use_enable systemd) \
$(multilib_native_use_enable test-programs test) \
$(multilib_native_use_enable udev) \
$(multilib_native_use_enable udev sixaxis)
}
multilib_src_compile() {
if multilib_is_native_abi; then
default
else
emake -f Makefile -f - libs \
<<<'libs: $(lib_LTLIBRARIES)'
fi
}
multilib_src_test() {
multilib_is_native_abi && default
}
multilib_src_install() {
if multilib_is_native_abi; then
emake DESTDIR="${D}" install
# Only install extra-tools when relevant USE flag is enabled
if use extra-tools; then
ewarn "Upstream doesn't support using this tools and their bugs are"
ewarn "likely to be ignored forever, also that tools can break"
ewarn "without previous announcement."
ewarn "Upstream also states all this tools are not really needed,"
ewarn "then, if you still need to rely on them, you must ask them"
ewarn "to either install that tool by default or add the needed"
ewarn "functionality to the existing 'official' tools."
ewarn "Please report this issues to:"
ewarn "http://www.bluez.org/development/lists/"
# Upstream doesn't install this, bug #524640
# http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
# http://comments.gmane.org/gmane.linux.bluez.kernel/54564
# gatttool is only built with readline, bug #530776
if use readline; then
dobin attrib/gatttool
dobin tools/btmgmt
fi
dobin tools/hex2hcd
fi
# Unittests are not that useful once installed, so make them optional
if use test-programs; then
#remove python3 only tests
rm -f "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-{client,server}
python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
dosym "${i}" /usr/bin/bluez-"${i##*/}"
done
fi
else
emake DESTDIR="${D}" \
install-includeHEADERS \
install-libLTLIBRARIES \
install-pkgconfigDATA
fi
}
multilib_src_install_all() {
prune_libtool_files --modules
keepdir /var/lib/bluetooth
# Upstream don't want people to play with them
# But we keep installing them due to 'historical' reasons
insinto /etc/bluetooth
local d
for d in input network proximity; do
doins profiles/${d}/${d}.conf
done
doins src/main.conf
newinitd "${FILESDIR}"/bluetooth-init.d-r3 bluetooth
newinitd "${FILESDIR}"/rfcomm-init.d-r2 rfcomm
einstalldocs
use doc && dodoc doc/*.txt
readme.gentoo_create_doc
}
pkg_postinst() {
readme.gentoo_print_elog
use udev && udev_reload
has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp."
if ! has_version sys-auth/consolekit && ! has_version sys-apps/systemd; then
elog "Since you don't have sys-auth/consolekit neither sys-apps/systemd, you will"
elog "need to add the user to the plugdev group."
fi
}

View file

@ -0,0 +1,58 @@
From 3027cb7141fb65cf3eeda69c688db8c4045e2d3f Mon Sep 17 00:00:00 2001
From: Giovanni Campagna <gcampagna-cNUdlRotFMnNLxjTenLetw@public.gmane.org>
Date: Sat, 12 Oct 2013 17:45:25 +0200
Subject: [PATCH] Allow using obexd without systemd in the user session
Not all sessions run systemd --user (actually, the majority
doesn't), so the dbus daemon must be able to spawn obexd
directly, and to do so it needs the full path of the daemon.
---
Makefile.obexd | 4 ++--
obexd/src/org.bluez.obex.service | 4 ----
obexd/src/org.bluez.obex.service.in | 4 ++++
3 files changed, 6 insertions(+), 6 deletions(-)
delete mode 100644 obexd/src/org.bluez.obex.service
create mode 100644 obexd/src/org.bluez.obex.service.in
diff --git a/Makefile.obexd b/Makefile.obexd
index 3760867..142e7c3 100644
--- a/Makefile.obexd
+++ b/Makefile.obexd
@@ -2,12 +2,12 @@
if SYSTEMD
systemduserunitdir = @SYSTEMD_USERUNITDIR@
systemduserunit_DATA = obexd/src/obex.service
+endif
dbussessionbusdir = @DBUS_SESSIONBUSDIR@
dbussessionbus_DATA = obexd/src/org.bluez.obex.service
-endif
-EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service
+EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service.in
obex_plugindir = $(libdir)/obex/plugins
diff --git a/obexd/src/org.bluez.obex.service b/obexd/src/org.bluez.obex.service
deleted file mode 100644
index a538088..0000000
--- a/obexd/src/org.bluez.obex.service
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.bluez.obex
-Exec=/bin/false
-SystemdService=dbus-org.bluez.obex.service
diff --git a/obexd/src/org.bluez.obex.service.in b/obexd/src/org.bluez.obex.service.in
new file mode 100644
index 0000000..9c815f2
--- /dev/null
+++ b/obexd/src/org.bluez.obex.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.bluez.obex
+Exec=@libexecdir@/obexd
+SystemdService=dbus-org.bluez.obex.service
--
1.8.3.1

View file

@ -0,0 +1,38 @@
From f7861d27fbcbc519f57d8496aa9486f487908821 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sat, 9 Nov 2013 18:13:43 +0100
Subject: [PATCH 1/5] obex: Use GLib helper function to manipulate paths
Instead of trying to do it by hand. This also makes sure that
relative paths aren't used by the agent.
---
obexd/src/manager.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index cec8a39..f18896e 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -651,14 +651,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID)) {
/* Splits folder and name */
- const char *slash = strrchr(name, '/');
+ gboolean is_relative = !g_path_is_absolute(name);
DBG("Agent replied with %s", name);
- if (!slash) {
- agent->new_name = g_strdup(name);
+ if (is_relative) {
+ agent->new_name = g_path_get_basename(name);
agent->new_folder = NULL;
} else {
- agent->new_name = g_strdup(slash + 1);
- agent->new_folder = g_strndup(name, slash - name);
+ agent->new_name = g_path_get_basename(name);
+ agent->new_folder = g_path_get_dirname(name);
}
}
--
1.8.4.2

View file

@ -0,0 +1,47 @@
From c16ae7041c7511d8d1ed8441f696716fa6a9117e Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 19 Nov 2013 14:11:39 +0100
Subject: [PATCH 2/5] autopair: Don't handle the iCade
We can't easily enter digits other than 1 through 4 (inclusive)
so leave it up to the agent to figure out a good passcode
for the iCade.
Note that we can not use the VID/PID of the device, as it is not
yet known at that point.
---
plugins/autopair.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/plugins/autopair.c b/plugins/autopair.c
index 8c98c12..5d2f6f7 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
@@ -57,13 +57,23 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
{
char addr[18];
char pinstr[7];
+ char name[25];
uint32_t class;
ba2str(device_get_address(device), addr);
class = btd_device_get_class(device);
- DBG("device %s 0x%x", addr, class);
+ device_get_name(device, name, sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ DBG("device %s (%s) 0x%x", addr, name, class);
+
+ g_message ("vendor 0x%X product: 0x%X", btd_device_get_vendor (device), btd_device_get_product (device));
+
+ /* The iCade shouldn't use random PINs like normal keyboards */
+ if (name != NULL && strstr(name, "iCade") != NULL)
+ return 0;
/* This is a class-based pincode guesser. Ignore devices with an
* unknown class.
--
1.8.4.2

View file

@ -0,0 +1,25 @@
From 67e5477687a2753d3f7b300bcfdc74464d8ad41f Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 9 Dec 2013 18:04:56 +0100
Subject: [PATCH 4/5] agent: Assert possible infinite loop
---
src/agent.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/agent.c b/src/agent.c
index bcba969..b292881 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -203,6 +203,8 @@ void agent_unref(struct agent *agent)
if (agent->ref > 0)
return;
+ g_assert (agent->ref == 0);
+
if (agent->request) {
DBusError err;
agent_pincode_cb pincode_cb;
--
1.8.4.2

View file

@ -0,0 +1,21 @@
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
depend() {
after coldplug
need dbus localmount hostname
}
start() {
ebegin "Starting ${SVCNAME}"
start-stop-daemon --start --background --exec /usr/libexec/bluetooth/bluetoothd
eend $?
}
stop() {
ebegin "Shutting down ${SVCNAME}"
start-stop-daemon --stop --quiet --exec /usr/libexec/bluetooth/bluetoothd
eend $?
}

View file

@ -0,0 +1,38 @@
From f554e152715a3c06a69954d9d4f15415c798e083 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Sun, 3 Apr 2016 14:30:02 -0400
Subject: [PATCH] build: Quote systemd variable names
If the systemd-m4 package has been installed, SYSTEMD_USERUNITDIR is
defined as a macro. Quote this name to prevent macro expansion.
Bug: https://bugs.gentoo.org/527432
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1679a47..4664003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,7 +216,7 @@ if (test "${enable_systemd}" != "no" && test -z "${path_systemunitdir}"); then
fi
AC_MSG_RESULT([${path_systemunitdir}])
fi
-AC_SUBST(SYSTEMD_SYSTEMUNITDIR, [${path_systemunitdir}])
+AC_SUBST([SYSTEMD_SYSTEMUNITDIR], [${path_systemunitdir}])
AC_ARG_WITH([systemduserunitdir],
AC_HELP_STRING([--with-systemduserunitdir=DIR],
@@ -230,7 +230,7 @@ if (test "${enable_systemd}" != "no" && test -z "${path_userunitdir}"); then
fi
AC_MSG_RESULT([${path_userunitdir}])
fi
-AC_SUBST(SYSTEMD_USERUNITDIR, [${path_userunitdir}])
+AC_SUBST([SYSTEMD_USERUNITDIR], [${path_userunitdir}])
AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
[do not install configuration and data files]),
--
2.8.0

View file

@ -0,0 +1,14 @@
diff -Nurp bluez-4.39.orig/src/bluetooth.conf bluez-4.39/src/bluetooth.conf
--- bluez-4.39.orig/src/bluetooth.conf 2008-12-20 20:18:10.000000000 +0100
+++ bluez-4.39/src/bluetooth.conf 2009-09-05 13:30:34.411581498 +0200
@@ -17,6 +17,10 @@
<allow send_destination="org.bluez"/>
</policy>
+ <policy group="plugdev">
+ <allow send_destination="org.bluez"/>
+ </policy>
+
<policy context="default">
<deny send_destination="org.bluez"/>
</policy>

View file

@ -0,0 +1,10 @@
--- a/tools/hid2hci.rules
+++ b/tools/hid2hci.rules
@@ -20,6 +20,7 @@
# Unfortunately the only event seen is the BT device disappearing, so the mouse
# device needs to be chased down on the USB bus.
ATTR{bDeviceClass}=="e0", ATTR{bDeviceSubClass}=="01", ATTR{bDeviceProtocol}=="01", ATTR{idVendor}=="413c", \
+ ENV{REMOVE_CMD}="/usr/bin/udevadm trigger --action=change --subsystem-match=usb --property-match=HID2HCI_SWITCH=1" \
ENV{REMOVE_CMD}="/sbin/udevadm trigger --action=change --subsystem-match=usb --property-match=HID2HCI_SWITCH=1"
# CSR devices

View file

@ -0,0 +1,35 @@
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
depend() {
need bluetooth
}
checkconfig() {
if [ -z "${ADDRESS}" ]; then
eerror "ADDRESS must be set"
return 1
fi
return 0
}
start() {
local DEVICE=${RC_SVCNAME#*.}
checkconfig || return 1
ebegin "Starting ${RC_SVCNAME}"
rfcomm bind "${DEVICE}" "${ADDRESS}" ${CHANNEL}
eend $?
}
stop() {
local DEVICE=${RC_SVCNAME#*.}
ebegin "Shutting down ${RC_SVCNAME}"
rfcomm release "${DEVICE}"
eend $?
}

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>pacho@gentoo.org</email>
<name>Pacho Ramos</name>
</maintainer>
<use>
<flag name="deprecated">Build deprecated plugins</flag>
<flag name="experimental">Build experimental plugins</flag>
<flag name="extra-tools">Install tools that upstream doesn't install on
purpose by default. All this tools shouldn't be used. Then, please
notify upstream about you still need them to let them know the
situation.</flag>
<flag name="test-programs">Install tools for testing of
various Bluetooth functions</flag>
<flag name="obex">Enable OBEX transfer support.</flag>
</use>
<upstream>
<remote-id type="cpe">cpe:/a:bluez:bluez</remote-id>
<remote-id type="cpe">cpe:/a:bluez:bluez-libs</remote-id>
</upstream>
</pkgmetadata>

View file

@ -1,4 +1,4 @@
net-wireless/bluez gstreamer
net-wireless/bluez gstreamer test-programs
net-wireless/compat-wireless b43 b44 bluetooth injection
net-wireless/compat-wireless-builder b43 b44 bluetooth injection
net-wireless/gnuradio audio channels dtv fcd fec filter grc trellis noaa uhd utils wavelet