From 5a9d0eaba699968ae29bf560e4546d09edcb440d Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Thu, 4 Jul 2002 00:12:53 +0000 Subject: - deraadt@cvs.openbsd.org 2002/06/30 21:54:16 [auth2.c session.c sshd.c] lint asks that we use names that do not overlap --- session.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'session.c') diff --git a/session.c b/session.c index 747a00afa..19b22c2aa 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.142 2002/06/26 13:49:26 deraadt Exp $"); +RCSID("$OpenBSD: session.c,v 1.143 2002/06/30 21:54:16 deraadt Exp $"); #include "ssh.h" #include "ssh1.h" @@ -992,13 +992,13 @@ do_setup_env(Session *s, const char *shell) if (!options.use_login) { while (custom_environment) { struct envstring *ce = custom_environment; - char *s = ce->s; + char *str = ce->s; - for (i = 0; s[i] != '=' && s[i]; i++) + for (i = 0; str[i] != '=' && str[i]; i++) ; - if (s[i] == '=') { - s[i] = 0; - child_set_env(&env, &envsize, s, s + i + 1); + if (str[i] == '=') { + str[i] = 0; + child_set_env(&env, &envsize, str, str + i + 1); } custom_environment = ce->next; xfree(ce->s); -- cgit v1.2.3 From 51b2488aad8b5387a8107e90b2f97dbe27ca850a Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Thu, 4 Jul 2002 03:08:40 +0000 Subject: - (bal) Clean up aix_usrinfo(). Ignore TTY= period I guess. --- ChangeLog | 3 ++- openbsd-compat/port-aix.c | 42 ++++++++++++++++++++++++++++++++---------- openbsd-compat/port-aix.h | 27 ++++++++++++++++++++++++--- session.c | 3 +-- 4 files changed, 59 insertions(+), 16 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 7451ee269..7ef5c3604 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,7 @@ ok itojun@ - (bal) Failed password attempts don't increment counter on AIX. Bug #145 - (bal) Missed Makefile.in change. keysign needs readconf.o + - (bal) Clean up aix_usrinfo(). Ignore TTY= period I guess. 20020702 - (djm) Use PAM_MSG_MEMBER for PAM_TEXT_INFO messages, use xmalloc & @@ -1266,4 +1267,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2331 2002/07/04 03:07:15 mouring Exp $ +$Id: ChangeLog,v 1.2332 2002/07/04 03:08:40 mouring Exp $ diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index ca0a88e69..02f185955 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c @@ -1,3 +1,25 @@ +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + * + */ #include "includes.h" #ifdef _AIX @@ -6,21 +28,21 @@ #include <../xmalloc.h> /* - * AIX has a "usrinfo" area where logname and - * other stuff is stored - a few applications - * actually use this and die if it's not set + * AIX has a "usrinfo" area where logname and other stuff is stored - + * a few applications actually use this and die if it's not set + * + * NOTE: TTY= should be set, but since no one uses it and it's hard to + * acquire due to privsep code. We will just drop support. */ void -aix_usrinfo(struct passwd *pw, char *tty, int ttyfd) +aix_usrinfo(struct passwd *pw) { u_int i; - char *cp=NULL; + char *cp; - if (ttyfd == -1) - tty[0] = '\0'; - cp = xmalloc(22 + strlen(tty) + 2 * strlen(pw->pw_name)); - i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c", pw->pw_name, 0, - pw->pw_name, 0, tty, 0, 0); + cp = xmalloc(16 + 2 * strlen(pw->pw_name)); + i = sprintf(cp, "LOGNAME=%s%cNAME=%s%c%c", pw->pw_name, 0, + pw->pw_name, 0, 0); if (usrinfo(SETUINFO, cp, i) == -1) fatal("Couldn't set usrinfo: %s", strerror(errno)); debug3("AIX/UsrInfo: set len %d", i); diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index e4d14f4ae..491ca4cd4 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h @@ -1,5 +1,26 @@ -#ifdef _AIX - -void aix_usrinfo(struct passwd *pw, char *tty, int ttyfd); +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + * + */ +#ifdef _AIX +void aix_usrinfo(struct passwd *pw); #endif /* _AIX */ diff --git a/session.c b/session.c index 19b22c2aa..774e6168a 100644 --- a/session.c +++ b/session.c @@ -1209,8 +1209,7 @@ do_setusercontext(struct passwd *pw) irix_setusercontext(pw); # endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ # ifdef _AIX - /* XXX: Disable tty setting. Enabled if required later */ - aix_usrinfo(pw, &tty, -1); + aix_usrinfo(pw); # endif /* _AIX */ /* Permanently switch to the desired uid. */ permanently_set_uid(pw); -- cgit v1.2.3 From 938b8285661f56181405b8c1637b31bf7b618de0 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Mon, 15 Jul 2002 17:58:34 +0000 Subject: - (bal) Remove unused tty defined in do_setusercontext() pointed out by dtucker@zip.com.au plus a a more KNF since I am near it. --- ChangeLog | 4 +++- session.c | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index bd2370263..28c0a91b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ - markus@cvs.openbsd.org 2002/07/12 15:50:17 [cipher.c] EVP_CIPH_CUSTOM_IV for our own rijndael + - (bal) Remove unused tty defined in do_setusercontext() pointed out by + dtucker@zip.com.au plus a a more KNF since I am near it. 20020714 - (tim) [Makefile.in] replace "id sshd" with "sshd -t" @@ -1370,4 +1372,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2368 2002/07/15 17:52:49 mouring Exp $ +$Id: ChangeLog,v 1.2369 2002/07/15 17:58:34 mouring Exp $ diff --git a/session.c b/session.c index 774e6168a..5fb1ace00 100644 --- a/session.c +++ b/session.c @@ -1159,8 +1159,6 @@ do_nologin(struct passwd *pw) void do_setusercontext(struct passwd *pw) { - char tty='\0'; - #ifdef HAVE_CYGWIN if (is_winnt) { #else /* HAVE_CYGWIN */ @@ -1170,9 +1168,9 @@ do_setusercontext(struct passwd *pw) setpcred(pw->pw_name); #endif /* HAVE_SETPCRED */ #ifdef HAVE_LOGIN_CAP -#ifdef __bsdi__ +# ifdef __bsdi__ setpgid(0, 0); -#endif +# endif if (setusercontext(lc, pw, pw->pw_uid, (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) { perror("unable to set user context"); -- cgit v1.2.3 From 38b050a0f526d1b7982deb9d19f59c95f7b91b22 Mon Sep 17 00:00:00 2001 From: Kevin Steves Date: Tue, 23 Jul 2002 00:44:07 +0000 Subject: - (stevesk) [auth-pam.[ch] session.c] pam_getenvlist() must be freed by the caller; add free_pam_environment() and use it. --- ChangeLog | 4 +++- auth-pam.c | 12 +++++++++++- auth-pam.h | 3 ++- session.c | 13 +++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 0bfeeddeb..b444df906 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ - (bal) [configure.ac] Missing ;; from cray patch. - (bal) [monitor_mm.c openbsd-compat/xmmap.h] Move xmmap() defines into it's own header. + - (stevesk) [auth-pam.[ch] session.c] pam_getenvlist() must be + freed by the caller; add free_pam_environment() and use it. 20020721 - (stevesk) [auth-pam.c] merge cosmetic changes from solar's @@ -1417,4 +1419,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2391 2002/07/23 00:03:33 mouring Exp $ +$Id: ChangeLog,v 1.2392 2002/07/23 00:44:07 stevesk Exp $ diff --git a/auth-pam.c b/auth-pam.c index 79af58a0b..8e1498296 100644 --- a/auth-pam.c +++ b/auth-pam.c @@ -38,7 +38,7 @@ extern char *__progname; extern int use_privsep; -RCSID("$Id: auth-pam.c,v 1.51 2002/07/21 23:59:39 stevesk Exp $"); +RCSID("$Id: auth-pam.c,v 1.52 2002/07/23 00:44:07 stevesk Exp $"); #define NEW_AUTHTOK_MSG \ "Warning: Your password has expired, please change it now." @@ -421,6 +421,16 @@ char **fetch_pam_environment(void) #endif /* HAVE_PAM_GETENVLIST */ } +void free_pam_environment(char **env) +{ + int i; + + if (env != NULL) { + for (i = 0; env[i] != NULL; i++) + xfree(env[i]); + } +} + /* Print any messages that have been generated during authentication */ /* or account checking to stderr */ void print_pam_messages(void) diff --git a/auth-pam.h b/auth-pam.h index 215e75282..7881b6b80 100644 --- a/auth-pam.h +++ b/auth-pam.h @@ -1,4 +1,4 @@ -/* $Id: auth-pam.h,v 1.15 2002/07/21 23:59:39 stevesk Exp $ */ +/* $Id: auth-pam.h,v 1.16 2002/07/23 00:44:07 stevesk Exp $ */ /* * Copyright (c) 2000 Damien Miller. All rights reserved. @@ -35,6 +35,7 @@ void start_pam(const char *user); void finish_pam(void); int auth_pam_password(Authctxt *authctxt, const char *password); char **fetch_pam_environment(void); +void free_pam_environment(char **env); int do_pam_authenticate(int flags); int do_pam_account(char *username, char *remote_user); void do_pam_session(char *username, const char *ttyname); diff --git a/session.c b/session.c index 5fb1ace00..3c759e472 100644 --- a/session.c +++ b/session.c @@ -1042,8 +1042,17 @@ do_setup_env(Session *s, const char *shell) s->authctxt->krb5_ticket_file); #endif #ifdef USE_PAM - /* Pull in any environment variables that may have been set by PAM. */ - copy_environment(fetch_pam_environment(), &env, &envsize); + /* + * Pull in any environment variables that may have + * been set by PAM. + */ + { + char **p; + + p = fetch_pam_environment(); + copy_environment(p, &env, &envsize); + free_pam_environment(p); + } #endif /* USE_PAM */ if (auth_sock_name != NULL) -- cgit v1.2.3 From 264ee307a8fd171dbb44121ec05b83f4143408cf Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Tue, 23 Jul 2002 21:01:56 +0000 Subject: - markus@cvs.openbsd.org 2002/07/19 15:43:33 [log.c log.h session.c sshd.c] remove fatal cleanups after fork; based on discussions with and code from solar. --- ChangeLog | 7 ++++++- log.c | 14 +++++++++++++- log.h | 3 ++- session.c | 5 ++++- sshd.c | 13 +++++++++---- 5 files changed, 34 insertions(+), 8 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 01b30968c..3b92fd015 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 20020723 - (bal) [bsd-cray.c bsd-cray.h] Part 2 of Cray merger. + - (bal) OpenBSD Sync + - markus@cvs.openbsd.org 2002/07/19 15:43:33 + [log.c log.h session.c sshd.c] + remove fatal cleanups after fork; based on discussions with and code + from solar. 20020722 - (bal) AIX tty data limiting patch fix by leigh@solinno.co.uk @@ -1423,4 +1428,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2394 2002/07/23 21:00:17 mouring Exp $ +$Id: ChangeLog,v 1.2395 2002/07/23 21:01:56 mouring Exp $ diff --git a/log.c b/log.c index 8c09ec1b2..96626d7d4 100644 --- a/log.c +++ b/log.c @@ -34,7 +34,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: log.c,v 1.23 2002/07/06 01:00:49 deraadt Exp $"); +RCSID("$OpenBSD: log.c,v 1.24 2002/07/19 15:43:33 markus Exp $"); #include "log.h" #include "xmalloc.h" @@ -223,6 +223,18 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context) (u_long) proc, (u_long) context); } +/* Remove all cleanups, to be called after fork() */ +void +fatal_remove_all_cleanups(void) +{ + struct fatal_cleanup *cu, *next_cu; + + for (cu = fatal_cleanups; cu; cu = next_cu) { + next_cu = cu->next; + xfree(cu); + } +} + /* Cleanup and exit */ void fatal_cleanup(void) diff --git a/log.h b/log.h index 3e4c3c3a7..917fafa69 100644 --- a/log.h +++ b/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.7 2002/05/19 20:54:52 deraadt Exp $ */ +/* $OpenBSD: log.h,v 1.8 2002/07/19 15:43:33 markus Exp $ */ /* * Author: Tatu Ylonen @@ -64,6 +64,7 @@ void debug3(const char *, ...) __attribute__((format(printf, 1, 2))); void fatal_cleanup(void); void fatal_add_cleanup(void (*) (void *), void *); void fatal_remove_cleanup(void (*) (void *), void *); +void fatal_remove_all_cleanups(void); void do_log(LogLevel, const char *, va_list); diff --git a/session.c b/session.c index 3c759e472..38388d43a 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.143 2002/06/30 21:54:16 deraadt Exp $"); +RCSID("$OpenBSD: session.c,v 1.144 2002/07/19 15:43:33 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -470,6 +470,8 @@ do_exec_no_pty(Session *s, const char *command) /* Fork the child. */ if ((pid = fork()) == 0) { + fatal_remove_all_cleanups(); + /* Child. Reinitialize the log since the pid has changed. */ log_init(__progname, options.log_level, options.log_facility, log_stderr); @@ -585,6 +587,7 @@ do_exec_pty(Session *s, const char *command) /* Fork the child. */ if ((pid = fork()) == 0) { + fatal_remove_all_cleanups(); /* Child. Reinitialize the log because the pid has changed. */ log_init(__progname, options.log_level, options.log_facility, log_stderr); diff --git a/sshd.c b/sshd.c index 8f9d3c392..427ca3545 100644 --- a/sshd.c +++ b/sshd.c @@ -42,7 +42,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshd.c,v 1.255 2002/06/30 21:59:45 deraadt Exp $"); +RCSID("$OpenBSD: sshd.c,v 1.256 2002/07/19 15:43:33 markus Exp $"); #include #include @@ -303,9 +303,6 @@ grace_alarm_handler(int sig) { /* XXX no idea how fix this signal handler */ - /* Close the connection. */ - packet_close(); - /* Log error and exit. */ fatal("Timeout before authentication for %s.", get_remote_ipaddr()); } @@ -589,6 +586,8 @@ privsep_preauth(void) if (pid == -1) { fatal("fork of unprivileged child failed"); } else if (pid != 0) { + fatal_remove_cleanup((void (*) (void *)) packet_close, NULL); + debug2("Network child is on pid %ld", (long)pid); close(pmonitor->m_recvfd); @@ -602,6 +601,10 @@ privsep_preauth(void) while (waitpid(pid, &status, 0) < 0) if (errno != EINTR) break; + + /* Reinstall, since the child has finished */ + fatal_add_cleanup((void (*) (void *)) packet_close, NULL); + return (authctxt); } else { /* child */ @@ -649,6 +652,8 @@ privsep_postauth(Authctxt *authctxt) if (pmonitor->m_pid == -1) fatal("fork of unprivileged child failed"); else if (pmonitor->m_pid != 0) { + fatal_remove_cleanup((void (*) (void *)) packet_close, NULL); + debug2("User child is on pid %ld", (long)pmonitor->m_pid); close(pmonitor->m_recvfd); monitor_child_postauth(pmonitor); -- cgit v1.2.3 From b9051ec9a49473b81bcd50868e3367186d919fb2 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Tue, 23 Jul 2002 21:11:09 +0000 Subject: - markus@cvs.openbsd.org 2002/07/22 11:03:06 [session.c] fallback to _PATH_STDPATH on setusercontext+LOGIN_SETPATH errors; --- ChangeLog | 5 ++++- session.c | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 6c3b914d9..fd1396175 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,9 @@ - stevesk@cvs.openbsd.org 2002/07/21 18:34:43 [auth-options.h] remove invalid comment + - markus@cvs.openbsd.org 2002/07/22 11:03:06 + [session.c] + fallback to _PATH_STDPATH on setusercontext+LOGIN_SETPATH errors; 20020722 - (bal) AIX tty data limiting patch fix by leigh@solinno.co.uk @@ -1439,4 +1442,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2399 2002/07/23 21:07:45 mouring Exp $ +$Id: ChangeLog,v 1.2400 2002/07/23 21:11:09 mouring Exp $ diff --git a/session.c b/session.c index 38388d43a..e2e30340c 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.144 2002/07/19 15:43:33 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.145 2002/07/22 11:03:06 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -962,8 +962,10 @@ do_setup_env(Session *s, const char *shell) child_set_env(&env, &envsize, "LOGNAME", pw->pw_name); child_set_env(&env, &envsize, "HOME", pw->pw_dir); #ifdef HAVE_LOGIN_CAP - (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH); - child_set_env(&env, &envsize, "PATH", getenv("PATH")); + if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0) + child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); + else + child_set_env(&env, &envsize, "PATH", getenv("PATH")); #else /* HAVE_LOGIN_CAP */ # ifndef HAVE_CYGWIN /* -- cgit v1.2.3 From 5d860f02ca352cd8e51fe266cc2e1b5d58704964 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Thu, 1 Aug 2002 01:28:38 +0000 Subject: - markus@cvs.openbsd.org 2002/07/30 17:03:55 [auth-options.c servconf.c servconf.h session.c sshd_config sshd_config.5] add PermitUserEnvironment (off by default!); from dot@dotat.at; ok provos, deraadt --- ChangeLog | 6 +++++- auth-options.c | 5 +++-- servconf.c | 12 ++++++++++-- servconf.h | 3 ++- session.c | 4 ++-- sshd_config | 3 ++- sshd_config.5 | 17 ++++++++++++++++- 7 files changed, 40 insertions(+), 10 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 9657aca12..74ce05354 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,10 @@ - markus@cvs.openbsd.org 2002/07/29 18:57:30 [sshconnect.c] print file:line + - markus@cvs.openbsd.org 2002/07/30 17:03:55 + [auth-options.c servconf.c servconf.h session.c sshd_config sshd_config.5] + add PermitUserEnvironment (off by default!); from dot@dotat.at; + ok provos, deraadt 20020730 - (bal) [uidswap.c] SCO compile correction by gert@greenie.muc.de @@ -1486,4 +1490,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2412 2002/08/01 01:26:29 mouring Exp $ +$Id: ChangeLog,v 1.2413 2002/08/01 01:28:38 mouring Exp $ diff --git a/auth-options.c b/auth-options.c index 41a29f79c..8595fdc14 100644 --- a/auth-options.c +++ b/auth-options.c @@ -10,7 +10,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth-options.c,v 1.25 2002/07/21 18:32:20 stevesk Exp $"); +RCSID("$OpenBSD: auth-options.c,v 1.26 2002/07/30 17:03:55 markus Exp $"); #include "xmalloc.h" #include "match.h" @@ -133,7 +133,8 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) goto next_option; } cp = "environment=\""; - if (strncasecmp(opts, cp, strlen(cp)) == 0) { + if (options.permit_user_env && + strncasecmp(opts, cp, strlen(cp)) == 0) { char *s; struct envstring *new_envstring; diff --git a/servconf.c b/servconf.c index bdf39afb8..50fccdda8 100644 --- a/servconf.c +++ b/servconf.c @@ -10,7 +10,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: servconf.c,v 1.112 2002/06/23 09:46:51 deraadt Exp $"); +RCSID("$OpenBSD: servconf.c,v 1.113 2002/07/30 17:03:55 markus Exp $"); #if defined(KRB4) #include @@ -101,6 +101,7 @@ initialize_server_options(ServerOptions *options) options->kbd_interactive_authentication = -1; options->challenge_response_authentication = -1; options->permit_empty_passwd = -1; + options->permit_user_env = -1; options->use_login = -1; options->compression = -1; options->allow_tcp_forwarding = -1; @@ -223,6 +224,8 @@ fill_default_server_options(ServerOptions *options) options->challenge_response_authentication = 1; if (options->permit_empty_passwd == -1) options->permit_empty_passwd = 0; + if (options->permit_user_env == -1) + options->permit_user_env = 0; if (options->use_login == -1) options->use_login = 0; if (options->compression == -1) @@ -291,7 +294,7 @@ typedef enum { sPrintMotd, sPrintLastLog, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, sStrictModes, sEmptyPasswd, sKeepAlives, - sUseLogin, sAllowTcpForwarding, sCompression, + sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups, @@ -354,6 +357,7 @@ static struct { { "xauthlocation", sXAuthLocation }, { "strictmodes", sStrictModes }, { "permitemptypasswords", sEmptyPasswd }, + { "permituserenvironment", sPermitUserEnvironment }, { "uselogin", sUseLogin }, { "compression", sCompression }, { "keepalive", sKeepAlives }, @@ -713,6 +717,10 @@ parse_flag: intptr = &options->permit_empty_passwd; goto parse_flag; + case sPermitUserEnvironment: + intptr = &options->permit_user_env; + goto parse_flag; + case sUseLogin: intptr = &options->use_login; goto parse_flag; diff --git a/servconf.h b/servconf.h index c94f541d0..024987dd6 100644 --- a/servconf.h +++ b/servconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: servconf.h,v 1.58 2002/06/20 23:05:55 markus Exp $ */ +/* $OpenBSD: servconf.h,v 1.59 2002/07/30 17:03:55 markus Exp $ */ /* * Author: Tatu Ylonen @@ -97,6 +97,7 @@ typedef struct { int challenge_response_authentication; int permit_empty_passwd; /* If false, do not permit empty * passwords. */ + int permit_user_env; /* If true, read ~/.ssh/environment */ int use_login; /* If true, login(1) is used */ int compression; /* If true, compression is allowed */ int allow_tcp_forwarding; diff --git a/session.c b/session.c index e2e30340c..f2a1bf015 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.145 2002/07/22 11:03:06 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.146 2002/07/30 17:03:55 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1065,7 +1065,7 @@ do_setup_env(Session *s, const char *shell) auth_sock_name); /* read $HOME/.ssh/environment. */ - if (!options.use_login) { + if (options.permit_user_env && !options.use_login) { snprintf(buf, sizeof buf, "%.200s/.ssh/environment", pw->pw_dir); read_environment_file(&env, &envsize, buf); diff --git a/sshd_config b/sshd_config index 24c4e059e..f20d812ee 100644 --- a/sshd_config +++ b/sshd_config @@ -1,4 +1,4 @@ -# $OpenBSD: sshd_config,v 1.56 2002/06/20 23:37:12 markus Exp $ +# $OpenBSD: sshd_config,v 1.57 2002/07/30 17:03:55 markus Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. @@ -81,6 +81,7 @@ #KeepAlive yes #UseLogin no #UsePrivilegeSeparation yes +#PermitUserEnvironment no #Compression yes #MaxStartups 10 diff --git a/sshd_config.5 b/sshd_config.5 index 6625865ef..f43b2bb9b 100644 --- a/sshd_config.5 +++ b/sshd_config.5 @@ -34,7 +34,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: sshd_config.5,v 1.5 2002/07/09 17:46:25 stevesk Exp $ +.\" $OpenBSD: sshd_config.5,v 1.6 2002/07/30 17:03:55 markus Exp $ .Dd September 25, 1999 .Dt SSHD_CONFIG 5 .Os @@ -465,6 +465,21 @@ for root. If this option is set to .Dq no root is not allowed to login. +.It Cm PermitUserEnvironment +Specifies whether +.Pa ~/.ssh/environment +is read by +.Nm sshd +and whether +.Cm environment= +options in +.Pa ~/.ssh/authorized_keys +files are permitted. +The default is +.Dq no . +This option is useful for locked-down installations where +.Ev LD_PRELOAD +and suchlike can cause security problems. .It Cm PidFile Specifies the file that contains the process ID of the .Nm sshd -- cgit v1.2.3 From 5a80bba86f60c2ba8447c764ad2fd4e6207b544a Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 4 Sep 2002 16:39:02 +1000 Subject: - markus@cvs.openbsd.org 2002/08/22 21:45:41 [session.c] send signal name (not signal number) in "exit-signal" message; noticed by galb@vandyke.com --- ChangeLog | 6 +++++- session.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 07699b017..ce409160f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,10 @@ [auth1.c auth2.c] auth_root_allowed() is handled by the monitor in the privsep case, so skip this for use_privsep, ok stevesk@, fixes bugzilla #387/325 + - markus@cvs.openbsd.org 2002/08/22 21:45:41 + [session.c] + send signal name (not signal number) in "exit-signal" message; noticed + by galb@vandyke.com 20020820 - OpenBSD CVS Sync @@ -1568,4 +1572,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2434 2002/09/04 06:37:26 djm Exp $ +$Id: ChangeLog,v 1.2435 2002/09/04 06:39:02 djm Exp $ diff --git a/session.c b/session.c index f2a1bf015..0e78aca34 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.146 2002/07/30 17:03:55 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.147 2002/08/22 21:45:41 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1809,6 +1809,27 @@ session_pty_cleanup(void *session) PRIVSEP(session_pty_cleanup2(session)); } +static char * +sig2name(int sig) +{ +#define SSH_SIG(x) if (sig == SIG ## x) return #x + SSH_SIG(ABRT); + SSH_SIG(ALRM); + SSH_SIG(FPE); + SSH_SIG(HUP); + SSH_SIG(ILL); + SSH_SIG(INT); + SSH_SIG(KILL); + SSH_SIG(PIPE); + SSH_SIG(QUIT); + SSH_SIG(SEGV); + SSH_SIG(TERM); + SSH_SIG(USR1); + SSH_SIG(USR2); +#undef SSH_SIG + return "SIG@openssh.com"; +} + static void session_exit_message(Session *s, int status) { @@ -1826,7 +1847,7 @@ session_exit_message(Session *s, int status) packet_send(); } else if (WIFSIGNALED(status)) { channel_request_start(s->chanid, "exit-signal", 0); - packet_put_int(WTERMSIG(status)); + packet_put_cstring(sig2name(WTERMSIG(status))); #ifdef WCOREDUMP packet_put_char(WCOREDUMP(status)); #else /* WCOREDUMP */ -- cgit v1.2.3 From ebc230662977241a9fd9c68034de849772d39438 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 4 Sep 2002 16:45:09 +1000 Subject: - stevesk@cvs.openbsd.org 2002/08/29 15:57:25 [monitor.c session.c sshlogin.c sshlogin.h] pass addrlen with sockaddr *; from Hajimu UMEMOTO NOTE: there are also p-specific parts to this patch. ok markus@ --- ChangeLog | 6 +++++- monitor.c | 6 +++--- session.c | 6 +++--- sshlogin.c | 4 ++-- sshlogin.h | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index bb0016c14..dd497ebce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,10 @@ - stevesk@cvs.openbsd.org 2002/08/27 17:18:40 [ssh_config.5] some warning text for ForwardAgent and ForwardX11; ok markus@ + - stevesk@cvs.openbsd.org 2002/08/29 15:57:25 + [monitor.c session.c sshlogin.c sshlogin.h] + pass addrlen with sockaddr *; from Hajimu UMEMOTO + NOTE: there are also p-specific parts to this patch. ok markus@ 20020820 - OpenBSD CVS Sync @@ -1579,4 +1583,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2437 2002/09/04 06:40:37 djm Exp $ +$Id: ChangeLog,v 1.2438 2002/09/04 06:45:09 djm Exp $ diff --git a/monitor.c b/monitor.c index 8e7ccf894..e039f7a28 100644 --- a/monitor.c +++ b/monitor.c @@ -25,7 +25,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor.c,v 1.23 2002/08/02 14:43:15 millert Exp $"); +RCSID("$OpenBSD: monitor.c,v 1.24 2002/08/29 15:57:25 stevesk Exp $"); #include @@ -1002,8 +1002,8 @@ mm_record_login(Session *s, struct passwd *pw) * the address be 0.0.0.0. */ memset(&from, 0, sizeof(from)); + fromlen = sizeof(from); if (packet_connection_is_on_socket()) { - fromlen = sizeof(from); if (getpeername(packet_get_connection_in(), (struct sockaddr *) & from, &fromlen) < 0) { debug("getpeername: %.100s", strerror(errno)); @@ -1013,7 +1013,7 @@ mm_record_login(Session *s, struct passwd *pw) /* Record that there was a login on that tty from the remote host. */ record_login(s->pid, s->tty, pw->pw_name, pw->pw_uid, get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping), - (struct sockaddr *)&from); + (struct sockaddr *)&from, fromlen); } static void diff --git a/session.c b/session.c index 0e78aca34..566bd900e 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.147 2002/08/22 21:45:41 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.148 2002/08/29 15:57:25 stevesk Exp $"); #include "ssh.h" #include "ssh1.h" @@ -671,8 +671,8 @@ do_pre_login(Session *s) * the address be 0.0.0.0. */ memset(&from, 0, sizeof(from)); + fromlen = sizeof(from); if (packet_connection_is_on_socket()) { - fromlen = sizeof(from); if (getpeername(packet_get_connection_in(), (struct sockaddr *) & from, &fromlen) < 0) { debug("getpeername: %.100s", strerror(errno)); @@ -737,7 +737,7 @@ do_login(Session *s, const char *command) record_login(pid, s->tty, pw->pw_name, pw->pw_uid, get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping), - (struct sockaddr *)&from); + (struct sockaddr *)&from, fromlen); #ifdef USE_PAM /* diff --git a/sshlogin.c b/sshlogin.c index e76f94534..4cd1c0059 100644 --- a/sshlogin.c +++ b/sshlogin.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshlogin.c,v 1.4 2002/06/23 03:30:17 deraadt Exp $"); +RCSID("$OpenBSD: sshlogin.c,v 1.5 2002/08/29 15:57:25 stevesk Exp $"); #include "loginrec.h" @@ -65,7 +65,7 @@ get_last_login_time(uid_t uid, const char *logname, */ void record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid, - const char *host, struct sockaddr * addr) + const char *host, struct sockaddr * addr, socklen_t addrlen) { struct logininfo *li; diff --git a/sshlogin.h b/sshlogin.h index bd30278e0..287c0d9f6 100644 --- a/sshlogin.h +++ b/sshlogin.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshlogin.h,v 1.3 2001/06/26 17:27:25 markus Exp $ */ +/* $OpenBSD: sshlogin.h,v 1.4 2002/08/29 15:57:25 stevesk Exp $ */ /* * Author: Tatu Ylonen @@ -16,7 +16,7 @@ void record_login(pid_t, const char *, const char *, uid_t, - const char *, struct sockaddr *); + const char *, struct sockaddr *, socklen_t); void record_logout(pid_t, const char *, const char *); u_long get_last_login_time(uid_t, const char *, char *, u_int); -- cgit v1.2.3 From e9994cb4d77d36f54af146a9ca0ea4db03b861b6 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 10 Sep 2002 21:43:53 +1000 Subject: - (djm) Bug #365: Read /.ssh/environment properly under CygWin. Patch from Mark Bradshaw --- ChangeLog | 6 +++++- session.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index b7af8dd8e..f71dacaf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20020910 + - (djm) Bug #365: Read /.ssh/environment properly under CygWin. + Patch from Mark Bradshaw + 20020905 - (djm) OpenBSD CVS Sync - stevesk@cvs.openbsd.org 2002/09/04 18:52:42 @@ -1608,4 +1612,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2448 2002/09/05 06:53:20 djm Exp $ +$Id: ChangeLog,v 1.2449 2002/09/10 11:43:53 djm Exp $ diff --git a/session.c b/session.c index 566bd900e..d017b17f9 100644 --- a/session.c +++ b/session.c @@ -1067,7 +1067,7 @@ do_setup_env(Session *s, const char *shell) /* read $HOME/.ssh/environment. */ if (options.permit_user_env && !options.use_login) { snprintf(buf, sizeof buf, "%.200s/.ssh/environment", - pw->pw_dir); + strcmp(pw->pw_dir, "/") ? pw->pw_dir : ""); read_environment_file(&env, &envsize, buf); } if (debug_flag) { -- cgit v1.2.3 From f37e246f858cdd79be4f4e158b7b04778d1cb7e9 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 19 Sep 2002 11:47:55 +1000 Subject: - stevesk@cvs.openbsd.org 2002/09/12 19:50:36 [session.c ssh.1] add SSH_CONNECTION and deprecate SSH_CLIENT; bug #384. ok markus@ --- ChangeLog | 5 ++++- session.c | 8 +++++++- ssh.1 | 10 +++++----- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index c1c240a82..43c701af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ - stevesk@cvs.openbsd.org 2002/09/12 19:11:52 [ssh-agent.c] %u for uid print; ok markus@ + - stevesk@cvs.openbsd.org 2002/09/12 19:50:36 + [session.c ssh.1] + add SSH_CONNECTION and deprecate SSH_CLIENT; bug #384. ok markus@ 20020912 - (djm) Made GNOME askpass programs return non-zero if cancel button is @@ -653,4 +656,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2464 2002/09/19 01:46:58 djm Exp $ +$Id: ChangeLog,v 1.2465 2002/09/19 01:47:55 djm Exp $ diff --git a/session.c b/session.c index d017b17f9..5da295289 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.148 2002/08/29 15:57:25 stevesk Exp $"); +RCSID("$OpenBSD: session.c,v 1.149 2002/09/12 19:50:36 stevesk Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1011,10 +1011,16 @@ do_setup_env(Session *s, const char *shell) } } + /* SSH_CLIENT deprecated */ snprintf(buf, sizeof buf, "%.50s %d %d", get_remote_ipaddr(), get_remote_port(), get_local_port()); child_set_env(&env, &envsize, "SSH_CLIENT", buf); + snprintf(buf, sizeof buf, "%.50s %d %.50s %d", + get_remote_ipaddr(), get_remote_port(), + get_local_ipaddr(packet_get_connection_in()), get_local_port()); + child_set_env(&env, &envsize, "SSH_CONNECTION", buf); + if (s->ttyfd != -1) child_set_env(&env, &envsize, "SSH_TTY", s->tty); if (s->term) diff --git a/ssh.1 b/ssh.1 index ce0dd291d..a65da5611 100644 --- a/ssh.1 +++ b/ssh.1 @@ -34,7 +34,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: ssh.1,v 1.165 2002/09/11 17:55:03 stevesk Exp $ +.\" $OpenBSD: ssh.1,v 1.166 2002/09/12 19:50:36 stevesk Exp $ .Dd September 25, 1999 .Dt SSH 1 .Os @@ -726,11 +726,11 @@ to make this work.) .It Ev SSH_AUTH_SOCK Identifies the path of a unix-domain socket used to communicate with the agent. -.It Ev SSH_CLIENT -Identifies the client end of the connection. +.It Ev SSH_CONNECTION +Identifies the client and server ends of the connection. The variable contains -three space-separated values: client ip-address, client port number, -and server port number. +four space-separated values: client ip-address, client port number, +server ip-address and server port number. .It Ev SSH_ORIGINAL_COMMAND The variable contains the original command line if a forced command is executed. -- cgit v1.2.3 From a6eb2b7f8ebb2eef6f21c4da08ac11a97a38a190 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 19 Sep 2002 11:50:48 +1000 Subject: - stevesk@cvs.openbsd.org 2002/09/16 19:55:33 [session.c] log when _PATH_NOLOGIN exists; ok markus@ --- ChangeLog | 5 ++++- session.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index b0b40b288..aaadccdbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ [channels.c sshconnect.c sshd.c] remove use of SO_LINGER, it should not be needed. error check SO_REUSEADDR. fixup comments. ok markus@ + - stevesk@cvs.openbsd.org 2002/09/16 19:55:33 + [session.c] + log when _PATH_NOLOGIN exists; ok markus@ 20020912 - (djm) Made GNOME askpass programs return non-zero if cancel button is @@ -660,4 +663,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2466 2002/09/19 01:49:37 djm Exp $ +$Id: ChangeLog,v 1.2467 2002/09/19 01:50:48 djm Exp $ diff --git a/session.c b/session.c index 5da295289..ed489214d 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.149 2002/09/12 19:50:36 stevesk Exp $"); +RCSID("$OpenBSD: session.c,v 1.150 2002/09/16 19:55:33 stevesk Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1168,6 +1168,8 @@ do_nologin(struct passwd *pw) #endif if (f) { /* /etc/nologin exists. Print its contents and exit. */ + log("User %.100s not allowed because %s exists", + pw->pw_name, _PATH_NOLOGIN); while (fgets(buf, sizeof(buf), f)) fputs(buf, stderr); fclose(f); -- cgit v1.2.3 From 164725f40ecda144de706c94778e47dc86ae9257 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Wed, 25 Sep 2002 23:14:14 +0000 Subject: l) Fix issue where successfull login does not clear failure counts in AIX. Patch by dtucker@zip.com.au ok by djm --- ChangeLog | 6 +++++- auth-passwd.c | 16 ++++++++++++++-- session.c | 7 ------- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index 9eebcdebe..a42c010af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20020925 + - (bal) Fix issue where successfull login does not clear failure counts + in AIX. Patch by dtucker@zip.com.au ok by djm + 20020923 - (djm) OpenBSD CVS Sync - stevesk@cvs.openbsd.org 2002/09/23 20:46:27 @@ -715,4 +719,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2480 2002/09/25 02:20:52 djm Exp $ +$Id: ChangeLog,v 1.2481 2002/09/25 23:14:14 mouring Exp $ diff --git a/auth-passwd.c b/auth-passwd.c index 17bbd2ceb..185db7d6d 100644 --- a/auth-passwd.c +++ b/auth-passwd.c @@ -81,6 +81,9 @@ RCSID("$OpenBSD: auth-passwd.c,v 1.27 2002/05/24 16:45:16 stevesk Exp $"); #endif /* !USE_PAM && !HAVE_OSF_SIA */ extern ServerOptions options; +#ifdef WITH_AIXAUTHENTICATE +extern char *aixloginmsg; +#endif /* * Tries to authenticate the user using password. Returns true if @@ -113,7 +116,7 @@ auth_password(Authctxt *authctxt, const char *password) #endif #ifdef WITH_AIXAUTHENTICATE char *authmsg; - char *loginmsg; + int authsuccess; int reenter = 1; #endif @@ -145,7 +148,16 @@ auth_password(Authctxt *authctxt, const char *password) } #endif #ifdef WITH_AIXAUTHENTICATE - return (authenticate(pw->pw_name,password,&reenter,&authmsg) == 0); + authsuccess = (authenticate(pw->pw_name,password,&reenter,&authmsg) == 0); + + if (authsuccess) + /* We don't have a pty yet, so just label the line as "ssh" */ + if (loginsuccess(authctxt->user, + get_canonical_hostname(options.verify_reverse_mapping), + "ssh", &aixloginmsg) < 0) + aixloginmsg = NULL; + + return(authsuccess); #endif #ifdef KRB4 if (options.kerberos_authentication == 1) { diff --git a/session.c b/session.c index ed489214d..0ccd2006d 100644 --- a/session.c +++ b/session.c @@ -210,13 +210,6 @@ do_authenticated(Authctxt *authctxt) close(startup_pipe); startup_pipe = -1; } -#ifdef WITH_AIXAUTHENTICATE - /* We don't have a pty yet, so just label the line as "ssh" */ - if (loginsuccess(authctxt->user, - get_canonical_hostname(options.verify_reverse_mapping), - "ssh", &aixloginmsg) < 0) - aixloginmsg = NULL; -#endif /* WITH_AIXAUTHENTICATE */ /* setup the channel layer */ if (!no_port_forwarding_flag && options.allow_tcp_forwarding) -- cgit v1.2.3 From 81ed518b9b888502cc57b23c02c47634ca508748 Mon Sep 17 00:00:00 2001 From: Tim Rice Date: Wed, 25 Sep 2002 17:38:46 -0700 Subject: Cray fixes (bug 367) based on patch from Wendy Palm @ cray. This does not include the deattack.c fixes. --- ChangeLog | 4 +++- acconfig.h | 5 ++++- auth1.c | 9 +++++++++ auth2.c | 11 +++++++++++ configure.ac | 7 ++++--- defines.h | 14 +++++++------- includes.h | 8 ++++++++ loginrec.c | 6 +++--- openbsd-compat/bsd-cray.c | 4 ++-- openbsd-compat/bsd-cray.h | 4 ++-- serverloop.c | 2 ++ session.c | 27 ++++++++++++++++++++++++++- sshd.c | 2 +- sshpty.c | 8 ++++---- 14 files changed, 86 insertions(+), 25 deletions(-) (limited to 'session.c') diff --git a/ChangeLog b/ChangeLog index a42c010af..24074d183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 20020925 - (bal) Fix issue where successfull login does not clear failure counts in AIX. Patch by dtucker@zip.com.au ok by djm + - (tim) Cray fixes (bug 367) based on patch from Wendy Palm @ cray. + This does not include the deattack.c fixes. 20020923 - (djm) OpenBSD CVS Sync @@ -719,4 +721,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2481 2002/09/25 23:14:14 mouring Exp $ +$Id: ChangeLog,v 1.2482 2002/09/26 00:38:46 tim Exp $ diff --git a/acconfig.h b/acconfig.h index f8fc650d7..3e058f3ea 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,4 +1,4 @@ -/* $Id: acconfig.h,v 1.144 2002/07/14 20:36:50 tim Exp $ */ +/* $Id: acconfig.h,v 1.145 2002/09/26 00:38:48 tim Exp $ */ #ifndef _CONFIG_H #define _CONFIG_H @@ -150,6 +150,9 @@ /* Define if you don't want to use lastlog */ #undef DISABLE_LASTLOG +/* Define if you don't want to use lastlog in session.c */ +#undef NO_SSH_LASTLOG + /* Define if you don't want to use utmp */ #undef DISABLE_UTMP diff --git a/auth1.c b/auth1.c index 4d2b92a22..676c8a667 100644 --- a/auth1.c +++ b/auth1.c @@ -304,6 +304,15 @@ do_authloop(Authctxt *authctxt) fatal("INTERNAL ERROR: authenticated invalid user %s", authctxt->user); +#ifdef _UNICOS + if (type == SSH_CMSG_AUTH_PASSWORD && !authenticated) + cray_login_failure(authctxt->user, IA_UDBERR); + if (authenticated && cray_access_denied(authctxt->user)) { + authenticated = 0; + fatal("Access denied for user %s.",authctxt->user); + } +#endif /* _UNICOS */ + #ifdef HAVE_CYGWIN if (authenticated && !check_nt_auth(type == SSH_CMSG_AUTH_PASSWORD, pw)) { diff --git a/auth2.c b/auth2.c index 1cb9769ff..17c58552a 100644 --- a/auth2.c +++ b/auth2.c @@ -216,6 +216,13 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method) authenticated = 0; #endif /* USE_PAM */ +#ifdef _UNICOS + if (authenticated && cray_access_denied(authctxt->user)) { + authenticated = 0; + fatal("Access denied for user %s.",authctxt->user); + } +#endif /* _UNICOS */ + /* Log before sending the reply */ auth_log(authctxt, authenticated, method, " ssh2"); @@ -235,6 +242,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method) if (authctxt->failures++ > AUTH_FAIL_MAX) { packet_disconnect(AUTH_FAIL_MSG, authctxt->user); } +#ifdef _UNICOS + if (strcmp(method, "password") == 0) + cray_login_failure(authctxt->user, IA_UDBERR); +#endif /* _UNICOS */ methods = authmethods_get(); packet_start(SSH2_MSG_USERAUTH_FAILURE); packet_put_cstring(methods); diff --git a/configure.ac b/configure.ac index f88d993e6..5fe50e56b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $Id: configure.ac,v 1.88 2002/09/23 23:54:12 tim Exp $ +# $Id: configure.ac,v 1.89 2002/09/26 00:38:47 tim Exp $ AC_INIT AC_CONFIG_SRCDIR([ssh.c]) @@ -303,6 +303,7 @@ mips-sony-bsd|mips-sony-newsos4) no_libnsl=1 AC_DEFINE(USE_PIPES) AC_DEFINE(DISABLE_FD_PASSING) + AC_DEFINE(NO_SSH_LASTLOG) LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal" LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm" MANTYPE=cat @@ -376,14 +377,14 @@ AC_ARG_WITH(libs, # Checks for header files. AC_CHECK_HEADERS(bstring.h crypt.h endian.h floatingpoint.h \ - getopt.h glob.h lastlog.h limits.h login.h \ + getopt.h glob.h ia.h lastlog.h limits.h login.h \ login_cap.h maillock.h netdb.h netgroup.h \ netinet/in_systm.h paths.h pty.h readpassphrase.h \ rpc/types.h security/pam_appl.h shadow.h stddef.h stdint.h \ strings.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h \ sys/mman.h sys/select.h sys/stat.h \ sys/stropts.h sys/sysmacros.h sys/time.h \ - sys/un.h time.h ttyent.h usersec.h \ + sys/un.h time.h tmpdir.h ttyent.h usersec.h \ util.h utime.h utmp.h utmpx.h) # Checks for libraries. diff --git a/defines.h b/defines.h index 42b12e9a4..ab19a077c 100644 --- a/defines.h +++ b/defines.h @@ -1,7 +1,7 @@ #ifndef _DEFINES_H #define _DEFINES_H -/* $Id: defines.h,v 1.95 2002/08/21 02:54:12 mouring Exp $ */ +/* $Id: defines.h,v 1.96 2002/09/26 00:38:48 tim Exp $ */ /* Constants */ @@ -124,7 +124,7 @@ typedef char int8_t; # if (SIZEOF_SHORT_INT == 2) typedef short int int16_t; # else -# if defined(_CRAY) && !defined(_CRAYSV2) +# ifdef _UNICOS # if (SIZEOF_SHORT_INT == 4) typedef short int16_t; # else @@ -132,16 +132,16 @@ typedef long int16_t; # endif # else # error "16 bit int type not found." -# endif /* _CRAY */ +# endif /* _UNICOS */ # endif # if (SIZEOF_INT == 4) typedef int int32_t; # else -# if defined(_CRAY) && !defined(_CRAYSV2) +# ifdef _UNICOS typedef long int32_t; # else # error "32 bit int type not found." -# endif /* _CRAY */ +# endif /* _UNICOS */ # endif #endif @@ -161,7 +161,7 @@ typedef unsigned char u_int8_t; # if (SIZEOF_SHORT_INT == 2) typedef unsigned short int u_int16_t; # else -# if defined(_CRAY) && !defined(_CRAYSV2) +# ifdef _UNICOS # if (SIZEOF_SHORT_INT == 4) typedef unsigned short u_int16_t; # else @@ -174,7 +174,7 @@ typedef unsigned long u_int16_t; # if (SIZEOF_INT == 4) typedef unsigned int u_int32_t; # else -# if defined(_CRAY) && !defined(_CRAYSV2) +# ifdef _UNICOS typedef unsigned long u_int32_t; # else # error "32 bit int type not found." diff --git a/includes.h b/includes.h index f6aa2ae67..d7b875c52 100644 --- a/includes.h +++ b/includes.h @@ -149,6 +149,14 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } # include #endif +#ifdef HAVE_IA_H +# include +#endif + +#ifdef HAVE_TMPDIR_H +# include +#endif + #include /* For OPENSSL_VERSION_NUMBER */ #include "defines.h" diff --git a/loginrec.c b/loginrec.c index 6dc608a4e..02c3106a3 100644 --- a/loginrec.c +++ b/loginrec.c @@ -163,7 +163,7 @@ #include "log.h" #include "atomicio.h" -RCSID("$Id: loginrec.c,v 1.43 2002/07/22 23:34:25 mouring Exp $"); +RCSID("$Id: loginrec.c,v 1.44 2002/09/26 00:38:49 tim Exp $"); #ifdef HAVE_UTIL_H # include @@ -622,13 +622,13 @@ construct_utmp(struct logininfo *li, switch (li->type) { case LTYPE_LOGIN: ut->ut_type = USER_PROCESS; -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS cray_set_tmpdir(ut); #endif break; case LTYPE_LOGOUT: ut->ut_type = DEAD_PROCESS; -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS cray_retain_utmp(ut, li->pid); #endif break; diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c index 8a14b0807..edb3112b3 100644 --- a/openbsd-compat/bsd-cray.c +++ b/openbsd-compat/bsd-cray.c @@ -1,5 +1,5 @@ /* - * $Id: bsd-cray.c,v 1.7 2002/07/23 21:00:18 mouring Exp $ + * $Id: bsd-cray.c,v 1.8 2002/09/26 00:38:51 tim Exp $ * * bsd-cray.c * @@ -34,7 +34,7 @@ * on UNICOS systems. * */ -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS #include #include diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index 0b75b2268..8868b4364 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h @@ -1,5 +1,5 @@ /* - * $Id: bsd-cray.h,v 1.4 2002/07/23 21:00:18 mouring Exp $ + * $Id: bsd-cray.h,v 1.5 2002/09/26 00:38:51 tim Exp $ * * bsd-cray.h * @@ -37,7 +37,7 @@ #ifndef _BSD_CRAY_H #define _BSD_CRAY_H -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS void cray_init_job(struct passwd *); /* init cray job */ void cray_job_termination_handler(int); /* process end of job signal */ void cray_login_failure(char *username, int errcode); diff --git a/serverloop.c b/serverloop.c index 5112de680..58e20dfb9 100644 --- a/serverloop.c +++ b/serverloop.c @@ -144,7 +144,9 @@ sigchld_handler(int sig) int save_errno = errno; debug("Received SIGCHLD."); child_terminated = 1; +#ifndef _UNICOS mysignal(SIGCHLD, sigchld_handler); +#endif notify_parent(); errno = save_errno; } diff --git a/session.c b/session.c index 0ccd2006d..9074525a4 100644 --- a/session.c +++ b/session.c @@ -512,10 +512,17 @@ do_exec_no_pty(Session *s, const char *command) perror("dup2 stderr"); #endif /* USE_PIPES */ +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif + /* Do processing for the child (exec command etc). */ do_child(s, command); /* NOTREACHED */ } +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ #ifdef HAVE_CYGWIN if (is_winnt) cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); @@ -603,8 +610,12 @@ do_exec_pty(Session *s, const char *command) /* record login, etc. similar to login(1) */ #ifndef HAVE_OSF_SIA - if (!(options.use_login && command == NULL)) + if (!(options.use_login && command == NULL)) { +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif /* _UNICOS */ do_login(s, command); + } # ifdef LOGIN_NEEDS_UTMPX else do_pre_login(s); @@ -615,6 +626,9 @@ do_exec_pty(Session *s, const char *command) do_child(s, command); /* NOTREACHED */ } +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ #ifdef HAVE_CYGWIN if (is_winnt) cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); @@ -755,6 +769,7 @@ do_login(Session *s, const char *command) printf("%s\n", aixloginmsg); #endif /* WITH_AIXAUTHENTICATE */ +#ifndef NO_SSH_LASTLOG if (options.print_lastlog && s->last_login_time != 0) { time_string = ctime(&s->last_login_time); if (strchr(time_string, '\n')) @@ -765,6 +780,7 @@ do_login(Session *s, const char *command) printf("Last login: %s from %s\r\n", time_string, s->hostname); } +#endif /* NO_SSH_LASTLOG */ do_motd(); } @@ -1024,6 +1040,11 @@ do_setup_env(Session *s, const char *shell) child_set_env(&env, &envsize, "SSH_ORIGINAL_COMMAND", original_command); +#ifdef _UNICOS + if (cray_tmpdir[0] != '\0') + child_set_env(&env, &envsize, "TMPDIR", cray_tmpdir); +#endif /* _UNICOS */ + #ifdef _AIX { char *cp; @@ -1275,6 +1296,10 @@ do_child(Session *s, const char *command) if (options.use_login && command != NULL) options.use_login = 0; +#ifdef _UNICOS + cray_setup(pw->pw_uid, pw->pw_name, command); +#endif /* _UNICOS */ + /* * Login(1) does this as well, and it needs uid 0 for the "-h" * switch, so we let login(1) to this for us. diff --git a/sshd.c b/sshd.c index 17f001669..37026dc2e 100644 --- a/sshd.c +++ b/sshd.c @@ -940,7 +940,7 @@ main(int ac, char **av) SYSLOG_FACILITY_AUTH : options.log_facility, !inetd_flag); -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS /* Cray can define user privs drop all prives now! * Not needed on PRIV_SU systems! */ diff --git a/sshpty.c b/sshpty.c index e3027ca2e..28d0e310c 100644 --- a/sshpty.c +++ b/sshpty.c @@ -162,7 +162,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) } return 1; #else /* HAVE_DEV_PTS_AND_PTC */ -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS char buf[64]; int i; int highpty; @@ -268,7 +268,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname) void *old; #endif /* USE_VHANGUP */ -#if defined(_CRAY) && !defined(_CRAYSV2) +#ifdef _UNICOS if (setsid() < 0) error("setsid: %.100s", strerror(errno)); @@ -290,7 +290,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname) error("%.100s: %.100s", ttyname, strerror(errno)); close(*ttyfd); *ttyfd = fd; -#else /* _CRAY */ +#else /* _UNICOS */ /* First disconnect from the old controlling tty. */ #ifdef TIOCNOTTY @@ -345,7 +345,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname) strerror(errno)); else close(fd); -#endif /* _CRAY */ +#endif /* _UNICOS */ } /* Changes the window size associated with the pty. */ -- cgit v1.2.3