Attempting to show the hosts file

pull/4/head
Jacob Windle 2019-02-23 19:41:47 -05:00
parent aa7697833e
commit 7c0f494f40
1 changed files with 23 additions and 0 deletions

23
main.c
View File

@ -3,6 +3,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
const char *blockString = "0.0.0.0 ";
@ -41,6 +42,24 @@ void usage()
fprintf(stdout, "hb [add] <sitename>\n");
}
void showHosts()
{
pid_t child = fork();
int rc = 0;
char * argv[] = {
"/etc/hosts"
};
if (child == 0)
{
execv("/bin/cat", argv);
}
else
{
rc = wait(NULL);
}
}
/**
* Entrypoint.
*/
@ -69,6 +88,10 @@ int main(int argc, char **argv)
usage();
exit(0);
}
else
{
showHosts();
}
}
if (hostsFile != NULL)