From owner-freebsd-ports Fri Sep 11 10:38:37 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA03110 for freebsd-ports-outgoing; Fri, 11 Sep 1998 10:38:37 -0700 (PDT) (envelope-from owner-freebsd-ports@FreeBSD.ORG) Received: from plugcom.ru (radiance.plugcom.ru [195.2.73.7]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA03034 for ; Fri, 11 Sep 1998 10:38:16 -0700 (PDT) (envelope-from vova@plugcom.ru) Received: from plugcom.ru (vova@radiance.plugcom.ru [195.2.73.7]) by plugcom.ru (8.8.7/8.8.6) with ESMTP id VAA04896; Fri, 11 Sep 1998 21:37:52 +0400 (MSD) Message-ID: <35F95FEF.F6A7C7B5@plugcom.ru> Date: Fri, 11 Sep 1998 21:37:51 +0400 From: "Vladimir B. Grebenschikov" Organization: Plug Communication X-Mailer: Mozilla 4.06 [en] (X11; I; FreeBSD 2.2-110597 i386) MIME-Version: 1.0 To: stefan@asterix.webaffairs.net CC: ports@FreeBSD.ORG Subject: FreeBSD Port: apache-php3.0.3-1.3.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org php function CRYPT() need patch for propertly work with FreeBSD MD5 passwords: --- php-3.0.3.orig/functions/crypt.c Fri Sep 11 21:28:00 1998 +++ php-3.0.3.orig/functions/crypt.c Fri Sep 11 20:55:25 1998 @@ -66,9 +66,30 @@ "Crypt", crypt_functions, NULL, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES }; +#ifdef __FreeBSD__ +static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +void +to64(s, v, n) + char *s; + long v; + int n; +{ + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } +} +#endif + void php3_crypt(INTERNAL_FUNCTION_PARAMETERS) { +#ifdef __FreeBSD__ + char salt[10]; +#else char salt[4]; +#endif int arg_count = ARG_COUNT(ht); pval *arg1, *arg2; static char seedchars[] = @@ -83,14 +104,39 @@ salt[0] = '\0'; if (arg_count == 2) { convert_to_string(arg2); +#ifdef __FreeBSD__ + strncpy(salt, arg2->value.str.val, 9); +#else strncpy(salt, arg2->value.str.val, 2); +#endif } if (!salt[0]) { +#ifdef __FreeBSD__ +# ifdef NEWSALT + salt[0] = '_'; + (void)srandom((int)time((time_t *)NULL)); + to64(&salt[1], random(), 4); + to64(&salt[5], random(), 4); +# else + struct timeval tv; + gettimeofday(&tv,0); + /* MD5 Salt */ + strncpy(&salt[0], "$1$", 3); + to64(&salt[3], random(), 3); + to64(&salt[6], tv.tv_usec, 3); + salt[8] = '\0'; +#endif +#else srand(time(0) * getpid()); salt[0] = seedchars[rand() % 64]; salt[1] = seedchars[rand() % 64]; +#endif } +#ifdef __FreeBSD__ + salt[9] = '\0'; +#else salt[2] = '\0'; +#endif return_value->value.str.val = (char *) crypt(arg1->value.str.val, salt); return_value->value.str.len = strlen(return_value->value.str.val); /* can be optimized away to 13? */ -- Plug Communication ISP, Moscow Vladimir B. Grebenschikov, vova@plugcom.ru, 2:5020/302@fidonet.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message