From deee356a629c81aae64ac22266561e9cc4e13e8b Mon Sep 17 00:00:00 2001 From: Dennis Groenen Date: Tue, 24 Apr 2012 22:40:58 +0200 Subject: lineedit: histfile can get emptied when CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y When CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is set to y, the histfile will get cleared if the total amount of history lines is less than MAX_HISTORY. Only if the histfile is not empty _and_ the amount of lines currently in memory are equal to or greater than MAX_HISTORY, history saving will work as expected with this feature enabled. Output from defconfig + CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y: $ echo "foo" > ~/.ash_history $ ./busybox ash ~/busybox/a $ echo "bar" > /dev/null ~/busybox/a $ exit $ cat ~/.ash_history $ Output with the patch applied and same config as above: $ echo "foo" > ~/.ash_history $ ./busybox ash ~/busybox/b $ echo "bar" > /dev/null ~/busybox/b $ exit $ cat ~/.ash_history foo echo "bar" > /dev/null exit $ Signed-off-by: Dennis Groenen Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index db8416712..b89748a1c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1352,8 +1352,7 @@ static void load_history(line_input_t *st_parm) /* fill temp_h[], retaining only last MAX_HISTORY lines */ memset(temp_h, 0, sizeof(temp_h)); idx = 0; - if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT) - st_parm->cnt_history_in_file = 0; + st_parm->cnt_history_in_file = 0; while ((line = xmalloc_fgetline(fp)) != NULL) { if (line[0] == '\0') { free(line); @@ -1361,8 +1360,7 @@ static void load_history(line_input_t *st_parm) } free(temp_h[idx]); temp_h[idx] = line; - if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT) - st_parm->cnt_history_in_file++; + st_parm->cnt_history_in_file++; idx++; if (idx == st_parm->max_history) idx = 0; -- cgit v1.2.3-55-g6feb From 576b1d3c417ddea79481063401837ec0bdb91658 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 28 Apr 2012 17:04:19 +0200 Subject: sendmail: use host rather than NIS domain name for HELO According to RFC 5321 the argument to HELO "contains the fully-qualified domain name of the SMTP client" or its IP address if no FQDN is available. BusyBox sendmail uses the NIS domain name instead which, in many cases, is likely to be the default "(none)". [vda: yes, I checked my machine and its uts.domainname was indeed "(none)"] Using the host name is more likely to satisfy the intent of the RFC while allowing the otherwise unused safe_getdomainname function to be removed. Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- include/libbb.h | 1 - libbb/safe_gethostname.c | 22 ---------------------- mailutils/sendmail.c | 7 ++++--- 3 files changed, 4 insertions(+), 26 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 2cc146631..f12800f53 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -795,7 +795,6 @@ void qsort_string_vector(char **sv, unsigned count) FAST_FUNC; int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC; char *safe_gethostname(void) FAST_FUNC; -char *safe_getdomainname(void) FAST_FUNC; /* Convert each alpha char in str to lower-case */ char* str_tolower(char *str) FAST_FUNC; diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c index bdb989631..cac99ae03 100644 --- a/libbb/safe_gethostname.c +++ b/libbb/safe_gethostname.c @@ -50,25 +50,3 @@ char* FAST_FUNC safe_gethostname(void) uname(&uts); return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename)); } - -/* - * On success return the current malloced and NUL terminated domainname. - * On error return malloced and NUL terminated string "?". - * This is an illegal first character for a domainname. - * The returned malloced string must be freed by the caller. - */ -char* FAST_FUNC safe_getdomainname(void) -{ -#if defined(__linux__) -/* The field domainname of struct utsname is Linux specific. */ - struct utsname uts; - uname(&uts); - return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname)); -#else - /* We really don't care about people with domain names wider than most screens */ - char buf[256]; - int r = getdomainname(buf, sizeof(buf)); - buf[sizeof(buf)-1] = '\0'; - return xstrdup(r < 0 ? "?" : buf); -#endif -} diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index aa381c60f..c426e9d85 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -118,7 +118,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) char *opt_from; char *s; llist_t *list = NULL; - char *domain = sane_address(safe_getdomainname()); + char *host = sane_address(safe_gethostname()); unsigned nheaders = 0; int code; @@ -222,8 +222,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) } // we should start with modern EHLO - if (250 != smtp_checkp("EHLO %s", domain, -1)) - smtp_checkp("HELO %s", domain, 250); + if (250 != smtp_checkp("EHLO %s", host, -1)) + smtp_checkp("HELO %s", host, 250); + free(host); // perform authentication if (opts & OPT_a) { -- cgit v1.2.3-55-g6feb