Re: ssh, consistent use of fcntl(2) with F_SETFD

2011-05-15 Thread Damien Miller
applied - thanks

On Sat, 14 May 2011, Aaron Stellman wrote:

 Please review the diff.
 Thanks
 
 Index: usr.bin/ssh/authfd.c
 ===
 RCS file: /cvs/src/usr.bin/ssh/authfd.c,v
 retrieving revision 1.84
 diff -p -u -r1.84 authfd.c
 --- usr.bin/ssh/authfd.c  31 Aug 2010 11:54:45 -  1.84
 +++ usr.bin/ssh/authfd.c  14 May 2011 17:57:48 -
 @@ -108,7 +108,7 @@ ssh_get_authentication_socket(void)
   return -1;
  
   /* close on exec */
 - if (fcntl(sock, F_SETFD, 1) == -1) {
 + if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) {
   close(sock);
   return -1;
   }
 Index: usr.bin/ssh/monitor.c
 ===
 RCS file: /cvs/src/usr.bin/ssh/monitor.c,v
 retrieving revision 1.110
 diff -p -u -r1.110 monitor.c
 --- usr.bin/ssh/monitor.c 9 Sep 2010 10:45:45 -   1.110
 +++ usr.bin/ssh/monitor.c 14 May 2011 17:57:48 -
 @@ -1513,7 +1513,7 @@ mm_init_compression(struct mm_master *mm
  /* XXX */
  
  #define FD_CLOSEONEXEC(x) do { \
 - if (fcntl(x, F_SETFD, 1) == -1) \
 + if (fcntl(x, F_SETFD, FD_CLOEXEC) == -1) \
   fatal(fcntl(%d, F_SETFD), x); \
  } while (0)
  
 Index: usr.bin/ssh/serverloop.c
 ===
 RCS file: /cvs/src/usr.bin/ssh/serverloop.c,v
 retrieving revision 1.159
 diff -p -u -r1.159 serverloop.c
 --- usr.bin/ssh/serverloop.c  28 May 2009 16:50:16 -  1.159
 +++ usr.bin/ssh/serverloop.c  14 May 2011 17:57:48 -
 @@ -127,8 +127,8 @@ notify_setup(void)
  {
   if (pipe(notify_pipe)  0) {
   error(pipe(notify_pipe) failed %s, strerror(errno));
 - } else if ((fcntl(notify_pipe[0], F_SETFD, 1) == -1) ||
 - (fcntl(notify_pipe[1], F_SETFD, 1) == -1)) {
 + } else if ((fcntl(notify_pipe[0], F_SETFD, FD_CLOEXEC) == -1) ||
 + (fcntl(notify_pipe[1], F_SETFD, FD_CLOEXEC) == -1)) {
   error(fcntl(notify_pipe, F_SETFD) failed %s, strerror(errno));
   close(notify_pipe[0]);
   close(notify_pipe[1]);



ssh, consistent use of fcntl(2) with F_SETFD

2011-05-14 Thread Aaron Stellman
Please review the diff.
Thanks

Index: usr.bin/ssh/authfd.c
===
RCS file: /cvs/src/usr.bin/ssh/authfd.c,v
retrieving revision 1.84
diff -p -u -r1.84 authfd.c
--- usr.bin/ssh/authfd.c31 Aug 2010 11:54:45 -  1.84
+++ usr.bin/ssh/authfd.c14 May 2011 17:57:48 -
@@ -108,7 +108,7 @@ ssh_get_authentication_socket(void)
return -1;
 
/* close on exec */
-   if (fcntl(sock, F_SETFD, 1) == -1) {
+   if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) {
close(sock);
return -1;
}
Index: usr.bin/ssh/monitor.c
===
RCS file: /cvs/src/usr.bin/ssh/monitor.c,v
retrieving revision 1.110
diff -p -u -r1.110 monitor.c
--- usr.bin/ssh/monitor.c   9 Sep 2010 10:45:45 -   1.110
+++ usr.bin/ssh/monitor.c   14 May 2011 17:57:48 -
@@ -1513,7 +1513,7 @@ mm_init_compression(struct mm_master *mm
 /* XXX */
 
 #define FD_CLOSEONEXEC(x) do { \
-   if (fcntl(x, F_SETFD, 1) == -1) \
+   if (fcntl(x, F_SETFD, FD_CLOEXEC) == -1) \
fatal(fcntl(%d, F_SETFD), x); \
 } while (0)
 
Index: usr.bin/ssh/serverloop.c
===
RCS file: /cvs/src/usr.bin/ssh/serverloop.c,v
retrieving revision 1.159
diff -p -u -r1.159 serverloop.c
--- usr.bin/ssh/serverloop.c28 May 2009 16:50:16 -  1.159
+++ usr.bin/ssh/serverloop.c14 May 2011 17:57:48 -
@@ -127,8 +127,8 @@ notify_setup(void)
 {
if (pipe(notify_pipe)  0) {
error(pipe(notify_pipe) failed %s, strerror(errno));
-   } else if ((fcntl(notify_pipe[0], F_SETFD, 1) == -1) ||
-   (fcntl(notify_pipe[1], F_SETFD, 1) == -1)) {
+   } else if ((fcntl(notify_pipe[0], F_SETFD, FD_CLOEXEC) == -1) ||
+   (fcntl(notify_pipe[1], F_SETFD, FD_CLOEXEC) == -1)) {
error(fcntl(notify_pipe, F_SETFD) failed %s, strerror(errno));
close(notify_pipe[0]);
close(notify_pipe[1]);