summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--configure.ac6
-rw-r--r--openbsd-compat/bsd-closefrom.c20
3 files changed, 19 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f37e7477..599e7eca1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
120060818
2 - (dtucker) [configure.ac openbsd-compat/bsd-closefrom.c] Resync with
3 closefrom.c from sudo.
4
120060817 520060817
2 - (dtucker) [openbsd-compat/fake-rfc2553.c openbsd-compat/setproctitle.c] 6 - (dtucker) [openbsd-compat/fake-rfc2553.c openbsd-compat/setproctitle.c]
3 Include stdlib.h for malloc and friends. 7 Include stdlib.h for malloc and friends.
@@ -5218,4 +5222,4 @@
5218 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 5222 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
5219 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 5223 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
5220 5224
5221$Id: ChangeLog,v 1.4482 2006/08/17 09:40:35 dtucker Exp $ 5225$Id: ChangeLog,v 1.4483 2006/08/18 08:51:20 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index 7a296ae8b..f8e6cd4ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.349 2006/08/17 09:35:49 dtucker Exp $ 1# $Id: configure.ac,v 1.350 2006/08/18 08:51:20 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) 17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18AC_REVISION($Revision: 1.349 $) 18AC_REVISION($Revision: 1.350 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20 20
21AC_CONFIG_HEADER(config.h) 21AC_CONFIG_HEADER(config.h)
@@ -181,7 +181,7 @@ case "$host" in
181 ) 181 )
182 AC_CHECK_FUNCS(setauthdb) 182 AC_CHECK_FUNCS(setauthdb)
183 AC_CHECK_DECL(F_CLOSEM, 183 AC_CHECK_DECL(F_CLOSEM,
184 AC_DEFINE(USE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]), 184 AC_DEFINE(HAVE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]),
185 [], 185 [],
186 [ #include <limits.h> 186 [ #include <limits.h>
187 #include <fcntl.h> ] 187 #include <fcntl.h> ]
diff --git a/openbsd-compat/bsd-closefrom.c b/openbsd-compat/bsd-closefrom.c
index e7a521e43..4b72920d6 100644
--- a/openbsd-compat/bsd-closefrom.c
+++ b/openbsd-compat/bsd-closefrom.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com> 2 * Copyright (c) 2004-2005 Todd C. Miller <Todd.Miller@courtesan.com>
3 * 3 *
4 * Permission to use, copy, modify, and distribute this software for any 4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above 5 * purpose with or without fee is hereby granted, provided that the above
@@ -52,12 +52,19 @@
52#endif 52#endif
53 53
54#ifndef lint 54#ifndef lint
55static const char sudorcsid[] = "$Sudo: closefrom.c,v 1.6 2004/06/01 20:51:56 millert Exp $"; 55__unused static const char rcsid[] = "$Sudo: closefrom.c,v 1.11 2006/08/17 15:26:54 millert Exp $";
56#endif /* lint */ 56#endif /* lint */
57 57
58/* 58/*
59 * Close all file descriptors greater than or equal to lowfd. 59 * Close all file descriptors greater than or equal to lowfd.
60 */ 60 */
61#ifdef HAVE_FCNTL_CLOSEM
62void
63closefrom(int lowfd)
64{
65 (void) fcntl(lowfd, F_CLOSEM, 0);
66}
67#else
61void 68void
62closefrom(int lowfd) 69closefrom(int lowfd)
63{ 70{
@@ -70,7 +77,7 @@ closefrom(int lowfd)
70 77
71 /* Check for a /proc/$$/fd directory. */ 78 /* Check for a /proc/$$/fd directory. */
72 len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid()); 79 len = snprintf(fdpath, sizeof(fdpath), "/proc/%ld/fd", (long)getpid());
73 if (len >= 0 && (u_int)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) { 80 if (len > 0 && (size_t)len <= sizeof(fdpath) && (dirp = opendir(fdpath))) {
74 while ((dent = readdir(dirp)) != NULL) { 81 while ((dent = readdir(dirp)) != NULL) {
75 fd = strtol(dent->d_name, &endp, 10); 82 fd = strtol(dent->d_name, &endp, 10);
76 if (dent->d_name != endp && *endp == '\0' && 83 if (dent->d_name != endp && *endp == '\0' &&
@@ -79,10 +86,6 @@ closefrom(int lowfd)
79 } 86 }
80 (void) closedir(dirp); 87 (void) closedir(dirp);
81 } else 88 } else
82#elif defined(USE_FCNTL_CLOSEM)
83 if (fcntl(lowfd, F_CLOSEM, 0) != -1) {
84 return;
85 } else
86#endif 89#endif
87 { 90 {
88 /* 91 /*
@@ -102,6 +105,5 @@ closefrom(int lowfd)
102 (void) close((int) fd); 105 (void) close((int) fd);
103 } 106 }
104} 107}
105 108#endif /* !HAVE_FCNTL_CLOSEM */
106#endif /* HAVE_CLOSEFROM */ 109#endif /* HAVE_CLOSEFROM */
107