View | Details | Raw Unified | Return to bug 11090
Collapse All | Expand All

(-)bluez-utils-3.9.orig/daemon/passkey-agent.c (-4 / +38 lines)
Lines 77-82 static DBusHandlerResult request_message Link Here
77
	DBusMessage *reply;
77
	DBusMessage *reply;
78
	const char *path, *address;
78
	const char *path, *address;
79
	dbus_bool_t numeric;
79
	dbus_bool_t numeric;
80
 	char *buffer;
81
 	FILE *pin;
82
 	unsigned int buflen;
83
 	int status;
84
 	char *s_passkey;
80
85
81
	if (!passkey)
86
	if (!passkey)
82
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
87
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
Lines 95-102 static DBusHandlerResult request_message Link Here
95
	}
100
	}
96
101
97
	printf("Passkey request for device %s\n", address);
102
	printf("Passkey request for device %s\n", address);
103
    buflen=strlen(passkey)+256;
104
    if(buflen<=256)
105
    {
106
        fprintf(stderr, "Invalid pin-helper argument, aborting.");
107
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
108
    }
109
    buffer=malloc(buflen);
110
    if(buffer==NULL)
111
    {
112
        fprintf(stderr, "Error allocating memory (malloc), aborting.");
113
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
114
    }
115
    sprintf(buffer, "%s %s %s", passkey, "in", address);
116
    pin=popen(buffer, "r");
117
    wait(&status);
118
    fgets(buffer, 256, pin);
119
    pclose(pin);
120
    if(buffer[0]!='P' || buffer[1]!='I' || buffer[2]!='N' || buffer[3]!=':')
121
    {
122
      free(buffer);
123
      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
124
    }
125
    s_passkey=&buffer[4];
126
    if(s_passkey[strlen(s_passkey)-1]=='\n') s_passkey[strlen(s_passkey)-1]='\0';
127
    fprintf(stderr, "Found passkey: \"%s\"\n", s_passkey);
98
128
99
	dbus_message_append_args(reply, DBUS_TYPE_STRING, &passkey,
129
130
	dbus_message_append_args(reply, DBUS_TYPE_STRING, &s_passkey ,
100
					DBUS_TYPE_INVALID);
131
					DBUS_TYPE_INVALID);
101
132
102
	dbus_connection_send(conn, reply, NULL);
133
	dbus_connection_send(conn, reply, NULL);
Lines 104-110 static DBusHandlerResult request_message Link Here
104
	dbus_connection_flush(conn);
135
	dbus_connection_flush(conn);
105
136
106
	dbus_message_unref(reply);
137
	dbus_message_unref(reply);
107
138
        free(buffer);
108
	return DBUS_HANDLER_RESULT_HANDLED;
139
	return DBUS_HANDLER_RESULT_HANDLED;
109
}
140
}
110
141
Lines 334-343 static int unregister_agent(DBusConnecti Link Here
334
365
335
static void usage(void)
366
static void usage(void)
336
{
367
{
337
	printf("Bluetooth passkey agent ver %s\n\n", VERSION);
368
	printf("Bluetooth passkey agent ver %s with \"exec\" patch from Marco Gulino (http://www.kmobiletools.org/node/228)\n\n", VERSION);
338
369
339
	printf("Usage:\n"
370
	printf("Usage:\n"
340
		"\tpasskey-agent [--default] [--path agent-path] <passkey> [address]\n"
371
		"\tpasskey-agent {-d|--default} [{-p|--path} agent-path] <path-to-pin-helper>\n"
372
		"\tpasskey-agent [{-p|--path} agent-path] <path-to-pin-helper> address\n"
373
		"\n"
374
		"\tDefault for agent-path: /org/bluez/passkey_agent_<program pid>\n"
341
		"\n");
375
		"\n");
342
}
376
}
343
377

Return to bug 11090