summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-05-08 20:34:31 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-05-08 20:34:31 +0000
commit5d90dc6c118e9f7282d2db97f61c8ca1049ba4c3 (patch)
tree7c732ab7492dd28b76142149543af442b03284f8
parent3ea0c4d548683e7e120f0f77cc8ff0070d8dc713 (diff)
- (bal) UseLogin patch for Solaris/UNICOS. Patch by Wayne Davison
<wayne@blorf.net>
-rw-r--r--ChangeLog6
-rw-r--r--acconfig.h8
-rw-r--r--configure.in4
-rw-r--r--loginrec.c23
-rw-r--r--loginrec.h5
-rw-r--r--session.c38
-rw-r--r--sshlogin.c14
-rw-r--r--sshlogin.h9
8 files changed, 102 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e2b2f43..485cd190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+20010509
+ - (bal) UseLogin patch for Solaris/UNICOS. Patch by Wayne Davison
+ <wayne@blorf.net>
+
20010508
- (bal) Fixed configure test for USE_SIA.
@@ -5290,4 +5294,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1179.2.10 2001/05/07 12:59:19 mouring Exp $
+$Id: ChangeLog,v 1.1179.2.11 2001/05/08 20:34:31 mouring Exp $
diff --git a/acconfig.h b/acconfig.h
index b4cfe040..9ceac7d4 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,4 +1,4 @@
-/* $Id: acconfig.h,v 1.110 2001/04/05 17:15:08 stevesk Exp $ */
+/* $Id: acconfig.h,v 1.110.2.1 2001/05/08 20:34:32 mouring Exp $ */
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -154,6 +154,12 @@
/* Define if you don't want to use wtmpx */
#undef DISABLE_WTMPX
+/* Some systems need a utmpx entry for /bin/login to work */
+#undef LOGIN_NEEDS_UTMPX
+
+/* Some versions of /bin/login need the TERM supplied on the commandline */
+#undef LOGIN_NEEDS_TERM
+
/* Define if you want to specify the path to your lastlog file */
#undef CONF_LASTLOG_FILE
diff --git a/configure.in b/configure.in
index 4b54730f..cab15a5b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.282.2.1 2001/05/07 12:59:20 mouring Exp $
+# $Id: configure.in,v 1.282.2.2 2001/05/08 20:34:33 mouring Exp $
AC_INIT(ssh.c)
@@ -153,6 +153,8 @@ mips-sony-bsd|mips-sony-newsos4)
LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
need_dash_r=1
AC_DEFINE(PAM_SUN_CODEBASE)
+ AC_DEFINE(LOGIN_NEEDS_UTMPX)
+ AC_DEFINE(LOGIN_NEEDS_TERM)
# hardwire lastlog location (can't detect it on some versions)
conf_lastlog_location="/var/adm/lastlog"
AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
diff --git a/loginrec.c b/loginrec.c
index c703663a..f492d581 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -163,7 +163,7 @@
#include "log.h"
#include "atomicio.h"
-RCSID("$Id: loginrec.c,v 1.32 2001/02/22 21:23:21 stevesk Exp $");
+RCSID("$Id: loginrec.c,v 1.32.4.1 2001/05/08 20:34:33 mouring Exp $");
#ifdef HAVE_UTIL_H
# include <util.h>
@@ -443,6 +443,27 @@ login_write (struct logininfo *li)
return 0;
}
+#ifdef LOGIN_NEEDS_UTMPX
+int
+login_utmp_only(struct logininfo *li)
+{
+ li->type = LTYPE_LOGIN;
+# ifdef USE_UTMP
+ utmp_write_entry(li);
+# endif
+# ifdef USE_WTMP
+ wtmp_write_entry(li);
+# endif
+# ifdef USE_UTMPX
+ utmpx_write_entry(li);
+# endif
+# ifdef USE_WTMPX
+ wtmpx_write_entry(li);
+# endif
+ return 0;
+}
+#endif
+
/**
** getlast_entry: Call low-level functions to retrieve the last login
** time.
diff --git a/loginrec.h b/loginrec.h
index ecb430d5..63d2e5f6 100644
--- a/loginrec.h
+++ b/loginrec.h
@@ -40,7 +40,7 @@
#include <netinet/in.h>
#include <sys/socket.h>
-/* RCSID("$Id: loginrec.h,v 1.5 2001/02/05 12:42:18 stevesk Exp $"); */
+/* RCSID("$Id: loginrec.h,v 1.5.8.1 2001/05/08 20:34:33 mouring Exp $"); */
/**
** you should use the login_* calls to work around platform dependencies
@@ -110,6 +110,9 @@ void login_set_current_time(struct logininfo *li);
/* record the entry */
int login_login (struct logininfo *li);
int login_logout(struct logininfo *li);
+#ifdef LOGIN_NEEDS_UTMPX
+int login_utmp_only(struct logininfo *li);
+#endif
/** End of public functions */
diff --git a/session.c b/session.c
index 3960c9f2..71ed304e 100644
--- a/session.c
+++ b/session.c
@@ -127,6 +127,9 @@ void session_proctitle(Session *s);
void do_exec_pty(Session *s, const char *command);
void do_exec_no_pty(Session *s, const char *command);
void do_login(Session *s, const char *command);
+#ifdef LOGIN_NEEDS_UTMPX
+void do_pre_login(Session *s);
+#endif
void do_child(Session *s, const char *command);
void do_motd(void);
int check_quietlogin(Session *s, const char *command);
@@ -644,6 +647,10 @@ do_exec_pty(Session *s, const char *command)
#ifndef HAVE_OSF_SIA
if (!(options.use_login && command == NULL))
do_login(s, command);
+# ifdef LOGIN_NEEDS_UTMPX
+ else
+ do_pre_login(s);
+# endif
#endif
/* Do common processing for the child, such as execing the command. */
@@ -687,6 +694,34 @@ do_exec_pty(Session *s, const char *command)
}
}
+#ifdef LOGIN_NEEDS_UTMPX
+void
+do_pre_login(Session *s)
+{
+ socklen_t fromlen;
+ struct sockaddr_storage from;
+ pid_t pid = getpid();
+
+ /*
+ * Get IP address of client. If the connection is not a socket, let
+ * the address be 0.0.0.0.
+ */
+ memset(&from, 0, 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));
+ fatal_cleanup();
+ }
+ }
+
+ record_utmp_only(pid, s->tty, s->pw->pw_name,
+ get_remote_name_or_ip(utmp_len, options.reverse_mapping_check),
+ (struct sockaddr *)&from);
+}
+#endif
+
/* administrative, login(1)-like work */
void
do_login(Session *s, const char *command)
@@ -1511,6 +1546,9 @@ do_child(Session *s, const char *command)
/* Launch login(1). */
execl(LOGIN_PROGRAM, "login", "-h", hostname,
+#ifdef LOGIN_NEEDS_TERM
+ s->term? s->term : "unknown",
+#endif
"-p", "-f", "--", pw->pw_name, NULL);
/* Login couldn't be executed, die. */
diff --git a/sshlogin.c b/sshlogin.c
index 1d9c031c..b7558b9e 100644
--- a/sshlogin.c
+++ b/sshlogin.c
@@ -77,6 +77,20 @@ record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
login_free_entry(li);
}
+#ifdef LOGIN_NEEDS_UTMPX
+void
+record_utmp_only(pid_t pid, const char *ttyname, const char *user,
+ const char *host, struct sockaddr * addr)
+{
+ struct logininfo *li;
+
+ li = login_alloc_entry(pid, user, host, ttyname);
+ login_set_addr(li, addr, sizeof(struct sockaddr));
+ login_utmp_only(li);
+ login_free_entry(li);
+}
+#endif
+
/* Records that the user has logged out. */
void
diff --git a/sshlogin.h b/sshlogin.h
index 64007cf0..20af2c8c 100644
--- a/sshlogin.h
+++ b/sshlogin.h
@@ -31,6 +31,15 @@ void
record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
const char *host, struct sockaddr *addr);
+#ifdef LOGIN_NEEDS_UTMPX
+/*
+ * Record just the utmp info for /bin/login.
+ */
+void
+record_utmp_only(pid_t pid, const char *ttyname, const char *user,
+ const char *host, struct sockaddr * addr);
+#endif
+
/*
* Records that the user has logged out. This does many thigs normally done
* by login(1) or init.