From: Guenter Knauf Date: Sun, 17 Apr 2011 19:07:23 +0000 (+0000) Subject: Syncronize with trunk version. X-Git-Tag: 2.2.18~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12b344c571dd18fdd5442edde06fa108c2608474;p=thirdparty%2Fapache%2Fhttpd.git Syncronize with trunk version. This includes a couple of backports / fixes: r826805, r826822, r829162, r829355, r829431. The default algorithm is now md5 on all platforms. All patches by sf; backport reviewed by fuankg, wrowe, trawick. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1094184 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3f259ce6f0b..69b4e90486d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.18 + *) htpasswd: Change the default algorithm for htpasswd to MD5 on all + platforms. Crypt with its 8 character limit is not useful anymore; + improve out of disk space handling (PR 30877); print a warning if + a password is truncated by crypt. [Stefan Fritsch] + *) mod_win32: Added shebang check for '! so that .vbs scripts can work as CGI. Win32's cscript interpreter can only use a single quote as comment char. [Guenter Knauf] diff --git a/STATUS b/STATUS index c6c43e461c4..cee3cf6c441 100644 --- a/STATUS +++ b/STATUS @@ -91,15 +91,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * htpasswd.c: Syncronize with trunk version. This includes a couple of fixes: - r826805, r826822, r829162, r829355, r829431. The patch below covers only - the C code - we also need to apply the docs and CHANGES parts of r826805. - 2.2.x patch: http://people.apache.org/~fuankg/diffs/htpasswd.c.diff - sf: this will change the default algorithm from crypt to md5 (I am not - against it) - FWIW, htdbm in 2.2.x already defaults to MD5 - +1 fuankg, wrowe, trawick - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/support/htpasswd.c b/support/htpasswd.c index 2eadc78e29e..3aa9e184521 100644 --- a/support/htpasswd.c +++ b/support/htpasswd.c @@ -141,7 +141,15 @@ static apr_status_t seed_rand(void) static void putline(apr_file_t *f, const char *l) { - apr_file_puts(l, f); + apr_status_t rc; + rc = apr_file_puts(l, f); + if (rc != APR_SUCCESS) { + char errstr[MAX_STRING_LEN]; + apr_strerror(rc, errstr, MAX_STRING_LEN); + apr_file_printf(errfile, "Error writing temp file: %s" NL, errstr); + apr_file_close(f); + exit(ERR_FILEPERM); + } } /* @@ -201,7 +209,7 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd, apr_cpystrn(cpw,pw,sizeof(cpw)); break; -#if !(defined(WIN32) || defined(NETWARE)) +#if (!(defined(WIN32) || defined(NETWARE))) case ALG_CRYPT: default: if (seed_rand()) { @@ -210,7 +218,16 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd, to64(&salt[0], rand(), 8); salt[8] = '\0'; - apr_cpystrn(cpw, (char *)crypt(pw, salt), sizeof(cpw) - 1); + apr_cpystrn(cpw, crypt(pw, salt), sizeof(cpw) - 1); + if (strlen(pw) > 8) { + char *truncpw = strdup(pw); + truncpw[8] = '\0'; + if (!strcmp(cpw, crypt(truncpw, salt))) { + apr_file_printf(errfile, "Warning: Password truncated to 8 characters " + "by CRYPT algorithm." NL); + } + free(truncpw); + } break; #endif } @@ -243,14 +260,9 @@ static void usage(void) apr_file_printf(errfile, " -n Don't update file; display results on " "stdout." NL); apr_file_printf(errfile, " -m Force MD5 encryption of the password" -#if defined(WIN32) || defined(TPF) || defined(NETWARE) " (default)" -#endif "." NL); apr_file_printf(errfile, " -d Force CRYPT encryption of the password" -#if (!(defined(WIN32) || defined(TPF) || defined(NETWARE))) - " (default)" -#endif "." NL); apr_file_printf(errfile, " -p Do not encrypt the password (plaintext)." NL); apr_file_printf(errfile, " -s Force SHA encryption of the password." NL); @@ -258,10 +270,11 @@ static void usage(void) "rather than prompting for it." NL); apr_file_printf(errfile, " -D Delete the specified user." NL); apr_file_printf(errfile, - "On Windows, NetWare and TPF systems the '-m' flag is used by " - "default." NL); + "On other systems than Windows, NetWare and TPF the '-p' flag will " + "probably not work." NL); apr_file_printf(errfile, - "On all other systems, the '-p' flag will probably not work." NL); + "The SHA algorithm does not use a salt and is less secure than " + "the MD5 algorithm." NL); exit(ERR_SYNTAX); } @@ -428,7 +441,7 @@ int main(int argc, const char * const argv[]) char *scratch, cp[MAX_STRING_LEN]; int found = 0; int i; - int alg = ALG_CRYPT; + int alg = ALG_APMD5; int mask = 0; apr_pool_t *pool; int existing_file = 0;