Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cron set close on exec on a couple of FDs. from Cha...



details:   https://anonhg.NetBSD.org/src/rev/417360bbc1fa
branches:  trunk
changeset: 545181:417360bbc1fa
user:      perry <perry%NetBSD.org@localhost>
date:      Fri Apr 04 01:24:09 2003 +0000

description:
set close on exec on a couple of FDs. from Charles Blundell PR security/16663

diffstat:

 usr.sbin/cron/crontab.c |  10 +++++++---
 usr.sbin/cron/misc.c    |   8 ++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diffs (67 lines):

diff -r 3837148c5f94 -r 417360bbc1fa usr.sbin/cron/crontab.c
--- a/usr.sbin/cron/crontab.c   Fri Apr 04 01:16:28 2003 +0000
+++ b/usr.sbin/cron/crontab.c   Fri Apr 04 01:24:09 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crontab.c,v 1.16 2002/11/16 04:34:13 itojun Exp $      */
+/*     $NetBSD: crontab.c,v 1.17 2003/04/04 01:24:09 perry Exp $       */
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = "Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp";
 #else
-__RCSID("$NetBSD: crontab.c,v 1.16 2002/11/16 04:34:13 itojun Exp $");
+__RCSID("$NetBSD: crontab.c,v 1.17 2003/04/04 01:24:09 perry Exp $");
 #endif
 #endif
 
@@ -347,6 +347,10 @@
                perror("fchown");
                goto fatal;
        }
+       if (fcntl(t, F_SETFD, FD_CLOEXEC) == -1) {
+               perror("fcntl");
+               goto fatal;
+       }
        if (!(NewCrontab = fdopen(t, "r+"))) {
                perror("fdopen");
                goto fatal;
@@ -567,7 +571,7 @@
        fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
        fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
        fprintf(tmp, "# (Cron version -- %s)\n",
-           "$NetBSD: crontab.c,v 1.16 2002/11/16 04:34:13 itojun Exp $");
+           "$NetBSD: crontab.c,v 1.17 2003/04/04 01:24:09 perry Exp $");
 
        /* copy the crontab to the tmp
         */
diff -r 3837148c5f94 -r 417360bbc1fa usr.sbin/cron/misc.c
--- a/usr.sbin/cron/misc.c      Fri Apr 04 01:16:28 2003 +0000
+++ b/usr.sbin/cron/misc.c      Fri Apr 04 01:24:09 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.8 1998/07/28 19:27:39 mycroft Exp $ */
+/*     $NetBSD: misc.c,v 1.9 2003/04/04 01:24:09 perry Exp $   */
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = "Id: misc.c,v 2.9 1994/01/15 20:43:43 vixie Exp";
 #else
-__RCSID("$NetBSD: misc.c,v 1.8 1998/07/28 19:27:39 mycroft Exp $");
+__RCSID("$NetBSD: misc.c,v 1.9 2003/04/04 01:24:09 perry Exp $");
 #endif
 #endif
 
@@ -446,6 +446,10 @@
                allow = fopen(ALLOW_FILE, "r");
                deny = fopen(DENY_FILE, "r");
                Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny))
+               if (allow)
+                       (void)fcntl(fileno(allow), F_SETFD, FD_CLOEXEC);
+               if (deny)
+                       (void)fcntl(fileno(deny), F_SETFD, FD_CLOEXEC);
 #else
                allow = NULL;
                deny = NULL;



Home | Main Index | Thread Index | Old Index