aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@redhat.com>2000-08-15 20:00:14 +0000
committerNalin Dahyabhai <nalin@redhat.com>2000-08-15 20:00:14 +0000
commit29a9fee1ec78d4a7812c0b195d12a23b5d6a8094 (patch)
treed908c1bb649f5e937f88cf4b17e07ebd63aabc0a /src
parentdfe1994884c319f0ff97e6598289994243fa7f5c (diff)
downloadinitscripts-29a9fee1ec78d4a7812c0b195d12a23b5d6a8094.tar
initscripts-29a9fee1ec78d4a7812c0b195d12a23b5d6a8094.tar.gz
initscripts-29a9fee1ec78d4a7812c0b195d12a23b5d6a8094.tar.bz2
initscripts-29a9fee1ec78d4a7812c0b195d12a23b5d6a8094.tar.xz
initscripts-29a9fee1ec78d4a7812c0b195d12a23b5d6a8094.zip
be more careful about netreport files
Diffstat (limited to 'src')
-rw-r--r--src/netreport.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/netreport.c b/src/netreport.c
index c11af5a5..7f1d964a 100644
--- a/src/netreport.c
+++ b/src/netreport.c
@@ -1,6 +1,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -21,16 +22,20 @@ int main(int argc, char ** argv) {
if (argc > 2) usage();
- if (argc > 1)
+ if (argc > 1) {
if (!strcmp(argv[1], "-r")) {
action = DEL;
} else {
usage();
}
+ }
- sprintf(netreport_name, "/var/run/netreport/%d", getppid());
+ snprintf(netreport_name, sizeof(netreport_name),
+ "/var/run/netreport/%d", getppid());
if (action == ADD) {
- netreport_file = creat(netreport_name, 0);
+ netreport_file = open(netreport_name,
+ O_EXCL | O_CREAT | O_WRONLY | O_TRUNC,
+ 0);
if (netreport_file < 0) {
if (errno != EEXIST) {
perror("Could not create netreport file");