From 29a9fee1ec78d4a7812c0b195d12a23b5d6a8094 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 15 Aug 2000 20:00:14 +0000 Subject: be more careful about netreport files --- initscripts.spec | 7 +++++-- src/netreport.c | 11 ++++++++--- 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 +- be more careful about creating files in netreport (#16164) + * Sat Aug 11 2000 Nalin Dahyabhai - 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 #include #include +#include #include #include @@ -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"); -- cgit v1.2.1