Attempting to show the hosts file

This commit is contained in:
Jacob Windle 2019-02-23 19:41:47 -05:00
parent aa7697833e
commit 7c0f494f40

23
main.c
View File

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