The patches below fix rfcomm_sppd to allow it to be used as a
subprocess or pipe when communicating to a bluetooth device. It
is not always useful to rely on rfcomm_sppd attaching itself to a
tty, so we should handle the case when there is not TTY.
I attempted to mail the maintainer first, but I have not heard
anything.
Aaron Hsu
--- Makefile.orig Thu Oct 23 00:00:42 2008
+++ Makefile Thu Oct 23 00:03:57 2008
@@ -2,7 +2,7 @@
COMMENT= bluetooth network tools
DISTNAME= bluetooth-tools-20080217
-PKGNAME= ${DISTNAME}p0
+PKGNAME= ${DISTNAME}p1
CATEGORIES= net
MAINTAINER= Uwe Stuehler <[EMAIL PROTECTED]>
--- patches/patch-rfcomm_sppd_rfcomm_sppd_c.orig Mon Oct 27 20:33:29 2008
+++ patches/patch-rfcomm_sppd_rfcomm_sppd_c Wed Oct 22 23:57:37 2008
@@ -0,0 +1,35 @@
+$OpenBSD$
+--- rfcomm_sppd/rfcomm_sppd.c.orig Fri Sep 14 04:24:55 2007
++++ rfcomm_sppd/rfcomm_sppd.c Wed Oct 22 23:57:09 2008
+@@ -228,18 +228,20 @@ main(int argc, char *argv[])
+ * be used directly with stdio
+ */
+ if (tty == NULL) {
+- if (tcgetattr(tty_in, &t) < 0)
+- err(EXIT_FAILURE, "tcgetattr");
++ if (tcgetattr(tty_in, &t) < 0) {
++ if (errno != ENOTTY)
++ err(EXIT_FAILURE, "tcgetattr");
++ } else {
++ memcpy(&tio, &t, sizeof(tio));
++ t.c_lflag &= ~(ECHO | ICANON);
++ t.c_iflag &= ~(ICRNL);
++
++ if (memcmp(&tio, &t, sizeof(tio))) {
++ if (tcsetattr(tty_in, TCSANOW, &t) < 0)
++ err(EXIT_FAILURE, "tcsetattr");
+
+- memcpy(&tio, &t, sizeof(tio));
+- t.c_lflag &= ~(ECHO | ICANON);
+- t.c_iflag &= ~(ICRNL);
+-
+- if (memcmp(&tio, &t, sizeof(tio))) {
+- if (tcsetattr(tty_in, TCSANOW, &t) < 0)
+- err(EXIT_FAILURE, "tcsetattr");
+-
+- atexit(reset_tio);
++ atexit(reset_tio);
++ }
+ }
+ } else {
+ if (daemon(0, 0) < 0)