aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@redhat.com>2001-02-28 10:05:50 +0000
committerNalin Dahyabhai <nalin@redhat.com>2001-02-28 10:05:50 +0000
commitd27070adf5d0681060d6c9615018c01a374fc8c9 (patch)
treeb4d60538bfb2d21b74a65802264342932527b539 /src
parent7c28717f1a644bec5cd6ed0e549005b3df49b352 (diff)
downloadinitscripts-d27070adf5d0681060d6c9615018c01a374fc8c9.tar
initscripts-d27070adf5d0681060d6c9615018c01a374fc8c9.tar.gz
initscripts-d27070adf5d0681060d6c9615018c01a374fc8c9.tar.bz2
initscripts-d27070adf5d0681060d6c9615018c01a374fc8c9.tar.xz
initscripts-d27070adf5d0681060d6c9615018c01a374fc8c9.zip
use O_NOFOLLOW
Diffstat (limited to 'src')
-rw-r--r--src/netreport.c16
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;
}