Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Sep 1998 09:42:45 +0200
From:      Andreas Klemm <andreas@klemm.gtn.com>
To:        "Vladimir B. Grebenschikov" <vova@plugcom.ru>, stefan@asterix.webaffairs.net
Cc:        ports@FreeBSD.ORG, ibex@physik.TU-Berlin.DE
Subject:   Re: FreeBSD Port: apache-php3.0.3-1.3.0
Message-ID:  <19980912094245.A29717@klemm.gtn.com>
In-Reply-To: <35F95FEF.F6A7C7B5@plugcom.ru>; from Vladimir B. Grebenschikov on Fri, Sep 11, 1998 at 09:37:51PM %2B0400
References:  <35F95FEF.F6A7C7B5@plugcom.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi !

Dirk Froemberg is the new port maintainer.
I didn't look closely into this ... if we add this patch, does
it still work if installing FreeBSD with DES ?

On Fri, Sep 11, 1998 at 09:37:51PM +0400, Vladimir B. Grebenschikov wrote:
> 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

-- 
Andreas Klemm                                http://www.FreeBSD.ORG/~andreas
     What gives you 90% more speed, for example, in kernel compilation ?
          http://www.FreeBSD.ORG/~fsmp/SMP/akgraph-a/graph1.html
             "NT = Not Today" (Maggie Biggs)      ``powered by FreeBSD SMP''

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980912094245.A29717>