From 873d06d71243c062bc321e72466400ebf6eb07ed Mon Sep 17 00:00:00 2001 From: Michael Mrozek Date: Sat, 5 Jun 2010 11:15:15 +0200 Subject: [PATCH] op_bluetooth: Added security fixes --- .../pandora-scripts/op_bluetooth.desktop | 2 +- .../pandora-scripts/op_bluetooth.sh | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop b/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop index 7cae88e..4009873 100644 --- a/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop +++ b/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop @@ -2,7 +2,7 @@ Name=Toggle Bluetooth Status Comment=Toggle the status of your Bluetooth device. StartupNotify=false -Exec=sudo /usr/pandora/scripts/op_bluetooth.sh +Exec=/usr/pandora/scripts/op_bluetooth.sh Icon=bluetooth Terminal=false Type=Application diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth.sh b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh index 0b3d8d3..cf33851 100644 --- a/recipes/pandora-system/pandora-scripts/op_bluetooth.sh +++ b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh @@ -3,30 +3,30 @@ # Released under the GPL INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`" +LOCK="~/.op_btenabled" + +if [ $1 = "startup" ]; then + [ -f "$LOCK" ] && sudo /usr/sbin/hciconfig "$INTERFACE" up pscan 1>/dev/null && sudo /usr/sbin/bluetoothd || echo "Bluetooth: User has not enabled Bluetooth." -if [ ${1} = "startup" ]; then - [ -f ~/.op_btenabled ] && sudo /usr/sbin/hciconfig ${INTERFACE} up pscan && sudo /usr/sbin/bluetoothd ||echo "Bluetooth: User has not enabled Bluetooth." else # Figure out if Bluetooth is running or not - if [ "`hciconfig ${INTERFACE} | grep UP`" ] + if hciconfig "$INTERFACE" | grep UP &>/dev/null then - notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png - sudo /usr/sbin/hciconfig ${INTERFACE} down - sudo killall btaddconn - sudo killall btdelconn - rm ~/.op_btenabled + notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000 + sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null + rm -f "$LOCK" else pgrep bluetoothd echo $INTERFACE if [ $? -ne 1 ]; then - notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i /usr/share/icons/hicolor/32x32/apps/blueman.png - sudo /usr/sbin/hciconfig ${INTERFACE} down - sudo /usr/sbin/hciconfig ${INTERFACE} up pscan - sudo /usr/sbin/bluetoothd - rm ~/.op_btenabled - echo true > ~/.op_btenabled + notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000 + sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null + sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null + sudo /usr/sbin/bluetoothd 1>/dev/null + touch "$LOCK" + fi fi fi -- 2.39.5