Commit fcea6880 authored by Edward Bartolo's avatar Edward Bartolo

Edited file file_functions.c function queryConnect to also list a connection's…

Edited file file_functions.c function queryConnect to also list a connection's security status. The latter is described as a comment as the top line.
parent 5d79e775
......@@ -215,8 +215,10 @@ int queryConnect(
char * essid
) {
int err;
char file_pathname[1024];
char command[1024];
char * encoded_essid;
FILE* shell_reader = NULL;
char read_buffer[1024];
err = encode_essid_alloc(essid, &encoded_essid);
if ( ERROR(err, "FN0001") )
......@@ -231,8 +233,13 @@ int queryConnect(
}
err = snprintf(
file_pathname, 1024, "%s/%s",
IFACES_PATH, encoded_essid
command,
1024,
"/usr/bin/head -n 1 %s/%s; /bin/grep -A1 \"ssid\" %s/%s",
IFACES_PATH,
encoded_essid,
IFACES_PATH,
encoded_essid
);
essid_free(encoded_essid);
......@@ -240,8 +247,24 @@ int queryConnect(
ERROR(-1, "FN0003");
}
err = execl("/bin/grep", "grep", "-A1", "ssid", file_pathname, (char *) NULL);
ERROR(err, "FN0004");
shell_reader = popen(command, "r");
if (shell_reader == NULL) {
return ERROR_PTR_INVALID(shell_reader, errno, "FN0004");
}
char* pos;
while (fgets(read_buffer, 1024, shell_reader)) {
pos = strstr(read_buffer, "\t");
// line break is already in the read lines
if (pos != NULL)
printf( (char*) (pos + 1) );
else printf(read_buffer);
}
err = pclose(shell_reader);
if (err == -1)
return ERROR(errno, "FN0005");
return err;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment