-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: b1c78f35392c37525049c18f2f146eb8c5ae8e05:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit b1c78f35392c37525049c18f2f146eb8c5ae8e05
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Mon Feb 12 17:34:58 2007 +0000

    *** empty log message ***

diff --git a/Changes b/Changes

index 052d22d3ba4f8dd6d84e072bc173f9d0a1d269c2..

index ..034eb0f73b7dc7ad798268cde989bb65ed16b0cd 100644

--- a/Changes
+++ b/Changes
@@ -43,6 +43,8 @@ TODO: fix rounding of colors when !xft (#aaaaaa => #a9a900) (do not use correct,
           Paskevich).
         - rip out support for obsolete sgtty.h interface.
         - rip out support for non-POSIX termios variants.
+        - update libptytty.
+        - update iom.C, make it call ptytty::sanitise_stdfd on init.

 8.1  Thu Dec  7 22:27:25 CET 2006
         - ケリスマスプレゼント - zomg!!1, it's too early!!!
diff --git a/src/iom.C b/src/iom.C

index b003fa3ea73554cf0c070344c8d2a0ca0f4d6b57..

index ..1516cf2ff9425eba11426efd54cea3af30f56392 100644

--- a/src/iom.C
+++ b/src/iom.C
@@ -151,6 +151,9 @@ static bool iom_valid;
 static struct init {
   init ()
   {
+#ifdef IOM_PREINIT
+    { IOM_PREINIT }
+#endif
     iom_valid = true;

 #if IOM_SIG
@@ -175,6 +178,10 @@ static struct init {

     tw0.start (TSTAMP_MAX);
 #endif
+
+#ifdef IOM_POSTINIT
+    { IOM_POSTINIT }
+#endif
   }

   ~init ()
diff --git a/src/iom_conf.h b/src/iom_conf.h

index 91c65ccbe4aa8d14492ae1f50def1f6a2d8f6c0a..

index ..03d7fda708e2967d63211f4c62090dbdfa2788e5 100644

--- a/src/iom_conf.h
+++ b/src/iom_conf.h
@@ -20,7 +20,7 @@
 #ifndef RXVT_IOM_CONF_H__
 #define RXVT_IOM_CONF_H__

-#include <rxvtutil.h>
+#include "rxvtutil.h"

 #define IOM_IO    1
 #define IOM_TIME  1
@@ -29,5 +29,8 @@
 #define IOM_IDLE  1
 #define IOM_CHILD 1

+#include "libptytty.h"
+#define IOM_PREINIT ptytty::sanitise_stdfd ();
+
 #endif

diff --git a/src/libptytty.h b/src/libptytty.h

index 34cb67948897dacab78142026aa4f1bf749b03a9..

index ..0dad6a4e73a082714b440da0792ca9b5220c4e9f 100644

--- a/src/libptytty.h
+++ b/src/libptytty.h
@@ -23,6 +23,7 @@ struct ptytty {
   bool make_controlling_tty ();
   void set_utf8_mode (bool on);

+  static void sanitise_stdfd ();
   static void init ();
   static ptytty *create (); // create a new pty object

@@ -56,6 +57,7 @@ void ptytty_close_tty (PTYTTY ptytty);
 int ptytty_make_controlling_tty (PTYTTY ptytty);
 void ptytty_set_utf8_mode (PTYTTY ptytty, int on);

+void ptytty_sanitise_stdfd ();
 void ptytty_init ();
 PTYTTY ptytty_create ();

diff --git a/src/proxy.C b/src/proxy.C

index 4c996f0d83c3696a2ba4be42b1e95fb3843815dd..

index ..81f3557c83a0b22e770a2060dd02e091b8e36c4b 100644

--- a/src/proxy.C
+++ b/src/proxy.C
@@ -33,6 +33,7 @@
 #include <sys/socket.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>

 // helper/proxy support

@@ -296,9 +297,28 @@ ptytty::create ()
     return new ptytty_unix;
 }

+void
+ptytty::sanitise_stdfd ()
+{
+  // sanitise stdin/stdout/stderr to point to *something*.
+  for (int fd = 0; fd <= 2; ++fd)
+    if (fcntl (fd, F_GETFL) < 0 && errno == EBADF)
+      {
+        int fd2 = open ("/dev/tty", fd ? O_WRONLY : O_RDONLY);
+
+        if (fd2 < 0)
+          fd2 = open ("/dev/null", fd ? O_WRONLY : O_RDONLY);
+
+        if (fd2 != fd)
+          abort ();
+      }
+}
+
 void
 ptytty::init ()
 {
+  sanitise_stdfd ();
+
   uid_t uid = getuid ();
   gid_t gid = getgid ();

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 12:25:17 2024