diff options
author | Bill Nottingham <notting@redhat.com> | 2001-03-30 17:23:34 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2001-03-30 17:23:34 +0000 |
commit | e2446c6407f9f339f89cd2968577d2aa7bdb943c (patch) | |
tree | 11a303dd2432b98f83fef578a18f327eba1ec6a7 /src | |
parent | b1ca0e293ef0a5d3d325f49dc02d4b80577dd13c (diff) | |
download | initscripts-e2446c6407f9f339f89cd2968577d2aa7bdb943c.tar initscripts-e2446c6407f9f339f89cd2968577d2aa7bdb943c.tar.gz initscripts-e2446c6407f9f339f89cd2968577d2aa7bdb943c.tar.bz2 initscripts-e2446c6407f9f339f89cd2968577d2aa7bdb943c.tar.xz initscripts-e2446c6407f9f339f89cd2968577d2aa7bdb943c.zip |
use O_NOFOLLOW
Diffstat (limited to 'src')
-rw-r--r-- | src/netreport.c | 16 |
1 files changed, 9 insertions, 7 deletions
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; } |