changeset 150:82fcf3185616

Cleaning out various dead wood found with -dead_strip bignum.c: mptobytes now resides in dss.c loginrec.c: remove lastlog code since it isn't used. dbutil.c: removed obselete usingsyslog variable channel.h: client channel type only defined for client compile common-algo.c: s/rijndael/aes/
author Matt Johnston <matt@ucc.asn.au>
date Mon, 20 Dec 2004 14:24:57 +0000
parents ed9ca2a9705c
children 6ba95762ec4e
files bignum.c bignum.h channel.h common-algo.c dbutil.c dss.c loginrec.c loginrec.h
diffstat 8 files changed, 25 insertions(+), 180 deletions(-) [+]
line wrap: on
line diff
--- a/bignum.c	Mon Dec 20 13:11:15 2004 +0000
+++ b/bignum.c	Mon Dec 20 14:24:57 2004 +0000
@@ -52,25 +52,6 @@
     va_end(args);
 }
 
-/* convert an unsigned mp into an array of bytes, malloced.
- * This array must be freed after use, len contains the length of the array,
- * if len != NULL */
-unsigned char* mptobytes(mp_int *mp, int *len) {
-	
-	unsigned char* ret;
-	int size;
-
-	size = mp_unsigned_bin_size(mp);
-	ret = m_malloc(size);
-	if (mp_to_unsigned_bin(mp, ret) != MP_OKAY) {
-		dropbear_exit("mem alloc error");
-	}
-	if (len != NULL) {
-		*len = size;
-	}
-	return ret;
-}
-
 void bytestomp(mp_int *mp, unsigned char* bytes, unsigned int len) {
 
 	if (mp_read_unsigned_bin(mp, bytes, len) != MP_OKAY) {
--- a/bignum.h	Mon Dec 20 13:11:15 2004 +0000
+++ b/bignum.h	Mon Dec 20 14:24:57 2004 +0000
@@ -29,7 +29,6 @@
 
 void m_mp_init(mp_int *mp);
 void m_mp_init_multi(mp_int *mp, ...);
-unsigned char* mptobytes(mp_int *mp, int *len);
 void bytestomp(mp_int *mp, unsigned char* bytes, unsigned int len);
 void sha1_process_mp(hash_state *hs, mp_int *mp);
 
--- a/channel.h	Mon Dec 20 13:11:15 2004 +0000
+++ b/channel.h	Mon Dec 20 14:24:57 2004 +0000
@@ -118,7 +118,9 @@
 void common_recv_msg_channel_data(struct Channel *channel, int fd, 
 		circbuffer * buf);
 
+#ifdef DROPBEAR_CLIENT
 const struct ChanType clichansess;
+#endif
 
 #ifdef USING_LISTENERS
 int send_msg_channel_open_init(int fd, const struct ChanType *type);
--- a/common-algo.c	Mon Dec 20 13:11:15 2004 +0000
+++ b/common-algo.c	Mon Dec 20 14:24:57 2004 +0000
@@ -34,7 +34,7 @@
 
 #ifdef DROPBEAR_AES128_CBC
 const struct dropbear_cipher dropbear_aes128 = 
-	{&rijndael_desc, 16, 16};
+	{&aes_desc, 16, 16};
 #endif
 #ifdef DROPBEAR_BLOWFISH_CBC
 const struct dropbear_cipher dropbear_blowfish = 
@@ -127,7 +127,7 @@
 
 	const struct _cipher_descriptor *regciphers[] = {
 #ifdef DROPBEAR_AES128_CBC
-		&rijndael_desc,
+		&aes_desc,
 #endif
 #ifdef DROPBEAR_BLOWFISH_CBC
 		&blowfish_desc,
--- a/dbutil.c	Mon Dec 20 13:11:15 2004 +0000
+++ b/dbutil.c	Mon Dec 20 14:24:57 2004 +0000
@@ -70,7 +70,6 @@
 int debug_trace = 0;
 #endif
 
-int usingsyslog = 0; /* set by runopts, but required externally to sessions */
 #ifndef DISABLE_SYSLOG
 void startsyslog() {
 
--- a/dss.c	Mon Dec 20 13:11:15 2004 +0000
+++ b/dss.c	Mon Dec 20 14:24:57 2004 +0000
@@ -261,6 +261,25 @@
 }
 #endif /* DROPBEAR_SIGNKEY_VERIFY */
 
+/* convert an unsigned mp into an array of bytes, malloced.
+ * This array must be freed after use, len contains the length of the array,
+ * if len != NULL */
+static unsigned char* mptobytes(mp_int *mp, int *len) {
+	
+	unsigned char* ret;
+	int size;
+
+	size = mp_unsigned_bin_size(mp);
+	ret = m_malloc(size);
+	if (mp_to_unsigned_bin(mp, ret) != MP_OKAY) {
+		dropbear_exit("mem alloc error");
+	}
+	if (len != NULL) {
+		*len = size;
+	}
+	return ret;
+}
+
 /* Sign the data presented with key, writing the signature contents
  * to the buffer
  *
--- a/loginrec.c	Mon Dec 20 13:11:15 2004 +0000
+++ b/loginrec.c	Mon Dec 20 14:24:57 2004 +0000
@@ -29,6 +29,8 @@
  ** loginrec.c:  platform-independent login recording and lastlog retrieval
  **/
 
+/* For now lastlog code has been removed as it wasn't being used by Dropbear. */
+
 /*
   The new login code explained
   ============================
@@ -174,11 +176,8 @@
 int utmpx_write_entry(struct logininfo *li);
 int wtmp_write_entry(struct logininfo *li);
 int wtmpx_write_entry(struct logininfo *li);
-int lastlog_write_entry(struct logininfo *li);
 int syslogin_write_entry(struct logininfo *li);
 
-int getlast_entry(struct logininfo *li);
-int lastlog_get_entry(struct logininfo *li);
 int wtmp_get_entry(struct logininfo *li);
 int wtmpx_get_entry(struct logininfo *li);
 
@@ -221,74 +220,6 @@
 	return login_write(li);
 }
 
-/* login_get_lastlog_time(int)           - Retrieve the last login time
- *
- * Retrieve the last login time for the given uid. Will try to use the
- * system lastlog facilities if they are available, but will fall back
- * to looking in wtmp/wtmpx if necessary
- *
- * Returns:
- *   0 on failure, or if user has never logged in
- *   Time in seconds from the epoch if successful
- *
- * Useful preprocessor symbols:
- *   DISABLE_LASTLOG: If set, *never* even try to retrieve lastlog
- *                    info
- *   USE_LASTLOG: If set, indicates the presence of system lastlog
- *                facilities. If this and DISABLE_LASTLOG are not set,
- *                try to retrieve lastlog information from wtmp/wtmpx.
- */
-unsigned int
-login_get_lastlog_time(const int uid)
-{
-	struct logininfo li;
-
-	if (login_get_lastlog(&li, uid))
-		return li.tv_sec;
-	else
-		return 0;
-}
-
-/* login_get_lastlog(struct logininfo *, int)   - Retrieve a lastlog entry
- *
- * Retrieve a logininfo structure populated (only partially) with
- * information from the system lastlog data, or from wtmp/wtmpx if no
- * system lastlog information exists.
- *
- * Note this routine must be given a pre-allocated logininfo.
- *
- * Returns:
- *  >0: A pointer to your struct logininfo if successful
- *  0  on failure (will use OpenSSH's logging facilities for diagnostics)
- *
- */
-struct logininfo *
-login_get_lastlog(struct logininfo *li, const int uid)
-{
-	struct passwd *pw;
-
-	memset(li, '\0', sizeof(*li));
-	li->uid = uid;
-
-	/*
-	 * If we don't have a 'real' lastlog, we need the username to
-	 * reliably search wtmp(x) for the last login (see
-	 * wtmp_get_entry().)
-	 */
-	pw = getpwuid(uid);
-	if (pw == NULL)
-		dropbear_exit("login_get_lastlog: Cannot find account for uid %i", uid);
-
-	/* No MIN_SIZEOF here - we absolutely *must not* truncate the
-	 * username */
-	strlcpy(li->username, pw->pw_name, sizeof(li->username));
-
-	if (getlast_entry(li))
-		return li;
-	else
-		return NULL;
-}
-
 
 /* login_alloc_entry(int, char*, char*, char*)    - Allocate and initialise
  *                                                  a logininfo structure
@@ -450,42 +381,6 @@
 }
 #endif
 
-/**
- ** getlast_entry: Call low-level functions to retrieve the last login
- **                time.
- **/
-
-/* take the uid in li and return the last login time */
-int
-getlast_entry(struct logininfo *li)
-{
-#ifdef USE_LASTLOG
-	return(lastlog_get_entry(li));
-#else /* !USE_LASTLOG */
-
-#ifdef DISABLE_LASTLOG
-	/* On some systems we shouldn't even try to obtain last login
-	 * time, e.g. AIX */
-	return 0;
-# else /* DISABLE_LASTLOG */
-	/* Try to retrieve the last login time from wtmp */
-#  if defined(USE_WTMP) && (defined(HAVE_STRUCT_UTMP_UT_TIME) || defined(HAVE_STRUCT_UTMP_UT_TV))
-	/* retrieve last login time from utmp */
-	return (wtmp_get_entry(li));
-#  else /* defined(USE_WTMP) && (defined(HAVE_STRUCT_UTMP_UT_TIME) || defined(HAVE_STRUCT_UTMP_UT_TV)) */
-	/* If wtmp isn't available, try wtmpx */
-#   if defined(USE_WTMPX) && (defined(HAVE_STRUCT_UTMPX_UT_TIME) || defined(HAVE_STRUCT_UTMPX_UT_TV))
-	/* retrieve last login time from utmpx */
-	return (wtmpx_get_entry(li));
-#   else
-	/* Give up: No means of retrieving last login time */
-	return 0;
-#   endif /* USE_WTMPX && (HAVE_STRUCT_UTMPX_UT_TIME || HAVE_STRUCT_UTMPX_UT_TV) */
-#  endif /* USE_WTMP && (HAVE_STRUCT_UTMP_UT_TIME || HAVE_STRUCT_UTMP_UT_TV) */
-# endif /* DISABLE_LASTLOG */
-#endif /* USE_LASTLOG */
-}
-
 
 
 /*
@@ -1495,45 +1390,4 @@
 	}
 }
 
-static void
-lastlog_populate_entry(struct logininfo *li, struct lastlog *last)
-{
-	line_fullname(li->line, last->ll_line, sizeof(li->line));
-	strlcpy(li->hostname, last->ll_host,
-		MIN_SIZEOF(li->hostname, last->ll_host));
-	li->tv_sec = last->ll_time;
-}
-
-int
-lastlog_get_entry(struct logininfo *li)
-{
-	struct lastlog last;
-	int fd, ret;
-
-	if (!lastlog_openseek(li, &fd, O_RDONLY))
-		return (0);
-
-	ret = atomicio(read, fd, &last, sizeof(last));
-	close(fd);
-
-	switch (ret) {
-	case 0:
-		memset(&last, '\0', sizeof(last));
-		/* FALLTHRU */
-	case sizeof(last):
-		lastlog_populate_entry(li, &last);
-		return (1);
-	case -1:
-		dropbear_log(LOG_ERR, "Error reading from %s: %s",
-		    LASTLOG_FILE, strerror(errno));
-		return (0);
-	default:
-		dropbear_log(LOG_ERR, "Error reading from %s: Expecting %d, got %d",
-		    LASTLOG_FILE, sizeof(last), ret);
-		return (0);
-	}
-
-	/* NOTREACHED */
-	return (0);
-}
 #endif /* USE_LASTLOG */
--- a/loginrec.h	Mon Dec 20 13:11:15 2004 +0000
+++ b/loginrec.h	Mon Dec 20 14:24:57 2004 +0000
@@ -150,7 +150,6 @@
 
 /** 'public' functions */
 
-/* construct a new login entry */
 struct logininfo *login_alloc_entry(int pid, const char *username,
 				    const char *hostname, const char *line);
 /* free a structure */
@@ -178,14 +177,6 @@
 void login_set_addr(struct logininfo *li, const struct sockaddr *sa,
 		    const unsigned int sa_size);
 
-/*
- * lastlog retrieval functions
- */
-/* lastlog *entry* functions fill out a logininfo */
-struct logininfo *login_get_lastlog(struct logininfo *li, const int uid);
-/* lastlog *time* functions return time_t equivalent (uint) */
-unsigned int login_get_lastlog_time(const int uid);
-
 /* produce various forms of the line filename */
 char *line_fullname(char *dst, const char *src, size_t dstsize);
 char *line_stripname(char *dst, const char *src, size_t dstsize);