summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Krasnyansky <maxk@qualcomm.com>2002-06-24 02:52:27 +0000
committerMax Krasnyansky <maxk@qualcomm.com>2002-06-24 02:52:27 +0000
commitccb0bf6ad34beb532176a49731537f09fe01875c (patch)
treea2d84623ef5aa94c2461c93668bfb0e00c7fee18
parentf79b2c879c633667916d1fb17870c54597294d8e (diff)
Reload PIN code on SIGHUP.
More cleanups.
-rw-r--r--hcid/hcid.h1
-rw-r--r--hcid/main.c22
-rw-r--r--hcid/security.c30
3 files changed, 24 insertions, 29 deletions
diff --git a/hcid/hcid.h b/hcid/hcid.h
index 40dc6ad0..0715db28 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -82,6 +82,7 @@ int read_config(char *file);
gboolean io_stack_event(GIOChannel *chan, GIOCondition cond, gpointer data);
gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer data);
+void init_security_data(void);
void start_security_manager(int hdev);
void stop_security_manager(int hdev);
void flush_link_keys(void);
diff --git a/hcid/main.c b/hcid/main.c
index 1f2537fb..37e6cf65 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -264,6 +264,8 @@ static void sig_hup(int sig)
if (read_config(hcid.config_file) < 0)
syslog(LOG_ERR, "Config reload failed");
+ init_security_data();
+
init_all_devices(hcid.sock);
}
@@ -364,17 +366,17 @@ int main(int argc, char *argv[], char *env[])
while ((opt=getopt(argc,argv,"f:n")) != EOF) {
switch(opt) {
- case 'n':
- daemon = 0;
- break;
+ case 'n':
+ daemon = 0;
+ break;
- case 'f':
- hcid.config_file = strdup(optarg);
- break;
+ case 'f':
+ hcid.config_file = strdup(optarg);
+ break;
- default:
- usage();
- exit(1);
+ default:
+ usage();
+ exit(1);
}
}
@@ -440,6 +442,8 @@ int main(int argc, char *argv[], char *env[])
if (read_config(hcid.config_file) < 0)
syslog(LOG_ERR, "Config load failed");
+ init_security_data();
+
/* Create event loop */
event_loop = g_main_new(FALSE);
diff --git a/hcid/security.c b/hcid/security.c
index a980b500..75e44421 100644
--- a/hcid/security.c
+++ b/hcid/security.c
@@ -352,24 +352,6 @@ gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer data)
return TRUE;
}
-static void init_security_data(void)
-{
- static int initialized = 0;
-
- if (initialized)
- return;
- initialized = 1;
-
- /* Set local PIN code */
- if (hcid.security == HCID_SEC_AUTO) {
- if (read_pin_code() < 0) {
- strcpy(hcid.pin_code, "bluez");
- hcid.pin_len = 5;
- }
- }
- return;
-}
-
void start_security_manager(int hdev)
{
GIOChannel *chan = io_chan[hdev];
@@ -382,8 +364,6 @@ void start_security_manager(int hdev)
syslog(LOG_INFO, "Starting security manager %d", hdev);
- init_security_data();
-
if ((dev = hci_open_dev(hdev)) < 0) {
syslog(LOG_ERR, "Can't open device hci%d. %s(%d)",
hdev, strerror(errno), errno);
@@ -438,3 +418,13 @@ void stop_security_manager(int hdev)
close(g_io_channel_unix_get_fd(chan));
io_chan[hdev] = NULL;
}
+
+void init_security_data(void)
+{
+ /* Set local PIN code */
+ if (read_pin_code() < 0) {
+ strcpy(hcid.pin_code, "BlueZ");
+ hcid.pin_len = 5;
+ }
+ return;
+}