patch to support hurd-i386

Christian Kurz shorty at debian.org
Thu Dec 28 09:47:58 EST 2000


Hi,

here's a patch so that ssh also supports hurd-i386. Thanks for
incorporating. The patch comes from Robert Bihlmeyer <robbe at orcus.priv.at>.

> openssh 2.2.0p1-1.1 does not build on the Hurd. The appended patch
> fixes that. Changes in detail:

> * PAM is not (yet?) supported, so the PAM dependencies are only put into
> the control file on architectures != hurd-i386.

> * Hurd has no random device, therefore /etc/ssh/ssh_prng_conf is needed.
> Added to conffiles.

> * Do not try to generate a hostkey while building the package. This is
> useless, and it will fail on the Hurd if ssh is not yet installed.

> * Hurd has no MAXHOSTNAME. Two instances replaced by fixed limit, where
> only the first N bytes were used, anyway. Two more instances replaced
> by a grow-until-fits loop.

diff -Nur openssh-2.2.0p1-/Makefile.in openssh-2.2.0p1/Makefile.in
--- openssh-2.2.0p1-/Makefile.in        Sun Oct 29 16:17:49 2000
+++ openssh-2.2.0p1/Makefile.in Sun Oct 29 16:44:49 2000
@@ -116,7 +116,7 @@
 distprep: catman-do
        autoreconf
 
-install: manpages $(TARGETS) install-files host-key
+install: manpages $(TARGETS) install-files
 
 install-files:
        ./mkinstalldirs $(DESTDIR)$(bindir)
diff -Nur openssh-2.2.0p1-/canohost.c openssh-2.2.0p1/canohost.c
--- openssh-2.2.0p1-/canohost.c Thu Jun 22 13:32:31 2000
+++ openssh-2.2.0p1/canohost.c  Sun Oct 29 16:44:49 2000
@@ -32,7 +32,8 @@
        int i;
        socklen_t fromlen;
        struct addrinfo hints, *ai, *aitop;
-       char name[MAXHOSTNAMELEN];
+       char *name;
+       size_t name_size;
        char ntop[NI_MAXHOST], ntop2[NI_MAXHOST];
 
        /* Get IP address of client. */
@@ -71,10 +72,21 @@
                fatal("get_remote_hostname: getnameinfo NI_NUMERICHOST failed");
 
        /* Map the IP address to a host name. */
-       if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
-            NULL, 0, NI_NAMEREQD) == 0) {
+       name_size = 100;
+       name = malloc(name_size);
+       if (name == NULL)
+               fatal("get_remote_hostname: not enough space for hostname");
+       while ((i = getnameinfo((struct sockaddr *)&from, fromlen, name,
+                               name_size, NULL, 0, NI_NAMEREQD))
+              == EAI_MEMORY) {
+               name_size <<= 1;
+               name = realloc(name, name_size);
+               if (name == NULL)
+                       fatal("get_remote_hostname: not enough space for hostname");
+       }
+       if (i == 0) {
                /* Got host name. */
-               name[sizeof(name) - 1] = '\0';
+               name[name_size - 1] = '\0';
                /*
                 * Convert it to all lowercase (which is expected by the rest
                 * of this software).
@@ -97,7 +109,7 @@
                hints.ai_socktype = SOCK_STREAM;
                if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
                        log("reverse mapping checking getaddrinfo for %.700s failed - POSSIBLE BREAKIN ATTEMPT!", name);
-                       strlcpy(name, ntop, sizeof name);
+                       strlcpy(name, ntop, name_size);
                        goto check_ip_options;
                }
                /* Look for the address from the list of addresses. */
@@ -113,13 +125,13 @@
                        /* Address not found for the host name. */
                        log("Address %.100s maps to %.600s, but this does not map back to the address - POSSIBLE BREAKIN ATTEMPT!",
                            ntop, name);
-                       strlcpy(name, ntop, sizeof name);
+                       strlcpy(name, ntop, name_size);
                        goto check_ip_options;
                }
                /* Address was found for the host name.  We accept the host name. */
        } else {
                /* Host name not found.  Use ascii representation of the address. */
-               strlcpy(name, ntop, sizeof name);
+               strlcpy(name, ntop, name_size);
                log("Could not reverse map address %.100s.", name);
        }
 
@@ -162,7 +174,7 @@
                }
        }
 
-       return xstrdup(name);
+       return name;
 }
 
 /*
diff -Nur openssh-2.2.0p1-/channels.c openssh-2.2.0p1/channels.c
--- openssh-2.2.0p1-/channels.c Sun Oct 29 16:17:49 2000
+++ openssh-2.2.0p1/channels.c  Sun Oct 29 16:44:49 2000
@@ -1720,7 +1720,7 @@
        char strport[NI_MAXSERV];
        int gaierr, n, num_socks = 0, socks[NUM_SOCKS];
        char display[512];
-       char hostname[MAXHOSTNAMELEN];
+       char hostname[401];     /* we only use the first 400 bytes anyway*/
 
        for (display_number = x11_display_offset;
             display_number < MAX_DISPLAYS;
@@ -1791,7 +1791,8 @@
 
        /* Set up a suitable value for the DISPLAY variable. */
 
-       if (gethostname(hostname, sizeof(hostname)) < 0)
+       if (gethostname(hostname, sizeof(hostname)) < 0
+           && errno != ENAMETOOLONG)
                fatal("gethostname: %.100s", strerror(errno));
 
 #ifdef IPADDR_IN_DISPLAY

-- 
          Debian Developer and Quality Assurance Team Member
    1024/26CC7853 31E6 A8CA 68FC 284F 7D16  63EC A9E6 67FF 26CC 7853
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 242 bytes
Desc: not available
Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20001227/9332129d/attachment.bin 


More information about the openssh-unix-dev mailing list