From 7c0f494f4004a9fe2d2876d8febdc5b29f0adb0d Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Sat, 23 Feb 2019 19:41:47 -0500 Subject: [PATCH] Attempting to show the hosts file --- main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.c b/main.c index 0e1f551..b543f20 100644 --- a/main.c +++ b/main.c @@ -3,6 +3,7 @@ #include #include #include +#include const char *blockString = "0.0.0.0 "; @@ -41,6 +42,24 @@ void usage() fprintf(stdout, "hb [add] \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)