Date: Wed, 16 Feb 2000 00:05:26 +0100 (CET) From: Karl.Dietz@frankfurt.netsurf.de To: FreeBSD-gnats-submit@freebsd.org Subject: ports/16736: fix: web500gw can't always parse dates (Y2K) Message-ID: <200002152305.AAA62263@frankfurt.netsurf.de>
next in thread | raw e-mail | index | archive | help
>Number: 16736 >Category: ports >Synopsis: fix: web500gw can't always parse dates (Y2K) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 15 16:00:02 PST 2000 >Closed-Date: >Last-Modified: >Originator: Karl Dietz >Release: FreeBSD 3.3-STABLE i386 >Organization: >Environment: >Description: initial mail from Jim Dutton: I believe that I have found the problem with Web500gw and its inability to properly display 4-digit years. UMich LDAP-3.3 uses 2-digit years whereas OpenLDAP and Netscape Directory Server use 4-digit years. The attached diff file corrects util.c for an LDAP server using 4-digit-year timestamps. While the comments are directed at OpenLDAP, they also apply to Netscape and any other 4-digit-year LDAP server. The display of dates now works properly. Please note, however, that I have NOT fully tested database updates with the util.c changes in place. I will get to that shortly, but believe that the date format changes will not affect anything since all OpenLDAP/Netscape DS timestamps use 4-digit-years. Nevertheless, the attached "util.c.diffs" context diff file provides the simple changes to allow Web500gw to properly display 4-digit-years instead of showing ALL 4-digit-years as "1969". Also included at the top of the diff file were some includes needed for FreeBSD, which may or may not already be in the FBSD port, patches files. I also sent a copy of the diff file off to Frank Richter. P.S. A proper "patch" should include a test for LDAP server "brandname" so anyone still using UMich LPAP-3.3 WON'T apply these changes, and thereby cause themselves problems (I wonder where those two extra bytes would come from - hmmmmm?). ---- cut me ---- The patch has then been reworked to accept both types of dates which makes it independet of the LDAP server it talks to. Jim told me later that: It has been successfully tested on the following: - UMich LDAP-3.3, "2000" timestamps (as "00mmdd.....") - OpenLDAP-1.2.7, "1999" timestamps (as "1999mmdd...") - OpenLDAP-1.2.7, "2000" timestamps (as "2000mmdd...") ----- end of excerpt ----- Y2K patch by: Jum Dutton <jimd@dutton3.it.siu.edu> torturing Jim to make the patch accept both type of dates: me aka port maintainer two small patches: the authors website >How-To-Repeat: Use web500gw to display LDAP-Attributes containing dates. >Fix: apply this patch ---- cut ---- Index: Makefile =================================================================== RCS file: /home/ncvs/ports/www/web500gw/Makefile,v retrieving revision 1.8 diff -u -r1.8 Makefile --- Makefile 1999/11/26 15:30:25 1.8 +++ Makefile 2000/01/19 22:40:26 @@ -13,6 +13,9 @@ ftp://ftp.ntua.gr/pub/net/ldap/web500gw/ \ ftp://ftp.imms.de/pub/unix/networking/ldap/ +PATCH_SITES= http://www.tu-chemnitz.de/~fri/web500gw/ +PATCHFILES= modtmpl.patch + MAINTAINER= Karl.Dietz@frankfurt.netsurf.de BUILD_DEPENDS= ${LOCALBASE}/lib/libldap.a:${PORTSDIR}/net/openldap Index: files/md5 =================================================================== RCS file: /home/ncvs/ports/www/web500gw/files/md5,v retrieving revision 1.2 diff -u -r1.2 md5 --- md5 1999/09/21 22:37:12 1.2 +++ md5 2000/01/19 22:47:13 @@ -1 +1,2 @@ MD5 (web500gw-2.1b3.tar.gz) = 8e411a94f79bad75a3e8deeea3d05050 +MD5 (modtmpl.patch) = 08cd0570c25646085946bb246fb56525 Index: patches/patch-ab =================================================================== RCS file: patch-ab diff -N patch-ab --- /dev/null Wed Jan 19 23:54:17 2000 +++ patch-ab Wed Jan 19 23:44:03 2000 @@ -0,0 +1,11 @@ +--- etc/web500gw.messages.orig Wed Jan 19 23:42:06 2000 ++++ etc/web500gw.messages Wed Jan 19 23:42:29 2000 +@@ -546,7 +546,7 @@ + ## %1 = URL to read, %2 = URL to modify, %3 = bind-dn, %4 = passwd + # Add ok + # %1 = RDN, %2 = UFN, %3 = URL z. Lesen +-:ADD_OK The entry <STRONG><A HREF=""%3">%2</A></STRONG><BR> ++:ADD_OK The entry <STRONG><A HREF="%3">%2</A></STRONG><BR> + was <STRONG>added</STRONG> successfully! + + ##################### Delete entry Index: patches/patch-ac =================================================================== RCS file: patch-ac diff -N patch-ac --- /dev/null Wed Jan 19 23:54:17 2000 +++ patch-ac Wed Jan 19 23:28:01 2000 @@ -0,0 +1,154 @@ +*** util.c.orig Thu Dec 2 18:07:10 1999 +--- util.c Mon Jan 17 23:23:51 2000 +*************** +*** 14,20 **** + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ +! + #include "web500gw.h" + + /* msg_?printf: formats (and prints out) a string contained in message file */ +--- 14,21 ---- + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ +! #include <unistd.h> +! #include <gnuregex.h> + #include "web500gw.h" + + /* msg_?printf: formats (and prints out) a string contained in message file */ +*************** +*** 437,443 **** + hour = 0; + mday++; + } +! year = YEAR (tm -> tm_year); + result = 0L; + for (i = 1970; i < year; i++) + result += dysize (i); +--- 438,444 ---- + hour = 0; + mday++; + } +! year = (tm -> tm_year); + result = 0L; + for (i = 1970; i < year; i++) + result += dysize (i); +*************** +*** 454,460 **** + + + /* returns a printable date string from LDAP's date format: +! * s should point to: YYMMDDHHmmSSZ + * format format string for strftime(3) + */ + char * +--- 455,461 ---- + + + /* returns a printable date string from LDAP's date format: +! * s should point to: YYYYMMDDHHmmSSZ + * format format string for strftime(3) + */ + char * +*************** +*** 473,487 **** + if (!s) + return(NULL); + +! /* s should point to: YYMMDDHHmmSSZ */ +! /* ... well 2 digits for year :-( */ +! +! tm.tm_year = 10*(s[0] - '0') + (s[1] - '0'); +! tm.tm_mon = 10*(s[2] - '0') + (s[3] - '0') - 1; +! tm.tm_mday = 10*(s[4] - '0') + (s[5] - '0'); +! tm.tm_hour = 10*(s[6] - '0') + (s[7] - '0'); +! tm.tm_min = 10*(s[8] - '0') + (s[9] - '0'); +! tm.tm_sec = 10*(s[10] - '0') + (s[11] - '0'); + tm.tm_isdst = 0; + + #if ! (defined(__hpux) || defined(_AIX) || defined(sunos5) || defined(linux) || defined(unixware7)) +--- 474,487 ---- + if (!s) + return(NULL); + +! /* s should point to: YYYYMMDDHHmmSSZ for OpenLDAP */ +! /* this change will probably cause problems for UMich LDAP-3.3 use */ +! tm.tm_year = 1000*(s[0] - '0') + 100*(s[1] - '0') + 10*(s[2] - '0') + (s[3] - '0'); +! tm.tm_mon = 10*(s[4] - '0') + (s[5] - '0') - 1; +! tm.tm_mday = 10*(s[6] - '0') + (s[7] - '0'); +! tm.tm_hour = 10*(s[8] - '0') + (s[9] - '0'); +! tm.tm_min = 10*(s[10] - '0') + (s[11] - '0'); +! tm.tm_sec = 10*(s[12] - '0') + (s[13] - '0'); + tm.tm_isdst = 0; + + #if ! (defined(__hpux) || defined(_AIX) || defined(sunos5) || defined(linux) || defined(unixware7)) +*************** +*** 512,518 **** + } + + /* compares 2 dates: +! * ldap_date should point to: YYMMDDHHmmSSZ + * http_date is a HTTP date (3 different formats ...) + * returns 1,0,-1 if first date is newer, equal, older to second + */ +--- 512,518 ---- + } + + /* compares 2 dates: +! * ldap_date should point to: YYYYMMDDHHmmSSZ + * http_date is a HTTP date (3 different formats ...) + * returns 1,0,-1 if first date is newer, equal, older to second + */ +*************** +*** 552,560 **** +--- 552,562 ---- + /* RFC 850: dd-Mmm-yy hh:mm:ss */ + sscanf(http_date, "%d-%3s-%d %d:%d:%d", + &day, month_name, &year, &hour, &min, &sec); ++ /* OpenLDAP uses and records 4 digit years - following code not needed + if (year < 70) + year += 100; + year += 1900; ++ */ + } else { /* normal HTTP date (RFC 822/1123): dd Mmm yyyy hh:mm:ss */ + sscanf(http_date, "%d %s %d %d:%d:%d", + &day, month_name, &year, &hour, &min, &sec); +*************** +*** 568,584 **** + day, month, year, 0); + Web500gw_debug(WEB500GW_DEBUG_UTIL, "%d:%d:%d\n", hour, min, sec, 0); + #endif +! if ((i = ((10*(ldap_date[0] - '0') + (ldap_date[1] - '0') + 1900) - year))) + return i > 0; +! if ((i = ((10*(ldap_date[2] - '0') + (ldap_date[3] - '0')) - month))) + return i > 0; +! if ((i = ((10*(ldap_date[4] - '0') + (ldap_date[5] - '0')) - day))) + return i > 0; +! if ((i = ((10*(ldap_date[6] - '0') + (ldap_date[7] - '0')) - hour))) + return i > 0; +! if ((i = ((10*(ldap_date[8] - '0') + (ldap_date[9] - '0')) - min))) + return i > 0; +! if ((i = ((10*(ldap_date[10] - '0') + (ldap_date[11] - '0')) - sec))) + return i > 0; + + /* gone so far - dates are identical */ +--- 570,586 ---- + day, month, year, 0); + Web500gw_debug(WEB500GW_DEBUG_UTIL, "%d:%d:%d\n", hour, min, sec, 0); + #endif +! if ((i = (1000*(ldap_date[0] -'0') + 100*(ldap_date[1] - '0') + (10*(ldap_date[2] - '0') + (ldap_date[3] - '0')) - year))) + return i > 0; +! if ((i = ((10*(ldap_date[4] - '0') + (ldap_date[5] - '0')) - month))) + return i > 0; +! if ((i = ((10*(ldap_date[6] - '0') + (ldap_date[7] - '0')) - day))) + return i > 0; +! if ((i = ((10*(ldap_date[8] - '0') + (ldap_date[9] - '0')) - hour))) + return i > 0; +! if ((i = ((10*(ldap_date[10] - '0') + (ldap_date[11] - '0')) - min))) + return i > 0; +! if ((i = ((10*(ldap_date[12] - '0') + (ldap_date[13] - '0')) - sec))) + return i > 0; + + /* gone so far - dates are identical */ >Release-Note: >Audit-Trail: >Unformatted: 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?200002152305.AAA62263>