openssh-3.1p1 on GNU/Hurd
Ben Lindstrom
mouring at etoh.eviladmin.org
Wed Apr 10 11:52:41 EST 2002
We are in a code freeze for 3.2. Only patches against --current will be
reviewed, and this is too big of change to ensure correct for 15+
platforms.
If you have a less draconic patch for 3.2 release we may consider it.
BTW.. AC_DEFINE(HAVE_BOGUS_SYS_QUEUE_H) has been removed since we
use our queue.h for all platforms due to lack of consisty in each
platform.
- Ben
On Tue, 9 Apr 2002, James A Morrison wrote:
>
> Hi,
>
> I've gone and ported the latest version of openssh, 3.1p1, to GNU/Hurd.
> I've tried to learn from the other threads on this topic, but I still had
> to get rid of MAXHOSTNAMELEN where I could.
>
> James A. Morrison
>
> diff -urN openssh-3.1p1.old/Makefile.in openssh-3.1p1/Makefile.in
> --- openssh-3.1p1.old/Makefile.in Tue Feb 26 14:24:22 2002
> +++ openssh-3.1p1/Makefile.in Tue Apr 9 16:16:49 2002
> @@ -54,7 +54,7 @@
>
> SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o sshtty.o readconf.o clientloop.o
>
> -SSHDOBJS= sshd.o auth.o auth1.o auth2.o auth-chall.o auth2-chall.o auth-rhosts.o auth-options.o auth-krb4.o auth-pam.o auth2-pam.o auth-passwd.o auth-rsa.o auth-rh-rsa.o auth-sia.o sshpty.o sshlogin.o loginrec.o servconf.o serverloop.o md5crypt.o session.o groupaccess.o auth-skey.o auth-bsdauth.o
> +SSHDOBJS= sshd.o auth.o auth1.o auth2.o auth-chall.o auth2-chall.o auth-rhosts.o auth-options.o auth-krb4.o auth-pam.o auth2-pam.o auth-passwd.o auth-rsa.o auth-rh-rsa.o auth-sia.o sshpty.o sshlogin.o loginrec.o servconf.o serverloop.o md5crypt.o session.o groupaccess.o auth-skey.o auth-bsdauth.o xgethostname.o
>
> MANPAGES = scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out
> MANPAGES_IN = scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1
> @@ -113,8 +113,8 @@
> ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o
> $(LD) -o $@ ssh-agent.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
>
> -ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
> - $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
> +ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o xgethostname.o
> + $(LD) -o $@ xgethostname.o ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
>
> ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
> $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
> diff -urN openssh-3.1p1.old/canohost.c openssh-3.1p1/canohost.c
> --- openssh-3.1p1.old/canohost.c Mon Mar 4 20:31:29 2002
> +++ openssh-3.1p1/canohost.c Tue Apr 9 21:05:15 2002
> @@ -284,9 +284,11 @@
> get_remote_name_or_ip(u_int utmp_len, int verify_reverse_mapping)
> {
> static const char *remote = "";
> - if (utmp_len > 0)
> + /* Assume that if utmp_len = -1 then there is no limit on the
> + hostname length */
> + if (utmp_len > 0 || utmp_len == -1)
> remote = get_canonical_hostname(verify_reverse_mapping);
> - if (utmp_len == 0 || strlen(remote) > utmp_len)
> + if (utmp_len == 0 || (utmp_len != -1 && strlen(remote) > utmp_len))
> remote = get_remote_ipaddr();
> return remote;
> }
> diff -urN openssh-3.1p1.old/configure.ac openssh-3.1p1/configure.ac
> --- openssh-3.1p1.old/configure.ac Wed Feb 27 01:12:35 2002
> +++ openssh-3.1p1/configure.ac Tue Apr 9 16:36:19 2002
> @@ -126,6 +126,9 @@
> AC_DEFINE(HAVE_BOGUS_SYS_QUEUE_H)
> inet6_default_4in6=yes
> ;;
> +*-*-gnu*)
> + AC_DEFINE(HAVE_BOGUS_SYS_QUEUE_H)
> + ;;
> mips-sony-bsd|mips-sony-newsos4)
> AC_DEFINE(HAVE_NEWS4)
> SONY=1
> diff -urN openssh-3.1p1.old/session.c openssh-3.1p1/session.c
> --- openssh-3.1p1.old/session.c Mon Feb 25 10:48:03 2002
> +++ openssh-3.1p1/session.c Tue Apr 9 20:59:48 2002
> @@ -56,6 +56,7 @@
> #include "serverloop.h"
> #include "canohost.h"
> #include "session.h"
> +#include "xgethostname.h"
>
> #ifdef HAVE_CYGWIN
> #include <windows.h>
> @@ -659,7 +660,7 @@
> do_login(Session *s, const char *command)
> {
> char *time_string;
> - char hostname[MAXHOSTNAMELEN];
> + char *hostname;
> socklen_t fromlen;
> struct sockaddr_storage from;
> time_t last_login_time;
> @@ -681,11 +682,9 @@
> }
>
> /* Get the time and hostname when the user last logged in. */
> - if (options.print_lastlog) {
> - hostname[0] = '\0';
> + if (options.print_lastlog)
> last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name,
> - hostname, sizeof(hostname));
> - }
> + &hostname);
>
> /* Record that there was a login on that tty from the remote host. */
> record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
> @@ -715,14 +714,17 @@
> printf("%s\n", aixloginmsg);
> #endif /* WITH_AIXAUTHENTICATE */
>
> - if (options.print_lastlog && last_login_time != 0) {
> - time_string = ctime(&last_login_time);
> - if (strchr(time_string, '\n'))
> - *strchr(time_string, '\n') = 0;
> - if (strcmp(hostname, "") == 0)
> - printf("Last login: %s\r\n", time_string);
> - else
> - printf("Last login: %s from %s\r\n", time_string, hostname);
> + if (options.print_lastlog )
> + if (last_login_time != 0) {
> + time_string = ctime(&last_login_time);
> + if (strchr(time_string, '\n'))
> + *strchr(time_string, '\n') = 0;
> + if (strcmp(hostname, "") == 0)
> + printf("Last login: %s\r\n", time_string);
> + else
> + printf("Last login: %s from %s\r\n", time_string, hostname);
> + }
> + xfree(hostname);
> }
>
> do_motd();
> @@ -1849,7 +1851,7 @@
> {
> struct stat st;
> char display[512], auth_display[512];
> - char hostname[MAXHOSTNAMELEN];
> + char *hostname;
>
> if (no_x11_forwarding_flag) {
> packet_send_debug("X11 forwarding disabled in user configuration file.");
> @@ -1881,7 +1883,7 @@
> }
>
> /* Set up a suitable value for the DISPLAY variable. */
> - if (gethostname(hostname, sizeof(hostname)) < 0)
> + if (!(hostname = xgethostname()))
> fatal("gethostname: %.100s", strerror(errno));
> /*
> * auth_display must be used as the displayname when the
> diff -urN openssh-3.1p1.old/ssh-keygen.c openssh-3.1p1/ssh-keygen.c
> --- openssh-3.1p1.old/ssh-keygen.c Tue Feb 26 13:15:10 2002
> +++ openssh-3.1p1/ssh-keygen.c Tue Apr 9 16:15:47 2002
> @@ -27,6 +27,7 @@
> #include "pathnames.h"
> #include "log.h"
> #include "readpass.h"
> +#include "xgethostname.h"
>
> #ifdef SMARTCARD
> #include <sectok.h>
> @@ -82,7 +83,7 @@
> char *__progname;
> #endif
>
> -char hostname[MAXHOSTNAMELEN];
> +char *hostname;
>
> static void
> ask_filename(struct passwd *pw, const char *prompt)
> @@ -860,7 +861,7 @@
> printf("You don't exist, go away!\n");
> exit(1);
> }
> - if (gethostname(hostname, sizeof(hostname)) < 0) {
> + if (!(hostname = xgethostname())) {
> perror("gethostname");
> exit(1);
> }
> diff -urN openssh-3.1p1.old/sshd.c openssh-3.1p1/sshd.c
> --- openssh-3.1p1.old/sshd.c Mon Mar 4 20:31:30 2002
> +++ openssh-3.1p1/sshd.c Tue Apr 9 14:09:55 2002
> @@ -183,7 +183,7 @@
> int session_id2_len = 0;
>
> /* record remote hostname or ip */
> -u_int utmp_len = MAXHOSTNAMELEN;
> +u_int utmp_len = 0;
>
> /* options.max_startup sized array of fd ints */
> int *startup_pipes = NULL;
> @@ -603,6 +603,13 @@
> /* Save argv. */
> saved_argc = ac;
> saved_argv = av;
> +
> + /* find max hostname length */
> +#ifdef _SC_HOST_NAME_MAX
> + utmp_len = sysconf(_SC_HOST_NAME_MAX);
> +#elif MAXHOSTNAMELEN
> + utmp_len = MAXHOSTNAMELEN;
> +#endif
>
> /* Initialize configuration options to their default values. */
> initialize_server_options(&options);
> diff -urN openssh-3.1p1.old/sshlogin.c openssh-3.1p1/sshlogin.c
> --- openssh-3.1p1.old/sshlogin.c Sun Feb 24 20:56:47 2002
> +++ openssh-3.1p1/sshlogin.c Tue Apr 9 20:57:38 2002
> @@ -51,12 +51,12 @@
>
> u_long
> get_last_login_time(uid_t uid, const char *logname,
> - char *buf, u_int bufsize)
> + char **buf)
> {
> struct logininfo li;
>
> login_get_lastlog(&li, uid);
> - strlcpy(buf, li.hostname, bufsize);
> + *buf = xstrdup(li.hostname);
> return li.tv_sec;
> }
>
> diff -urN openssh-3.1p1.old/sshlogin.h openssh-3.1p1/sshlogin.h
> --- openssh-3.1p1.old/sshlogin.h Sun Feb 24 20:56:47 2002
> +++ openssh-3.1p1/sshlogin.h Tue Apr 9 14:33:16 2002
> @@ -18,7 +18,7 @@
> record_login(pid_t, const char *, const char *, uid_t,
> const char *, struct sockaddr *);
> void record_logout(pid_t, const char *, const char *);
> -u_long get_last_login_time(uid_t, const char *, char *, u_int);
> +u_long get_last_login_time(uid_t, const char *, char **);
>
> #ifdef LOGIN_NEEDS_UTMPX
> void record_utmp_only(pid_t, const char *, const char *, const char *,
> diff -urN openssh-3.1p1.old/xgethostname.c openssh-3.1p1/xgethostname.c
> --- openssh-3.1p1.old/xgethostname.c Wed Dec 31 19:00:00 1969
> +++ openssh-3.1p1/xgethostname.c Tue Apr 9 21:14:55 2002
> @@ -0,0 +1,85 @@
> +/* Copyright (c) 2001 Neal H Walfield <neal at cs.uml.edu>.
> +
> + This file is placed into the public domain. Its distribution
> + is unlimited.
> +
> + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
> + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
> + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
> + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +/* NAME
> +
> + xgethostname - get the host name.
> +
> + SYNOPSIS
> +
> + char *xgethostname (void);
> +
> + DESCRIPTION
> +
> + The xhostname function is intended to replace gethostname(2), a
> + function used to access the host name. The old interface is
> + inflexable given that it assumes the existance of the
> + MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
> + Single Unix Specification version 3 guarantee to be defined.
> +
> + RETURN VALUE
> +
> + On success, a malloced, null terminated (possibly truncated)
> + string containing the host name is returned. On failure, NULL
> + is returned and errno is set.
> + */
> +
> +#include <sys/param.h> /* For MAXHOSTNAMELEN */
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <unistd.h>
> +
> +char *
> +xgethostname (void)
> +{
> + int size = 0;
> + int addnull = 0;
> + char *buf;
> + int err;
> + char *tmp;
> +
> +#ifdef MAXHOSTNAMELEN
> + size = MAXHOSTNAMELEN;
> + addnull = 1;
> +#else /* MAXHOSTNAMELEN */
> +#ifdef _SC_HOST_NAME_MAX
> + size = sysconf (_SC_HOST_NAME_MAX);
> + addnull = 1;
> +#endif /* _SC_HOST_NAME_MAX */
> + if (size <= 0)
> + size = 256;
> +#endif /* MAXHOSTNAMELEN */
> +
> + buf = xmalloc (size + addnull);
> +
> + err = gethostname (buf, size);
> + while (err == -1 && errno == ENAMETOOLONG)
> + {
> + size *= 2;
> + buf = xrealloc (buf, size + addnull);
> + err = gethostname (buf, size);
> + }
> +
> + if (err)
> + return NULL;
> +
> + if (addnull)
> + buf[size] = '\0';
> +
> + return buf;
> +}
> diff -urN openssh-3.1p1.old/xgethostname.h openssh-3.1p1/xgethostname.h
> --- openssh-3.1p1.old/xgethostname.h Wed Dec 31 19:00:00 1969
> +++ openssh-3.1p1/xgethostname.h Tue Apr 9 20:54:38 2002
> @@ -0,0 +1,48 @@
> +/* Copyright (c) 2001 Neal H Walfield <neal at cs.uml.edu>.
> +
> + This file is placed into the public domain. Its distribution
> + is unlimited.
> +
> + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
> + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
> + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
> + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +/* NAME
> +
> + xgethostname - get the host name.
> +
> + SYNOPSIS
> +
> + char *xgethostname (void);
> +
> + DESCRIPTION
> +
> + The xhostname function is intended to replace gethostname(2), a
> + function used to access the host name. The old interface is
> + inflexable given that it assumes the existance of the
> + MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
> + Single Unix Specification version 3 guarantee to be defined.
> +
> + RETURN VALUE
> +
> + On success, a malloced, null terminated (possibly truncated)
> + string containing the host name is returned. On failure,
> + NULL is returned and errno is set.
> + */
> +
> +#ifndef XGETHOSTNAME
> +#define XGETHOSTNAME
> +
> +char * xgethostname (void);
> +
> +#endif /* XGETHOSTNAME */
> +
> _______________________________________________
> openssh-unix-dev at mindrot.org mailing list
> http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
>
More information about the openssh-unix-dev
mailing list