[Midnightbsd-cvs] src [11503] trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c: sync with freebsd.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 13:41:38 EDT 2018
Revision: 11503
http://svnweb.midnightbsd.org/src/?rev=11503
Author: laffer1
Date: 2018-07-07 13:41:37 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync with freebsd.
Modified Paths:
--------------
trunk/usr.bin/bluetooth/Makefile
trunk/usr.bin/bluetooth/Makefile.inc
trunk/usr.bin/bluetooth/bthost/Makefile
trunk/usr.bin/bluetooth/bthost/bthost.1
trunk/usr.bin/bluetooth/bthost/bthost.c
trunk/usr.bin/bluetooth/btsockstat/Makefile
trunk/usr.bin/bluetooth/btsockstat/btsockstat.1
trunk/usr.bin/bluetooth/btsockstat/btsockstat.c
trunk/usr.bin/bluetooth/rfcomm_sppd/Makefile
trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c
trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c
Property Changed:
----------------
trunk/usr.bin/bluetooth/Makefile.inc
trunk/usr.bin/bluetooth/bthost/bthost.1
trunk/usr.bin/bluetooth/btsockstat/btsockstat.1
trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
Modified: trunk/usr.bin/bluetooth/Makefile
===================================================================
--- trunk/usr.bin/bluetooth/Makefile 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/Makefile 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
# $Id $
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bluetooth/Makefile 121054 2003-10-12 22:04:24Z emax $
SUBDIR= \
bthost \
Modified: trunk/usr.bin/bluetooth/Makefile.inc
===================================================================
--- trunk/usr.bin/bluetooth/Makefile.inc 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/Makefile.inc 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bluetooth/Makefile.inc 314006 2017-02-21 02:23:27Z ngie $
-.include "${.CURDIR}/../../Makefile.inc"
+.include "${SRCTOP}/usr.bin/Makefile.inc"
Property changes on: trunk/usr.bin/bluetooth/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bluetooth/bthost/Makefile
===================================================================
--- trunk/usr.bin/bluetooth/bthost/Makefile 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/bthost/Makefile 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,5 +1,6 @@
-# $Id: Makefile,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
# $MidnightBSD$
+# $Id: Makefile,v 1.4 2003/08/14 20:07:13 max Exp $
+# $FreeBSD: stable/10/usr.bin/bluetooth/bthost/Makefile 201386 2010-01-02 10:27:05Z ed $
PROG= bthost
Modified: trunk/usr.bin/bluetooth/bthost/bthost.1
===================================================================
--- trunk/usr.bin/bluetooth/bthost/bthost.1 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/bthost/bthost.1 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin at yahoo.com>
.\" All rights reserved.
.\"
@@ -22,8 +23,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: bthost.1,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
-.\" $MidnightBSD$
+.\" $Id: bthost.1,v 1.7 2003/05/21 22:19:00 max Exp $
+.\" $FreeBSD: stable/10/usr.bin/bluetooth/bthost/bthost.1 140368 2005-01-17 07:44:44Z ru $
.\"
.Dd May 8, 2003
.Dt BTHOST 1
Property changes on: trunk/usr.bin/bluetooth/bthost/bthost.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bluetooth/bthost/bthost.c
===================================================================
--- trunk/usr.bin/bluetooth/bthost/bthost.c 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/bthost/bthost.c 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* bthost.c
*
@@ -25,8 +26,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bthost.c,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
- * $MidnightBSD$
+ * $Id: bthost.c,v 1.5 2003/05/21 20:30:01 max Exp $
+ * $FreeBSD: stable/10/usr.bin/bluetooth/bthost/bthost.c 121054 2003-10-12 22:04:24Z emax $
*/
#include <bluetooth.h>
Modified: trunk/usr.bin/bluetooth/btsockstat/Makefile
===================================================================
--- trunk/usr.bin/bluetooth/btsockstat/Makefile 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/btsockstat/Makefile 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,5 +1,6 @@
-# $Id: Makefile,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
# $MidnightBSD$
+# $Id: Makefile,v 1.7 2003/08/14 20:07:14 max Exp $
+# $FreeBSD: stable/10/usr.bin/bluetooth/btsockstat/Makefile 140941 2005-01-28 16:08:11Z ru $
PROG= btsockstat
WARNS?= 2
Modified: trunk/usr.bin/bluetooth/btsockstat/btsockstat.1
===================================================================
--- trunk/usr.bin/bluetooth/btsockstat/btsockstat.1 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/btsockstat/btsockstat.1 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin at yahoo.com>
.\" All rights reserved.
.\"
@@ -22,8 +23,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: btsockstat.1,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
-.\" $MidnightBSD$
+.\" $Id: btsockstat.1,v 1.6 2003/05/21 00:09:45 max Exp $
+.\" $FreeBSD: stable/10/usr.bin/bluetooth/btsockstat/btsockstat.1 140420 2005-01-18 13:43:56Z ru $
.\"
.Dd October 12, 2003
.Dt BTSOCKSTAT 1
Property changes on: trunk/usr.bin/bluetooth/btsockstat/btsockstat.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bluetooth/btsockstat/btsockstat.c
===================================================================
--- trunk/usr.bin/bluetooth/btsockstat/btsockstat.c 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/btsockstat/btsockstat.c 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* btsockstat.c
*
@@ -25,8 +26,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: btsockstat.c,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
- * $MidnightBSD$
+ * $Id: btsockstat.c,v 1.8 2003/05/21 22:40:25 max Exp $
+ * $FreeBSD: stable/10/usr.bin/bluetooth/btsockstat/btsockstat.c 287446 2015-09-04 00:41:29Z delphij $
*/
#include <sys/types.h>
@@ -154,9 +155,9 @@
* Discard setgid privileges if not the running kernel so that
* bad guys can't print interesting stuff from kernel memory.
*/
-
if (memf != NULL)
- setgid(getgid());
+ if (setgid(getgid()) != 0)
+ err(1, "setgid");
kvmd = kopen(memf);
if (kvmd == NULL)
@@ -583,15 +584,9 @@
kvm_t *kvmd = NULL;
char errbuf[_POSIX2_LINE_MAX];
- /*
- * Discard setgid privileges if not the running kernel so that
- * bad guys can't print interesting stuff from kernel memory.
- */
-
- if (memf != NULL)
- setgid(getgid());
-
kvmd = kvm_openfiles(NULL, memf, NULL, O_RDONLY, errbuf);
+ if (setgid(getgid()) != 0)
+ err(1, "setgid");
if (kvmd == NULL) {
warnx("kvm_openfiles: %s", errbuf);
return (NULL);
Modified: trunk/usr.bin/bluetooth/rfcomm_sppd/Makefile
===================================================================
--- trunk/usr.bin/bluetooth/rfcomm_sppd/Makefile 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/rfcomm_sppd/Makefile 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,5 +1,6 @@
-# $Id: Makefile,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
# $MidnightBSD$
+# $Id: Makefile,v 1.7 2003/09/07 18:15:55 max Exp $
+# $FreeBSD: stable/10/usr.bin/bluetooth/rfcomm_sppd/Makefile 274182 2014-11-06 16:32:00Z emax $
PROG= rfcomm_sppd
SRCS= rfcomm_sppd.c rfcomm_sdp.c
@@ -6,6 +7,6 @@
WARNS?= 2
DPADD= ${LIBBLUETOOTH} ${LIBSDP}
-LDADD= -lbluetooth -lsdp
+LDADD= -lbluetooth -lsdp -lutil
.include <bsd.prog.mk>
Modified: trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c
===================================================================
--- trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* rfcomm_sdp.c
*
@@ -25,8 +26,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: rfcomm_sdp.c,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
- * $MidnightBSD$
+ * $Id: rfcomm_sdp.c,v 1.1 2003/09/07 18:15:55 max Exp $
+ * $FreeBSD: stable/10/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c 128077 2004-04-09 23:26:16Z emax $
*/
#include <bluetooth.h>
Modified: trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
===================================================================
--- trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin at yahoo.com>
.\" All rights reserved.
.\"
@@ -22,8 +23,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: rfcomm_sppd.1,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
-.\" $MidnightBSD$
+.\" $Id: rfcomm_sppd.1,v 1.3 2003/09/07 18:15:55 max Exp $
+.\" $FreeBSD: stable/10/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 274182 2014-11-06 16:32:00Z emax $
.\"
.Dd April 21, 2008
.Dt RFCOMM_SPPD 1
@@ -33,10 +34,9 @@
.Nd RFCOMM Serial Port Profile daemon
.Sh SYNOPSIS
.Nm
-.Op Fl bhS
+.Op Fl bhtS
.Fl a Ar address
.Fl c Ar channel
-.Op Fl t Ar tty
.Sh DESCRIPTION
The
.Nm
@@ -53,7 +53,7 @@
.Nm
utility provides access to the server's remote serial port via stdin/stdout
or via
-.Xr pty 4
+.Xr pts 4
interface if
.Fl t
option was specified.
@@ -72,8 +72,7 @@
If
.Fl t
options was specified,
-the server side of the virtual serial port is attached to the pseudo-terminal
-.Ar tty .
+the server side of the virtual serial port is attached to a pseudo-terminal.
Otherwise the virtual serial port is attached to the stdin/stdout.
.Nm
should be run as root in order to communicate with
@@ -146,8 +145,8 @@
.It Fl S
Server mode; see
.Sx DESCRIPTION .
-.It Fl t Ar tty
-Slave pseudo tty name.
+.It Fl t
+Use slave pseudo tty.
If not set stdin/stdout will be used.
This option is required if
.Fl b
@@ -154,16 +153,14 @@
option was specified.
.El
.Sh FILES
-.Bl -tag -width ".Pa /dev/tty[p-sP-S][0-9a-v]" -compact
-.It Pa /dev/pty[p-sP-S][0-9a-v]
-master pseudo terminals
-.It Pa /dev/tty[p-sP-S][0-9a-v]
+.Bl -tag -width ".Pa /dev/pts/[num]" -compact
+.It Pa /dev/pts/[num]
slave pseudo terminals
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
-.Dl "rfcomm_sppd -a 00:01:02:03:04:05 -c 1 -t /dev/ttyp1"
+.Dl "rfcomm_sppd -a 00:01:02:03:04:05 -c 1 -t"
.Pp
Will start the
.Nm
@@ -171,13 +168,17 @@
.Li 00:01:02:03:04:05
and channel
.Li 1 .
-Once the connection has been established,
-.Pa /dev/ttyp1
+Once the connection has been established, a
+.Xr pts 4
can be used to talk to the remote serial port on the server.
+.Nm
+prints the name of the
+.Xr pts 4
+to use on stdout.
.Sh SEE ALSO
.Xr bluetooth 3 ,
.Xr ng_btsocket 4 ,
-.Xr pty 4 ,
+.Xr pts 4 ,
.Xr rfcomm_pppd 8 ,
.Xr sdpd 8
.Sh AUTHORS
Property changes on: trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c
===================================================================
--- trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c 2018-07-07 17:41:00 UTC (rev 11502)
+++ trunk/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c 2018-07-07 17:41:37 UTC (rev 11503)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* rfcomm_sppd.c
*/
@@ -27,11 +28,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: rfcomm_sppd.c,v 1.2 2012-11-23 01:13:49 laffer1 Exp $
- * $MidnightBSD$
+ * $Id: rfcomm_sppd.c,v 1.4 2003/09/07 18:15:55 max Exp $
+ * $FreeBSD: stable/10/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c 274182 2014-11-06 16:32:00Z emax $
*/
#include <sys/stat.h>
+#include <sys/types.h>
#include <bluetooth.h>
#include <ctype.h>
#include <err.h>
@@ -49,6 +51,7 @@
#include <syslog.h>
#include <termios.h>
#include <unistd.h>
+#include <libutil.h>
#define SPPD_IDENT "rfcomm_sppd"
#define SPPD_BUFFER_SIZE 1024
@@ -58,7 +61,7 @@
bdaddr_t const *remote,
int service, int *channel, int *error);
-static int sppd_ttys_open (char const *tty, int *amaster, int *aslave);
+static int sppd_ttys_open (char **tty, int *amaster, int *aslave);
static int sppd_read (int fd, char *buffer, int size);
static int sppd_write (int fd, char *buffer, int size);
static void sppd_sighandler (int s);
@@ -74,7 +77,8 @@
struct sockaddr_rfcomm ra;
bdaddr_t addr;
int n, background, channel, service,
- s, amaster, aslave, fd, doserver;
+ s, amaster, aslave, fd, doserver,
+ dopty;
fd_set rfd;
char *tty = NULL, *ep = NULL, buf[SPPD_BUFFER_SIZE];
@@ -82,9 +86,10 @@
background = channel = 0;
service = SDP_SERVICE_CLASS_SERIAL_PORT;
doserver = 0;
+ dopty = 0;
/* Parse command line options */
- while ((n = getopt(argc, argv, "a:bc:t:hS")) != -1) {
+ while ((n = getopt(argc, argv, "a:bc:thS")) != -1) {
switch (n) {
case 'a': /* BDADDR */
if (!bt_aton(optarg, &addr)) {
@@ -130,11 +135,8 @@
background = 1;
break;
- case 't': /* Slave TTY name */
- if (optarg[0] != '/')
- asprintf(&tty, "%s%s", _PATH_DEV, optarg);
- else
- tty = optarg;
+ case 't': /* Open pseudo TTY */
+ dopty = 1;
break;
case 'S':
@@ -173,18 +175,18 @@
err(1, "Could not sigaction(SIGCHLD)");
/* Open TTYs */
- if (tty == NULL) {
+ if (dopty) {
+ if (sppd_ttys_open(&tty, &amaster, &aslave) < 0)
+ exit(1);
+
+ fd = amaster;
+ } else {
if (background)
usage();
amaster = STDIN_FILENO;
fd = STDOUT_FILENO;
- } else {
- if (sppd_ttys_open(tty, &amaster, &aslave) < 0)
- exit(1);
-
- fd = amaster;
- }
+ }
/* Open RFCOMM connection */
@@ -287,6 +289,10 @@
openlog(SPPD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON);
syslog(LOG_INFO, "Starting on %s...", (tty != NULL)? tty : "stdin/stdout");
+ /* Print used tty on stdout for wrappers to pick up */
+ if (!background)
+ fprintf(stdout, "%s\n", tty);
+
for (done = 0; !done; ) {
FD_ZERO(&rfd);
FD_SET(amaster, &rfd);
@@ -359,70 +365,20 @@
/* Open TTYs */
static int
-sppd_ttys_open(char const *tty, int *amaster, int *aslave)
+sppd_ttys_open(char **tty, int *amaster, int *aslave)
{
- char pty[PATH_MAX], *slash;
- struct group *gr = NULL;
- gid_t ttygid;
+ char pty[PATH_MAX];
struct termios tio;
- /*
- * Construct master PTY name. The slave tty name must be less then
- * PATH_MAX characters in length, must contain '/' character and
- * must not end with '/'.
- */
+ cfmakeraw(&tio);
- if (strlen(tty) >= sizeof(pty)) {
- syslog(LOG_ERR, "Slave tty name is too long");
+ if (openpty(amaster, aslave, pty, &tio, NULL) == -1) {
+ syslog(LOG_ERR, "Could not openpty(). %s", strerror(errno));
return (-1);
}
- strlcpy(pty, tty, sizeof(pty));
- slash = strrchr(pty, '/');
- if (slash == NULL || slash[1] == '\0') {
- syslog(LOG_ERR, "Invalid slave tty name (%s)", tty);
- return (-1);
- }
-
- slash[1] = 'p';
-
- if (strcmp(pty, tty) == 0) {
- syslog(LOG_ERR, "Master and slave tty are the same (%s)", tty);
- return (-1);
- }
-
- if ((*amaster = open(pty, O_RDWR, 0)) < 0) {
- syslog(LOG_ERR, "Could not open(%s). %s", pty, strerror(errno));
- return (-1);
- }
-
- /*
- * Slave TTY
- */
-
- if ((gr = getgrnam("tty")) != NULL)
- ttygid = gr->gr_gid;
- else
- ttygid = -1;
-
- (void) chown(tty, getuid(), ttygid);
- (void) chmod(tty, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
- (void) revoke(tty);
-
- if ((*aslave = open(tty, O_RDWR, 0)) < 0) {
- syslog(LOG_ERR, "Could not open(%s). %s", tty, strerror(errno));
- close(*amaster);
- return (-1);
- }
-
- /*
- * Make slave TTY raw
- */
-
- cfmakeraw(&tio);
-
- if (tcsetattr(*aslave, TCSANOW, &tio) < 0) {
- syslog(LOG_ERR, "Could not tcsetattr(). %s", strerror(errno));
+ if ((*tty = strdup(pty)) == NULL) {
+ syslog(LOG_ERR, "Could not strdup(). %s", strerror(errno));
close(*aslave);
close(*amaster);
return (-1);
@@ -496,7 +452,7 @@
"\t-a address Peer address (required in client mode)\n" \
"\t-b Run in background\n" \
"\t-c channel RFCOMM channel to connect to or listen on\n" \
-"\t-t tty TTY name (required in background mode)\n" \
+"\t-t use slave pseudo tty (required in background mode)\n" \
"\t-S Server mode\n" \
"\t-h Display this message\n", SPPD_IDENT);
exit(255);
More information about the Midnightbsd-cvs
mailing list