From d27070adf5d0681060d6c9615018c01a374fc8c9 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 28 Feb 2001 10:05:50 +0000 Subject: use O_NOFOLLOW --- src/netreport.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/netreport.c') 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