From 4e577b895f24b4126db9b0a555d874e38f8b0bf7 Mon Sep 17 00:00:00 2001 From: damien Date: Thu, 20 Apr 2000 13:12:58 +0000 Subject: [PATCH] - Merge fixes from Debian patch from Phil Hands - Allow setting of PAM service name through CFLAGS (SSHD_PAM_SERVICE) - Use vhangup to clean up Linux ttys - Force posix getopt processing on GNU libc systems --- ChangeLog | 4 ++++ auth-pam.c | 3 ++- configure.in | 2 +- pty.c | 19 ++++++++++++++++--- ssh-agent.c | 4 ++++ ssh.h | 4 ++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 168e583b..192ca2c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ [session.c] - remove bogus chan_read_failed. this could cause data corruption (missing data) at end of a SSH2 session. + - Merge fixes from Debian patch from Phil Hands + - Allow setting of PAM service name through CFLAGS (SSHD_PAM_SERVICE) + - Use vhangup to clean up Linux ttys + - Force posix getopt processing on GNU libc systems 20000419 - OpenBSD CVS updates diff --git a/auth-pam.c b/auth-pam.c index 17e8d882..d712009c 100644 --- a/auth-pam.c +++ b/auth-pam.c @@ -215,7 +215,8 @@ void start_pam(struct passwd *pw) debug("Starting up PAM with username \"%.200s\"", pw->pw_name); - pam_retval = pam_start("sshd", pw->pw_name, &conv, (pam_handle_t**)&pamh); + pam_retval = pam_start(SSHD_PAM_SERVICE, pw->pw_name, &conv, + (pam_handle_t**)&pamh); if (pam_retval != PAM_SUCCESS) fatal("PAM initialisation failed: %.200s", PAM_STRERROR((pam_handle_t *)pamh, pam_retval)); diff --git a/configure.in b/configure.in index b676193d..596c4e09 100644 --- a/configure.in +++ b/configure.in @@ -110,7 +110,7 @@ fi AC_CHECK_HEADERS(bstring.h endian.h lastlog.h login.h maillock.h netdb.h netgroup.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h util.h utmp.h utmpx.h) # Checks for library functions. -AC_CHECK_FUNCS(arc4random bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage innetgr md5_crypt mkdtemp openpty rresvport_af setenv seteuid setlogin setproctitle setreuid snprintf strlcat strlcpy updwtmpx vsnprintf _getpty) +AC_CHECK_FUNCS(arc4random bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage innetgr md5_crypt mkdtemp openpty rresvport_af setenv seteuid setlogin setproctitle setreuid snprintf strlcat strlcpy updwtmpx vsnprintf vhangup _getpty) AC_CHECK_FUNC(login, [AC_DEFINE(HAVE_LOGIN)], diff --git a/pty.c b/pty.c index bffac4e5..acdbb806 100644 --- a/pty.c +++ b/pty.c @@ -201,6 +201,9 @@ void pty_make_controlling_tty(int *ttyfd, const char *ttyname) { int fd; +#ifdef HAVE_VHANGUP + void *old; +#endif /* HAVE_VHANGUP */ /* First disconnect from the old controlling tty. */ #ifdef TIOCNOTTY @@ -232,12 +235,22 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname) */ ioctl(*ttyfd, TIOCSCTTY, NULL); #endif /* TIOCSCTTY */ +#ifdef HAVE_VHANGUP + old = signal(SIGHUP, SIG_IGN); + vhangup(); + signal(SIGHUP, old); +#endif /* HAVE_VHANGUP */ fd = open(ttyname, O_RDWR); - if (fd < 0) + if (fd < 0) { error("%.100s: %.100s", ttyname, strerror(errno)); - else + } else { +#ifdef HAVE_VHANGUP + close(*ttyfd); + *ttyfd = fd; +#else /* HAVE_VHANGUP */ close(fd); - +#endif /* HAVE_VHANGUP */ + } /* Verify that we now have a controlling tty. */ fd = open("/dev/tty", O_WRONLY); if (fd < 0) diff --git a/ssh-agent.c b/ssh-agent.c index 5a265e6b..c9a84a4a 100644 --- a/ssh-agent.c +++ b/ssh-agent.c @@ -511,7 +511,11 @@ main(int ac, char **av) __progname); exit(1); } +#ifdef __GNU_LIBRARY__ + while ((ch = getopt(ac, av, "+cks")) != -1) { +#else /* __GNU_LIBRARY__ */ while ((ch = getopt(ac, av, "cks")) != -1) { +#endif /* __GNU_LIBRARY__ */ switch (ch) { case 'c': if (s_flag) diff --git a/ssh.h b/ssh.h index f79c119f..4d1b26df 100644 --- a/ssh.h +++ b/ssh.h @@ -71,6 +71,10 @@ */ #define SSH_SERVICE_NAME "ssh" +#if defined(USE_PAM) && !defined(SSHD_PAM_SERVICE) +# define SSHD_PAM_SERVICE "sshd" +#endif + #ifndef ETCDIR #define ETCDIR "/etc" #endif /* ETCDIR */ -- 2.45.2