daily pastebin goal
8%
SHARE
TWEET

lars

a guest Jan 11th, 2019 59 in 18 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: tools/build/mk/OptionalObsoleteFiles.inc
  2. ===================================================================
  3. --- tools/build/mk/OptionalObsoleteFiles.inc    (revision 342944)
  4. +++ tools/build/mk/OptionalObsoleteFiles.inc    (working copy)
  5. @@ -504,6 +504,7 @@
  6.  .endif
  7.  OLD_FILES+=usr/sbin/ath3kfw
  8.  OLD_FILES+=usr/sbin/bcmfw
  9. +OLD_FILES+=usr/sbin/bluetooth-config
  10.  OLD_FILES+=usr/sbin/bt3cfw
  11.  OLD_FILES+=usr/sbin/bthidcontrol
  12.  OLD_FILES+=usr/sbin/bthidd
  13. @@ -580,6 +581,7 @@
  14.  OLD_FILES+=usr/share/man/man5/hcsecd.conf.5.gz
  15.  OLD_FILES+=usr/share/man/man8/ath3kfw.8.gz
  16.  OLD_FILES+=usr/share/man/man8/bcmfw.8.gz
  17. +OLD_FILES+=usr/share/man/man8/bluetooth-config.8.gz
  18.  OLD_FILES+=usr/share/man/man8/bt3cfw.8.gz
  19.  OLD_FILES+=usr/share/man/man8/bthidcontrol.8.gz
  20.  OLD_FILES+=usr/share/man/man8/bthidd.8.gz
  21. Index: usr.sbin/bluetooth/Makefile
  22. ===================================================================
  23. --- usr.sbin/bluetooth/Makefile (revision 342944)
  24. +++ usr.sbin/bluetooth/Makefile (working copy)
  25. @@ -4,6 +4,7 @@
  26.  .include <src.opts.mk>
  27.  
  28.  SUBDIR= \
  29. +   bluetooth-config \
  30.     bt3cfw \
  31.     btpand \
  32.     hccontrol \
  33. Index: usr.sbin/bluetooth/bluetooth-config/Makefile
  34. ===================================================================
  35. --- usr.sbin/bluetooth/bluetooth-config/Makefile    (nonexistent)
  36. +++ usr.sbin/bluetooth/bluetooth-config/Makefile    (working copy)
  37. @@ -0,0 +1,6 @@
  38. +# $FreeBSD$
  39. +
  40. +SCRIPTS=bluetooth-config.sh
  41. +MAN=   bluetooth-config.8
  42. +
  43. +.include <bsd.prog.mk>
  44.  
  45. Property changes on: usr.sbin/bluetooth/bluetooth-config/Makefile
  46. ___________________________________________________________________
  47. Added: svn:eol-style
  48. ## -0,0 +1 ##
  49. +native
  50. \ No newline at end of property
  51. Added: svn:keywords
  52. ## -0,0 +1 ##
  53. +FreeBSD=%H
  54. \ No newline at end of property
  55. Added: svn:mime-type
  56. ## -0,0 +1 ##
  57. +text/plain
  58. \ No newline at end of property
  59. Index: usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8
  60. ===================================================================
  61. --- usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8  (nonexistent)
  62. +++ usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8  (working copy)
  63. @@ -0,0 +1,222 @@
  64. +.\" Copyright (c) 2019 Dirk Engling
  65. +.\" All rights reserved.
  66. +.\"
  67. +.\" Redistribution and use in source and binary forms, with or without
  68. +.\" modification, are permitted provided that the following conditions
  69. +.\" are met:
  70. +.\" 1. Redistributions of source code must retain the above copyright
  71. +.\"    notice, this list of conditions and the following disclaimer.
  72. +.\" 2. Redistributions in binary form must reproduce the above copyright
  73. +.\"    notice, this list of conditions and the following disclaimer in the
  74. +.\"    documentation and/or other materials provided with the distribution.
  75. +.\"
  76. +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  77. +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  78. +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  79. +.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  80. +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  81. +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  82. +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  83. +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  84. +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  85. +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  86. +.\" SUCH DAMAGE.
  87. +.\"
  88. +.\" $FreeBSD$
  89. +.\"
  90. +.Dd January 7, 2019
  91. +.Dt BLUETOOTH-CONFIG 8
  92. +.Os
  93. +.Sh NAME
  94. +.Nm bluetooth-config
  95. +.Nd a script to manage config files for the bluetooth sub system
  96. +.Sh SYNOPSIS
  97. +.Nm
  98. +.Ar scan
  99. +.Op Fl d Ar device
  100. +.Op Fl n Ar node
  101. +.Sh DESCRIPTION
  102. +The
  103. +.Nm
  104. +utility is an interactive script to provide a frontend to the complex bluetooth sub system daemons.
  105. +.Pp
  106. +The following options are available:
  107. +.Bl -tag -width indent+
  108. +.It Fl d
  109. +Scan for a specific bluetooth device address.
  110. +.It Fl n
  111. +Limit scan to a specific host controller. Hint: List all netgraph nodes with
  112. +.Ql /usr/sbin/ngctl list .
  113. +.El
  114. +.Pp
  115. +.Nm
  116. +will help finding and setting up bluetooth controllers, scan for nearby bluetooth devices in
  117. +pairing mode, lookup their names, allow mapping to friendly names in
  118. +.Pa /etc/bluetooth/hosts ,
  119. +ask for the paring PIN, instrument
  120. +.Xr hcsecd 8
  121. +to securely pair with new devices and, if the device offers HID endpoints such as mice or
  122. +keyboards, configure and restart
  123. +.Xr bthidd 8 .
  124. +.Pp
  125. +.Nm
  126. +can bring up any interface and daemon necessary for operation and, if a node is provided on
  127. +command line, will do so automatically for that interface.
  128. +.Sh CAVEATS
  129. +.Nm
  130. +can not parse entries in
  131. +.Xr hcsecd 8
  132. +config file and thus will ask the user to manually modify existing pairing PIN entries.
  133. +.Sh FILES
  134. +.Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
  135. +.It Pa /etc/bluetooth/hosts
  136. +.It Pa sysrc -n bthidd_config
  137. +.It Pa sysrc -n hcsecd_config
  138. +.El
  139. +.Sh EXAMPLES
  140. +.Nm
  141. +scan -n ubt0 -a 00:26:bb:7a:58:95
  142. +.Bd -ragged -offset indent
  143. +This will scan the bluetooth controller ubt0hci for a bluetooth device with the address
  144. +00:26:bb:7a:58:95, set up ubt0 if necessary and enter an interactive dialog to pair the
  145. +new device. Since in this example a mouse is paired,
  146. +.Nm
  147. +will interact with
  148. +.Xr bthidd 8 ,
  149. +enabling it if necessary and then write an HID descriptor to its config.
  150. +.Ed
  151. +.Pp
  152. +.Nm
  153. +scan
  154. +.Bd -ragged -offset indent
  155. +This will scan all bluetooth controllers on the systems for bluetooth devices, prompting
  156. +to bring up controllers or daemons along the way.
  157. +.Ed
  158. +.Sh SEE ALSO
  159. +.Xr bthidcontrol 8 ,
  160. +.Xr bthidd 8 ,
  161. +.Xr bthost 1 ,
  162. +.Xr hccontrol 8 ,
  163. +.Xr hcsecd 8 ,
  164. +.Xr sdpcontrol 8 ,
  165. +.Xr sysrc 8
  166. +.Sh HISTORY
  167. +A
  168. +.Nm
  169. +utility first appeared in
  170. +.Fx 12.1 .
  171. +.Sh AUTHORS
  172. +.An Dirk Engling Aq Mt erdgeist@erdgeist.org
  173. +.Sh THANKS TO
  174. +Lars Engels and Warren Block for suggestions, help, and testing.
  175. +.\" Copyright (c) 2019 Dirk Engling
  176. +.\" All rights reserved.
  177. +.\"
  178. +.\" Redistribution and use in source and binary forms, with or without
  179. +.\" modification, are permitted provided that the following conditions
  180. +.\" are met:
  181. +.\" 1. Redistributions of source code must retain the above copyright
  182. +.\"    notice, this list of conditions and the following disclaimer.
  183. +.\" 2. Redistributions in binary form must reproduce the above copyright
  184. +.\"    notice, this list of conditions and the following disclaimer in the
  185. +.\"    documentation and/or other materials provided with the distribution.
  186. +.\"
  187. +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  188. +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  189. +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  190. +.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  191. +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  192. +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  193. +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  194. +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  195. +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  196. +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  197. +.\" SUCH DAMAGE.
  198. +.\"
  199. +.\" $FreeBSD$
  200. +.\"
  201. +.Dd January 7, 2019
  202. +.Dt BLUETOOTH-CONFIG 8
  203. +.Os
  204. +.Sh NAME
  205. +.Nm bluetooth-config
  206. +.Nd a script to manage config files for the bluetooth sub system
  207. +.Sh SYNOPSIS
  208. +.Nm
  209. +.Ar scan
  210. +.Op Fl d Ar device
  211. +.Op Fl n Ar node
  212. +.Sh DESCRIPTION
  213. +The
  214. +.Nm
  215. +utility is an interactive script to provide a frontend to the complex bluetooth sub system daemons.
  216. +.Pp
  217. +The following options are available:
  218. +.Bl -tag -width indent+
  219. +.It Fl d
  220. +Scan for a specific bluetooth device address.
  221. +.It Fl n
  222. +Limit scan to a specific host controller. Hint: List all netgraph nodes with
  223. +.Ql /usr/sbin/ngctl list .
  224. +.El
  225. +.Pp
  226. +.Nm
  227. +will help finding and setting up bluetooth controllers, scan for nearby bluetooth devices in
  228. +pairing mode, lookup their names, allow mapping to friendly names in
  229. +.Pa /etc/bluetooth/hosts ,
  230. +ask for the paring PIN, instrument
  231. +.Xr hcsecd 8
  232. +to securely pair with new devices and, if the device offers HID endpoints such as mice or
  233. +keyboards, configure and restart
  234. +.Xr bthidd 8 .
  235. +.Pp
  236. +.Nm
  237. +can bring up any interface and daemon necessary for operation and, if a node is provided on
  238. +command line, will do so automatically for that interface.
  239. +.Sh CAVEATS
  240. +.Nm
  241. +can not parse entries in
  242. +.Xr hcsecd 8
  243. +config file and thus will ask the user to manually modify existing pairing PIN entries.
  244. +.Sh FILES
  245. +.Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
  246. +.It Pa /etc/bluetooth/hosts
  247. +.It Pa sysrc -n bthidd_config
  248. +.It Pa sysrc -n hcsecd_config
  249. +.El
  250. +.Sh EXAMPLES
  251. +.Nm
  252. +scan -n ubt0 -a 00:26:bb:7a:58:95
  253. +.Bd -ragged -offset indent
  254. +This will scan the bluetooth controller ubt0hci for a bluetooth device with the address
  255. +00:26:bb:7a:58:95, set up ubt0 if necessary and enter an interactive dialog to pair the
  256. +new device. Since in this example a mouse is paired,
  257. +.Nm
  258. +will interact with
  259. +.Xr bthidd 8 ,
  260. +enabling it if necessary and then write an HID descriptor to its config.
  261. +.Ed
  262. +.Pp
  263. +.Nm
  264. +scan
  265. +.Bd -ragged -offset indent
  266. +This will scan all bluetooth controllers on the systems for bluetooth devices, prompting
  267. +to bring up controllers or daemons along the way.
  268. +.Ed
  269. +.Sh SEE ALSO
  270. +.Xr bthidcontrol 8 ,
  271. +.Xr bthidd 8 ,
  272. +.Xr bthost 1 ,
  273. +.Xr hccontrol 8 ,
  274. +.Xr hcsecd 8 ,
  275. +.Xr sdpcontrol 8 ,
  276. +.Xr sysrc 8
  277. +.Sh HISTORY
  278. +A
  279. +.Nm
  280. +utility first appeared in
  281. +.Fx 12.1 .
  282. +.Sh AUTHORS
  283. +.An Dirk Engling Aq Mt erdgeist@erdgeist.org
  284. +.Sh THANKS TO
  285. +Lars Engels and Warren Block for suggestions, help, and testing.
  286.  
  287. Property changes on: usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8
  288. ___________________________________________________________________
  289. Added: svn:eol-style
  290. ## -0,0 +1 ##
  291. +native
  292. \ No newline at end of property
  293. Added: svn:keywords
  294. ## -0,0 +1 ##
  295. +FreeBSD=%H
  296. \ No newline at end of property
  297. Added: svn:mime-type
  298. ## -0,0 +1 ##
  299. +text/plain
  300. \ No newline at end of property
  301. Index: usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh
  302. ===================================================================
  303. --- usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh (nonexistent)
  304. +++ usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh (working copy)
  305. @@ -0,0 +1,275 @@
  306. +#!/bin/sh
  307. +#-
  308. +# Copyleft 2019 Dirk Engling
  309. +#
  310. +# This script is released under the beerware license.
  311. +#
  312. +# $FreeBSD$
  313. +#
  314. +
  315. +# define our bail out shortcut
  316. +exerr () { echo -e "Error: $*" >&2 ; exit 1; }
  317. +print_syntax () { echo -e "Syntax: $0 scan [-d device] [-n node]"; exit 1; }
  318. +
  319. +# Assuming we are called to do the pair-new-device subcommand first
  320. +
  321. +main() {
  322. +unset node device started bdaddresses retry
  323. +
  324. +# Only one command at the moment is scan (+ add)
  325. +[ "$#" -eq 1 -a "$1" = "scan" ] || print_syntax
  326. +shift
  327. +
  328. +# Get command line options
  329. +while getopts :d:n: arg; do
  330. +  case ${arg} in
  331. +    d) device="$OPTARG";;
  332. +    n) node="$OPTARG";;
  333. +    ?) print_syntax;;
  334. +  esac
  335. +done
  336. +
  337. +# No use running without super user rights
  338. +[ $( id -u ) -eq 0 ] || exerr "$0 must modify files that belong to root.  Re-run as root."
  339. +
  340. +known_nodes=$(/usr/sbin/hccontrol read_node_list 2>/dev/null | \
  341. +    /usr/bin/tail -n +2 | /usr/bin/cut -d ' ' -f 1)
  342. +
  343. +# Check if netgraph knows about any HCI nodes
  344. +if ! [ "${known_nodes}" ]; then
  345. +  ng_nodes=$(/usr/sbin/ngctl list 2>/dev/null | \
  346. +    /usr/bin/grep -o "Name: .* Type: ubt" | /usr/bin/cut -d ' ' -f 2)
  347. +
  348. +  [ "${ng_nodes}" ] || exerr "No Bluetooth host controllers found."
  349. +
  350. +  unset found
  351. +  for n in ${ng_nodes}; do
  352. +    if [ "${n}" = "${node%hci}" ]; then
  353. +      # If we found the node but its stack is not set up, do it now
  354. +      /usr/sbin/service bluetooth start ${node%hci} || exit 1
  355. +      found="YES"
  356. +    fi
  357. +  done
  358. +
  359. +  # If we have Bluetooth controller nodes without a set up stack,
  360. +  # ask the user if we shall start it up
  361. +  if ! [ "${found}" ]; then
  362. +    printf "No usable Bluetooth host controllers were found.\n"
  363. +    printf "These host controllers exist in the system:\n  %s" " ${ng_nodes}"
  364. +    read -p "Choose a host controller to set up: [${ng_nodes%% *}]" node
  365. +    : ${node:="${ng_nodes%% *}"}
  366. +    /usr/sbin/service bluetooth start ${node} || exit 1
  367. +  fi
  368. +
  369. +  # Re-read known nodes
  370. +  known_nodes=$(/usr/sbin/hccontrol read_node_list 2>/dev/null | \
  371. +    /usr/bin/tail -n +2 | /usr/bin/cut -d ' ' -f 1)
  372. +  # check if we succeeded in bringing it up
  373. +  [ "${known_nodes}" ] || exerr "Failed to set up Bluetooth stack"
  374. +fi
  375. +
  376. +# if a node was requested on command line, check if it is there
  377. +if [ "${node}" ]; then
  378. +  unset found
  379. +  for n in ${known_nodes}; do
  380. +    [ "${n}" = "${node}" ] && found="YES"
  381. +    [ "${n}" = "${node}hci" ] && node="${node}hci" && found="YES"
  382. +  done
  383. +  [ "${found}" ] || exerr "Node ${node} not found"
  384. +fi
  385. +
  386. +[ "${node}" ] && node="-n ${node}"
  387. +
  388. +while ! [ "${bdaddresses}" ]; do
  389. +  retry=X${retry}
  390. +  printf "Scanning for new Bluetooth devices (Attempt %d of 5) ... " ${#retry}
  391. +  bdaddresses=$( /usr/sbin/hccontrol -N ${node} inquiry 2>/dev/null | \
  392. +    /usr/bin/grep -o "BD_ADDR: .*" | /usr/bin/cut -d ' ' -f 2 )
  393. +
  394. +  # Count entries and, if a device was requested on command line,
  395. +  # try to find it
  396. +  unset found count
  397. +  for bdaddress in ${bdaddresses}; do
  398. +    count=X${count}
  399. +    if [ "${bdaddress}" = "${device}" ]; then
  400. +      found=YES
  401. +      bdaddresses="${device}"
  402. +      count=X
  403. +      break
  404. +    fi
  405. +  done
  406. +
  407. +  # If device was requested on command line but is not found,
  408. +  # or no devices found at all, rescan until retry is exhausted
  409. +  if ! [ "${found}" -o "${count}" -a -z "${device}" ]; then
  410. +    printf "failed.\n"
  411. +    if [ "${#retry}" -eq 5 ]; then
  412. +      [ "${device}" ] && exerr "Device ${device} not found"
  413. +      exerr "No new Bluetooth devices found"
  414. +    fi
  415. +    unset bdaddresses
  416. +    sleep 2
  417. +    continue
  418. +  fi
  419. +
  420. +  [ ${#count} -gt 1 ] && plural=s || plural=''
  421. +  printf "done.\nFound %d new bluetooth device%s (scanning for names):\n" ${#count} ${plural}
  422. +
  423. +  # Looping again for the faster feedback
  424. +  unset count
  425. +  for bdaddress in ${bdaddresses}; do
  426. +    count=X${count}
  427. +    bdname=$( /usr/bin/bthost -b "${bdaddress}" 2>/dev/null )
  428. +    friendlyname=$( /usr/sbin/hccontrol Remote_Name_Request ${bdaddress} 2> /dev/null | \
  429. +      /usr/bin/grep -o "Name: .*" | /usr/bin/cut -d ' ' -f 2- )
  430. +
  431. +    # sdpcontrol should be able to pull vendor and product id via sdp
  432. +    printf "[%2d] %s\t\"%s\" (%s)\n" ${#count} "${bdaddress}" "${friendlyname}" "${bdname}"
  433. +
  434. +    eval bdaddress_${#count}=\${bdaddress}
  435. +    eval bdname_${#count}=\${bdname}
  436. +    eval friendlyname_${#count}=\${friendlyname}
  437. +  done
  438. +
  439. +  # If a device was pre-selected, do not query the user
  440. +  [ "${device}" ] && topair=1 || unset topair
  441. +
  442. +  # Even if only one device was found, user may chose 0 to rescan
  443. +  while ! [ "${topair}" ]; do
  444. +    if [ ${#count} -eq 1 ]; then
  445. +      read -p "Select device to pair with [1, or 0 to rescan]: " topair
  446. +    else
  447. +      read -p "Select device to pair with [1-${#count}, or 0 to rescan]: " topair
  448. +    fi
  449. +    if ! [ "${topair}" -ge 0 -a "${topair}" -le "${#count}" ] 2>/dev/null ; then
  450. +      printf "Value out of range: %s.\n" {topair}
  451. +      unset topair
  452. +    fi
  453. +  done
  454. +
  455. +  [ "${topair}" -eq "0" ] && unset bdaddresses retry
  456. +done
  457. +
  458. +eval bdaddress=\${bdaddress_${topair}}
  459. +eval bdname=\${bdname_${topair}}
  460. +eval friendlyname=\${friendlyname_${topair}}
  461. +
  462. +# Do we need to add an entry to /etc/bluetooth/hosts?
  463. +if ! [ "${bdname}" ]; then
  464. +  printf "\nAdding device ${bdaddress} to /etc/bluetooth/hosts.\n"
  465. +
  466. +  while ! [ "${bdname}" ]; do
  467. +    read -p "Enter friendly name. [${friendlyname}]: " REPLY
  468. +    : ${REPLY:="${friendlyname}"}
  469. +
  470. +    if [ "${REPLY}" ]; then
  471. +      # Remove white space and non-friendly characters
  472. +      bdname=$( printf "%s" "${REPLY}" | tr -c '[:alnum:]-,.' _ )
  473. +      [ "${REPLY}" != "${bdname}" ] && printf "Notice: Using sanitized name \"%s\" in /etc/bluetooth/hosts.\n" "${bdname}"
  474. +    fi
  475. +  done
  476. +
  477. +  printf "%s\t%s\n" "${bdaddress}" "${bdname}" >> /etc/bluetooth/hosts
  478. +fi
  479. +
  480. +# If scanning for the name did not succeed, resort to bdname
  481. +: ${friendlyname:="${bdname}"}
  482. +
  483. +# now over to hcsecd
  484. +
  485. +# Since hcsecd does not allow querying for known devices, we need to
  486. +# check for bdaddr entries manually.
  487. +#
  488. +# Also we cannot really modify the PIN in an existing entry. So we
  489. +# need to prompt the user to manually do it and restart this script
  490. +if ! /usr/sbin/service hcsecd enabled; then
  491. +  printf "\nWarning: hcsecd is not enabled.\nThis daemon manages pairing requests.\n"
  492. +  read -p "Enable hcsecd? [yes]: " REPLY
  493. +  case "${REPLY}" in no|n|NO|N|No|nO) ;; *) /usr/sbin/sysrc hcsecd_enable="YES";; esac
  494. +fi
  495. +secd_config=$( /usr/sbin/sysrc -n hcsecd_config )
  496. +secd_entries=$( /usr/bin/grep -Eo "bdaddr[[:space:]]+(${bdaddress}|${bdname})" ${secd_config} | awk '{ print $2; }' )
  497. +
  498. +if [ "${secd_entries}" ]; then
  499. +  printf "\nWarning: An entry for device %s is already present in %s.\n" ${secd_entries} ${secd_config}
  500. +  printf "To modify pairing information, edit this file and run\n  service hcsecd restart\n"
  501. +  read -p "Continue? [yes]: " REPLY
  502. +  case "${REPLY}" in no|n|NO|N|No|nO) exit;; esac
  503. +else
  504. +  printf "\nWriting pairing information description block to %s.\n" ${secd_config}
  505. +  printf "(To get PIN, put device in pairing mode first.)\n"
  506. +  read -p "Enter PIN [nopin]: " pin
  507. +  [ "${pin}" ] && pin=\""${pin}"\" || pin="nopin"
  508. +
  509. +  # Write out new hcsecd config block
  510. +  printf "\ndevice {\n\tbdaddr\t%s;\n\tname\t\"%s\";\n\tkey\tnokey\;\n\tpin\t%s\;\n}\n" \
  511. +    "${bdaddress}" "${friendlyname}" "${pin}" >> ${secd_config}
  512. +
  513. +  # ... and make daemon reload config, TODO: hcsecd should provide a reload hook
  514. +  /usr/sbin/service hcsecd restart
  515. +
  516. +  # TODO: we should check if hcsecd succeeded pairing and revert to an old version
  517. +  # of hcsecd.conf so we can undo adding the block above and retry with a new PIN
  518. +  # also, if there's a way to force devices to re-pair, try this
  519. +fi
  520. +
  521. +# now check for specific services to be provided by the device
  522. +# first up: HID
  523. +
  524. +if /usr/sbin/sdpcontrol -a "${bdaddress}" search HID | \
  525. +   /usr/bin/grep -q "^Record Handle: "; then
  526. +
  527. +  printf "\nThis device provides human interface device services.\n"
  528. +  read -p "Set it up? [yes]: " REPLY
  529. +  case "${REPLY}" in no|n|NO|N|No|nO) ;;
  530. +  *)
  531. +    if ! /usr/sbin/service bthidd enabled; then
  532. +      printf "\nWarning: bthidd is not enabled."
  533. +      printf "\nThis daemon manages Bluetooth HID devices.\n"
  534. +      read -p "Enable bthidd? [yes]: " REPLY
  535. +      case "${REPLY}" in no|n|NO|N|No|nO) ;; *) /usr/sbin/sysrc bthidd_enable="YES";; esac
  536. +    fi
  537. +
  538. +    # Check if bthidd already knows about this device
  539. +    bthidd_known=$( /usr/sbin/bthidcontrol -a "${bdaddress}" known | \
  540. +      /usr/bin/grep "${bdaddress}" )
  541. +    if [ "${bthidd_known}" ]; then
  542. +      printf "Notice: Device %s already known to bthidd.\n" "${bdaddress}"
  543. +    else
  544. +      bthidd_config=$( /usr/sbin/sysrc -n bthidd_config )
  545. +      printf "Writing HID descriptor block to %s ... " "${bthidd_config}"
  546. +      /usr/sbin/bthidcontrol -a "${bdaddress}" query >> "${bthidd_config}"
  547. +
  548. +      # Re-read config to see if we succeeded adding the device
  549. +      bthidd_known=$( /usr/sbin/bthidcontrol -a "${bdaddress}" known | \
  550. +        grep "${bdaddress}" )
  551. +      if ! [ "${bthidd_known}" ]; then
  552. +        printf "failed.\n"
  553. +      else
  554. +        printf "success.\nTo re-read its config, bthidd must be restarted.\n"
  555. +        printf "Warning: If a Bluetooth keyboard is being used, the connection might be lost.\n"
  556. +        printf "It can be manually restarted later with\n  service bthidd restart\n"
  557. +        read -p "Restart bthidd now? [yes]: " REPLY
  558. +        case "${REPLY}" in no|n|NO|N|No|nO) ;; *) /usr/sbin/service bthidd restart;; esac
  559. +      fi
  560. +    fi
  561. +  ;;
  562. +  esac
  563. +fi
  564. +
  565. +}
  566. +
  567. +# After function definitions, main() can use them
  568. +main "$@"
  569. +
  570. +exit
  571. +
  572. +# TODO
  573. +# * If device is a keyboard, offer a text entry test field and if it does
  574. +#   not succeed, leave some clues for debugging (i.e. if the node responds
  575. +#   to pings, maybe switch keyboard on/off, etc)
  576. +# * Same if device is a mouse, i.e. hexdump /dev/sysmouse.
  577. +# * If device offers DUN profiles, ask the user if an entry in
  578. +#   /etc/ppp/ppp.conf should be created
  579. +# * If OPUSH or SPP is offered, refer to the respective man pages to give
  580. +#   some clues how to continue
  581.  
  582. Property changes on: usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh
  583. ___________________________________________________________________
  584. Added: svn:eol-style
  585. ## -0,0 +1 ##
  586. +native
  587. \ No newline at end of property
  588. Added: svn:executable
  589. ## -0,0 +1 ##
  590. +*
  591. \ No newline at end of property
  592. Added: svn:keywords
  593. ## -0,0 +1 ##
  594. +FreeBSD=%H
  595. \ No newline at end of property
  596. Added: svn:mime-type
  597. ## -0,0 +1 ##
  598. +text/plain
  599. \ No newline at end of property
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top