diff options
| -rw-r--r-- | hcid/hcid.conf | 8 | ||||
| -rw-r--r-- | hcid/hcid.conf.5 | 20 | ||||
| -rw-r--r-- | hcid/hcid.h | 5 | ||||
| -rw-r--r-- | hcid/kword.c | 4 | ||||
| -rw-r--r-- | hcid/main.c | 9 | ||||
| -rw-r--r-- | hcid/parser.y | 17 | ||||
| -rw-r--r-- | hcid/security.c | 108 | 
7 files changed, 13 insertions, 158 deletions
diff --git a/hcid/hcid.conf b/hcid/hcid.conf index 65e3d816..f15c02ec 100644 --- a/hcid/hcid.conf +++ b/hcid/hcid.conf @@ -21,13 +21,7 @@ options {  	pairing multi;  	# Default PIN code for incoming connections -	pin_code "BlueZ"; - -	# PIN helper -	pin_helper /usr/bin/bluepin; - -	# D-Bus PIN helper -	#dbus_pin_helper; +	passkey "BlueZ";  }  # Default settings for HCI devices diff --git a/hcid/hcid.conf.5 b/hcid/hcid.conf.5 index b6934746..085d50b7 100644 --- a/hcid/hcid.conf.5 +++ b/hcid/hcid.conf.5 @@ -46,30 +46,12 @@ successive attempts. The default hcid configuration is shipped with \fBmulti\fP  enabled  .TP -\fBpin_code\fP "\fIpin\fP" +\fBpasskey\fP "\fIpin\fP"  The default PIN for incoming connections if \fBsecurity\fP has been  set to \fIauto\fP.  .TP  -\fBpin_helper\fP "\fIfile\fP" - -The path to the PIN helper application. The default is "/bin/bluepin". -The following output is expected from the PIN helper: - -PIN:12345678 - -Or, when no PIN is available: - -ERR - -.TP  -\fBdbus_pin_helper\fP - -Declaring this parameter enables the D-BUS message bus system for PIN -requests. - -.TP   \fBsecurity\fP  none|auto|user  \fInone\fP means the security manager is disabled. \fIauto\fP uses diff --git a/hcid/hcid.h b/hcid/hcid.h index 1483c6ba..b4e6f290 100644 --- a/hcid/hcid.h +++ b/hcid/hcid.h @@ -34,8 +34,6 @@  #define HCID_CONFIG_FILE CONFIGDIR "/hcid.conf" -#define HCID_PIN_HELPER  "/usr/bin/bluepin" -  enum {  	HCID_SET_NAME,  	HCID_SET_CLASS, @@ -82,9 +80,6 @@ struct hcid_opts {  	uint8_t pin_code[16];  	int     pin_len; -	char   *pin_helper; -	int     dbus_pin_helper; -  	int     sock;  };  extern struct hcid_opts hcid; diff --git a/hcid/kword.c b/hcid/kword.c index f7a3f66e..32fd5571 100644 --- a/hcid/kword.c +++ b/hcid/kword.c @@ -60,9 +60,7 @@ struct kword cfg_keyword[] = {  	{ "pageto",		K_PAGETO	},  	{ "auth",		K_AUTH		},  	{ "encrypt",		K_ENCRYPT	}, -	{ "pin_code",		K_PINCODE	}, -	{ "pin_helper",		K_PINHELP	}, -	{ "dbus_pin_helper",	K_DBUSPINHELP	}, +	{ "passkey",		K_PASSKEY	},  	{ "yes",		K_YES		},  	{ "no",			K_NO		}, diff --git a/hcid/main.c b/hcid/main.c index 93edb232..842a5826 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -566,8 +566,6 @@ int main(int argc, char *argv[], char *env[])  	strcpy((char *) hcid.pin_code, "BlueZ");  	hcid.pin_len = 5; -	hcid.pin_helper  = strdup(HCID_PIN_HELPER); -  	init_defaults();  	while ((opt = getopt(argc, argv, "nsf:")) != EOF) { @@ -660,15 +658,10 @@ int main(int argc, char *argv[], char *env[])  	init_devices();  #ifdef ENABLE_DBUS -	if (hcid_dbus_init() == FALSE && hcid.dbus_pin_helper) { +	if (hcid_dbus_init() == FALSE) {  		error("Unable to get on D-Bus");  		exit(1);  	} -#else -	if (hcid.dbus_pin_helper) { -		error("D-Bus not configured in this build of hcid"); -		exit(1); -	}  #endif  	init_security_data(); diff --git a/hcid/parser.y b/hcid/parser.y index 60dd986f..60bbe224 100644 --- a/hcid/parser.y +++ b/hcid/parser.y @@ -60,7 +60,7 @@ int yyerror(char *s);  %token K_OPTIONS K_DEVICE  %token K_AUTOINIT K_SECURITY K_PAIRING  %token K_PTYPE K_NAME K_CLASS K_VOICE K_INQMODE K_PAGETO K_LM K_LP K_AUTH K_ENCRYPT K_ISCAN K_PSCAN -%token K_PINCODE K_PINHELP K_DBUSPINHELP +%token K_PASSKEY  %token K_YES K_NO  %token <str> WORD PATH STRING LIST HCI BDADDR @@ -114,26 +114,13 @@ hcid_opt:  				hcid.pairing = $2;  			} -  | K_PINCODE STRING	{ +  | K_PASSKEY STRING	{    				strncpy((char *) hcid.pin_code, $2, 16);  				hcid.pin_len = strlen($2);  				if (hcid.pin_len > 16)  					hcid.pin_len = 16;  			} -  | K_PINHELP PATH	{ -				if (hcid.pin_helper) -					free(hcid.pin_helper); -				hcid.pin_helper = strdup($2); -				hcid.dbus_pin_helper = 0; -			} - -  | K_DBUSPINHELP	{ -				if (hcid.pin_helper) -					free(hcid.pin_helper); -				hcid.pin_helper = NULL; -				hcid.dbus_pin_helper = 1; -			}    | WORD		{  				cfg_error("Unknown option '%s'", $1); diff --git a/hcid/security.c b/hcid/security.c index 0c8fd777..f6d409f6 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -202,97 +202,13 @@ void set_pin_length(bdaddr_t *sba, int length)  	io_data[dev_id].pin_length = length;  } -/* -  PIN helper is an external app that asks user for a PIN. It can  -  implement its own PIN  code generation policy and methods like -  PIN look up in some database, etc.  -  HCId expects following output from PIN helper: -	PIN:12345678	-	PIN code -	ERR		-	No PIN available -*/ - +#ifndef ENABLE_DBUS  static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)  {  	pin_code_reply_cp pr; -	struct sigaction sa; -	char addr[18], str[512], *pin, name[249], tmp[497], *ptr; -	FILE *pipe; -	int i, ret, len; - -	/* Run PIN helper in the separate process */ -	switch (fork()) { -		case 0: -			break; -		case -1: -			error("Can't fork PIN helper: %s (%d)", -							strerror(errno), errno); -		default: -			return; -	} - -	if (access(hcid.pin_helper, R_OK | X_OK)) { -		error("Can't exec PIN helper %s: %s (%d)", -					hcid.pin_helper, strerror(errno), errno); -		goto reject; -	} - -	memset(name, 0, sizeof(name)); -	read_device_name(sba, &ci->bdaddr, name); -	//hci_remote_name(dev, &ci->bdaddr, sizeof(name), name, 0); - -	memset(tmp, 0, sizeof(tmp)); -	ptr = tmp; - -	for (i = 0; i < 248 && name[i]; i++) -		if (isprint(name[i])) { -			switch (name[i]) { -			case '"': -			case '`': -			case '$': -			case '|': -			case '>': -			case '<': -			case '&': -			case ';': -			case '\\': -				*ptr++ = '\\'; -			} -			*ptr++ = name[i]; -		} else { -			name[i] = '.'; -			*ptr++ = '.'; -		} - -	ba2str(&ci->bdaddr, addr); -	snprintf(str, sizeof(str), "%s %s %s \"%s\"", hcid.pin_helper, -					ci->out ? "out" : "in", addr, tmp); - -	setenv("PATH", "/bin:/usr/bin:/usr/local/bin", 1); - -	memset(&sa, 0, sizeof(sa)); -	sa.sa_flags = SA_NOCLDSTOP; -	sa.sa_handler = SIG_DFL; -	sigaction(SIGCHLD, &sa, NULL); - -	pipe = popen(str, "r"); -	if (!pipe) { -		error("Can't exec PIN helper: %s (%d)", -							strerror(errno), errno); -		goto reject; -	} - -	pin = fgets(str, sizeof(str), pipe); -	ret = pclose(pipe); +	char *pin = "BlueZ"; +	int len; -	if (!pin || strlen(pin) < 5) -		goto nopin; - -	strtok(pin, "\n\r"); - -	if (strncmp("PIN:", pin, 4)) -		goto nopin; - -	pin += 4;  	len  = strlen(pin);  	set_pin_length(sba, len); @@ -303,26 +219,16 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)  	pr.pin_len = len;  	hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_REPLY,  			PIN_CODE_REPLY_CP_SIZE, &pr); -	exit(0); - -nopin: -	if (!pin || strncmp("ERR", pin, 3)) -		error("PIN helper exited abnormally with code %d", ret); - -reject: -	hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &ci->bdaddr); -	exit(0);  } +#endif  static void request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)  {  #ifdef ENABLE_DBUS -	if (hcid.dbus_pin_helper) { -		hcid_dbus_request_pin(dev, sba, ci); -		return; -	} -#endif +	hcid_dbus_request_pin(dev, sba, ci); +#else  	call_pin_helper(dev, sba, ci); +#endif  }  static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)  | 
