aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--initscripts.spec7
-rw-r--r--src/netreport.c11
2 files changed, 13 insertions, 5 deletions
diff --git a/initscripts.spec b/initscripts.spec
index 6985fa44..72aa5e69 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -1,9 +1,9 @@
Summary: The inittab file and the /etc/init.d scripts.
Name: initscripts
-Version: 5.44
+Version: 5.45
Copyright: GPL
Group: System Environment/Base
-Release: 2
+Release: 1
Source: initscripts-%{version}.tar.gz
BuildRoot: /%{_tmppath}/%{name}-%{version}-%{release}-root
Requires: mingetty, /bin/awk, /bin/sed, mktemp, e2fsprogs >= 1.15
@@ -232,6 +232,9 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0664,root,utmp) /var/run/utmp
%changelog
+* Tue Aug 15 2000 Nalin Dahyabhai <nalin@redhat.com>
+- be more careful about creating files in netreport (#16164)
+
* Sat Aug 11 2000 Nalin Dahyabhai <nalin@redhat.com>
- move documentation for the DEMAND and IDLETIMEOUT values to the right
section of sysconfig.txt
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");