config files

Iain Hibbert plunky at rya-online.net
Tue Mar 14 08:48:29 UTC 2006


On Mon, 13 Mar 2006, Maksim Yevmenkin wrote:

> > Its just that to add a mouse to the system, I needed to enter details in 3
> > files (and, details are held in two more) which could be considered a bit
> > much just for a mouse :)
>
> 3 files, i assume, are: /etc/bluetooth/hosts, /etc/bluetooth/hcsecd.conf and
> /etc/bluetooth/bthidd.conf. entry in /etc/bluetooth/hosts file is optional.
>
> i'm not sure which other 2 files you are talking about.

/var/db/bthcid.keys & /var/db/bthidd.hids

which are automatic, though may need attention when batteries are changed?

> > vaguely related to this, would the attached patch work to reload
> > bthidd.conf on SIGHUP? It seems that it should, though I'm not sure if the
> > fact that the new_device field is set would be an issue (maybe not, if the
> > session already exists?)
>
> there is one problem with this particular patch. please see my comments inline

Ok, this should be better - seems to work for me, thanks!

(also you may need to enable "reload" in /etc/rc.d/bthidd?)

--

On another issue, in libsdp/session.c you have

	sa.l2cap_psm = htole16(NG_L2CAP_PSM_SDP);

which seems wrong? (will work ok on little endian machine)

iain
-------------- next part --------------
--- bthidd.c	2004-11-18 18:05:15.000000000 +0000
+++ bthidd.c	2006-03-14 08:04:09.000000000 +0000
@@ -49,13 +49,15 @@
 static int	remove_pid_file	(char const *file);
 static int	elapsed		(int tval);
 static void	sighandler	(int s);
+static void	sighup		(int s);
 static void	usage		(void);
 
 /*
  * bthidd
  */
 
-static int	done = 0; /* are we done? */
+static int	done = 0;	/* are we done? */
+static int	reload = 0;	/* reload config file */
 
 int
 main(int argc, char *argv[])
@@ -137,13 +139,19 @@
 	sa.sa_handler = sighandler;
 
 	if (sigaction(SIGTERM, &sa, NULL) < 0 ||
-	    sigaction(SIGHUP, &sa, NULL) < 0 ||
 	    sigaction(SIGINT, &sa, NULL) < 0) {
 		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
 			strerror(errno), errno);
 		exit(1);
 	}
 
+	sas.sa_handler = sighup;
+	if (sigaction(SIGHUP, &sa, NULL) < 0) {
+		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
+			strerror(errno), errno);
+		exit(1);
+	}
+
 	sa.sa_handler = SIG_IGN;
 	if (sigaction(SIGPIPE, &sa, NULL) < 0) {
 		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
@@ -169,6 +177,15 @@
 
 		if (server_do(&srv) < 0)
 			break;
+
+		if (reload) {
+			if (write_hids_file() < 0 ||
+			    read_config_file() < 0 ||
+			    read_hids_file() < 0)
+				break;
+
+			reload = 0;
+		}
 	}
 
 	server_shutdown(&srv);
@@ -241,7 +258,7 @@
 }
 
 /*
- * Signal handler
+ * Signal handlers
  */
 
 static void
@@ -251,6 +268,13 @@
 		s, ++ done);
 }
 
+static void
+sighup(int s)
+{
+	syslog(LOG_NOTICE, "Got SIGHUP: reload config");
+	reload = 1;
+}
+
 /*
  * Display usage and exit
  */


More information about the freebsd-bluetooth mailing list