Merge pull request #4038 from igungor/lakka-connman-fix
Fix parsing of connmanctl output
This commit is contained in:
commit
9268a9651d
|
@ -130,21 +130,37 @@ static bool connmanctl_ssid_is_online(unsigned i)
|
|||
static bool connmanctl_connect_ssid(unsigned i, const char* passphrase)
|
||||
{
|
||||
char ln[512] = {0};
|
||||
char name[20] = {0};
|
||||
char name[64] = {0};
|
||||
char service[128] = {0};
|
||||
char command[256] = {0};
|
||||
char settings_dir[PATH_MAX_LENGTH] = {0};
|
||||
char settings_path[PATH_MAX_LENGTH] = {0};
|
||||
FILE *command_file = NULL;
|
||||
FILE *settings_file = NULL;
|
||||
FILE *serv_file = NULL;
|
||||
union string_list_elem_attr attr;
|
||||
const char *line = lines->elems[i].data;
|
||||
|
||||
strlcpy(name, line+4, sizeof(name));
|
||||
strlcpy(name, string_trim_whitespace(name), sizeof(name));
|
||||
static struct string_list* list = NULL;
|
||||
// connmanctl services outputs a 4 character prefixed lines, either whispace
|
||||
// or an identifier. i.e.:
|
||||
// $ connmanctl services
|
||||
// '*A0 SSID some_unique_id'
|
||||
// ' SSID some_another_unique_id'
|
||||
list = string_split(line+4, " ");
|
||||
if(!list)
|
||||
return false;
|
||||
|
||||
strlcpy(service, line+25, sizeof(service));
|
||||
if (list->size == 0) {
|
||||
string_list_free(list);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list->size-1; i++) {
|
||||
strlcat(name, list->elems[i].data, sizeof(name));
|
||||
strlcat(name, " ", sizeof(name));
|
||||
}
|
||||
strlcpy(service, list->elems[list->size-1].data, sizeof(service));
|
||||
|
||||
string_list_free(list);
|
||||
|
||||
strlcat(settings_dir, LAKKA_CONNMAN_DIR, sizeof(settings_dir));
|
||||
strlcat(settings_dir, service, sizeof(settings_dir));
|
||||
|
|
Loading…
Reference in New Issue