From e2446c6407f9f339f89cd2968577d2aa7bdb943c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 30 Mar 2001 17:23:34 +0000 Subject: use O_NOFOLLOW --- src/netreport.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/netreport.c b/src/netreport.c index 7f1d964a..cceedc3a 100644 --- a/src/netreport.c +++ b/src/netreport.c @@ -7,7 +7,8 @@ /* this will be running setgid root, so be careful! */ -void usage(void) { +static void +usage(void) { fprintf(stderr, "usage: netreport [-r]\n"); exit(1); } @@ -20,10 +21,12 @@ int main(int argc, char ** argv) { char netreport_name[64]; int netreport_file; - if (argc > 2) usage(); + if (argc > 2) { + usage(); + } if (argc > 1) { - if (!strcmp(argv[1], "-r")) { + if (strcmp(argv[1], "-r") == 0) { action = DEL; } else { usage(); @@ -34,9 +37,8 @@ int main(int argc, char ** argv) { "/var/run/netreport/%d", getppid()); if (action == ADD) { netreport_file = open(netreport_name, - O_EXCL | O_CREAT | O_WRONLY | O_TRUNC, - 0); - if (netreport_file < 0) { + O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0); + if (netreport_file == -1) { if (errno != EEXIST) { perror("Could not create netreport file"); exit (1); @@ -49,5 +51,5 @@ int main(int argc, char ** argv) { unlink(netreport_name); } - exit(0); + return 0; } -- cgit v1.2.1