summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2004-12-20 14:24:57 +0000
committerMatt Johnston <matt@ucc.asn.au>2004-12-20 14:24:57 +0000
commit93de4408f1c9069fcd2fb427d96c3084371c9295 (patch)
tree0224a9d7257f7e4d30baaf7aa32efb1d9a7498fd
parentdb1345ea08beb72f3e6b5420cd4163a01719a0e0 (diff)
downloaddropbear-93de4408f1c9069fcd2fb427d96c3084371c9295.tar.gz
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/
-rw-r--r--bignum.c19
-rw-r--r--bignum.h1
-rw-r--r--channel.h2
-rw-r--r--common-algo.c4
-rw-r--r--dbutil.c1
-rw-r--r--dss.c19
-rw-r--r--loginrec.c150
-rw-r--r--loginrec.h9
8 files changed, 25 insertions, 180 deletions
diff --git a/bignum.c b/bignum.c
index 4552d30..97901fb 100644
--- a/bignum.c
+++ b/bignum.c
@@ -52,25 +52,6 @@ void m_mp_init_multi(mp_int *mp, ...)
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) {
diff --git a/bignum.h b/bignum.h
index 27f5e77..2a807af 100644
--- a/bignum.h
+++ b/bignum.h
@@ -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);
diff --git a/channel.h b/channel.h
index 535960e..be6dd60 100644
--- a/channel.h
+++ b/channel.h
@@ -118,7 +118,9 @@ void recv_msg_channel_eof();
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);
diff --git a/common-algo.c b/common-algo.c
index e1d22e1..22cdc70 100644
--- a/common-algo.c
+++ b/common-algo.c
@@ -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 @@ void crypto_init() {
const struct _cipher_descriptor *regciphers[] = {
#ifdef DROPBEAR_AES128_CBC
- &rijndael_desc,
+ &aes_desc,
#endif
#ifdef DROPBEAR_BLOWFISH_CBC
&blowfish_desc,
diff --git a/dbutil.c b/dbutil.c
index cc7fcf8..cf57118 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -70,7 +70,6 @@ void (*_dropbear_log)(int priority, const char* format, va_list param)
int debug_trace = 0;
#endif
-int usingsyslog = 0; /* set by runopts, but required externally to sessions */
#ifndef DISABLE_SYSLOG
void startsyslog() {
diff --git a/dss.c b/dss.c
index 5bd358a..0cb437c 100644
--- a/dss.c
+++ b/dss.c
@@ -261,6 +261,25 @@ out:
}
#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
*
diff --git a/loginrec.c b/loginrec.c
index 727a290..f231ef8 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -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 utmp_write_entry(struct logininfo *li);
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 @@ login_logout(struct logininfo *li)
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 @@ login_utmp_only(struct logininfo *li)
}
#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 @@ lastlog_write_entry(struct logininfo *li)
}
}
-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 */
diff --git a/loginrec.h b/loginrec.h
index f253fa6..03d26b9 100644
--- a/loginrec.h
+++ b/loginrec.h
@@ -150,7 +150,6 @@ struct logininfo {
/** '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 @@ int login_log_entry(struct logininfo *li);
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);