From lomew@marker.cs.utah.edu  Mon Jan 26 13:18:44 1998
Received: from marker.cs.utah.edu (marker.cs.utah.edu [155.99.212.61])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA00378
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Jan 1998 13:18:43 -0800 (PST)
          (envelope-from lomew@marker.cs.utah.edu)
Received: (from lomew@localhost)
	by marker.cs.utah.edu (8.8.8/8.8.5) id OAA04902;
	Mon, 26 Jan 1998 14:18:36 -0700 (MST)
Message-Id: <199801262118.OAA04902@marker.cs.utah.edu>
Date: Mon, 26 Jan 1998 14:18:36 -0700 (MST)
From: Bart Robinson <lomew@marker.cs.utah.edu>
Reply-To: lomew@marker.cs.utah.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: bootpd gets timezone incorrectly
X-Send-Pr-Version: 3.2

>Number:         5574
>Category:       misc
>Synopsis:       bootpd gets timezone incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dirk
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 26 13:20:00 PST 1998
>Closed-Date:    Fri Nov 10 04:21:19 PST 2000
>Last-Modified:  Fri Nov 10 04:21:59 PST 2000
>Originator:     Bart Robinson
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
Utah Flux Project
>Environment:

We're using FreeBSD 2.2.5-STABLE i386 but FreeBSD-current suffers from the
same problem.

>Description:

BOOTP has a facility for clients to be told the time offset when the
"to" key in the bootptab file is set to "auto".  However, bootpd was
getting this info from gettimeofday, which no longer supplies a valid
timezone.

>How-To-Repeat:

Set the "to" key to "auto" in the bootptab.  The clients get a zero offset.

>Fix:
	
Here is a patch to /usr/src/libexec/bootpd/tzone.c to make it simply
use the tm_gmtoff from struct tm.

This patch is valid for FreeBSD-current as well as 2.2.5-STABLE.

Index: tzone.c
===================================================================
RCS file: /n/marker/usr/lsrc/FreeBSD/CVS/src/libexec/bootpd/tzone.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 tzone.c
--- tzone.c	1994-09-29 23:45:06-06	1.1.1.1
+++ tzone.c	1998-01-26 14:06:12-07
@@ -4,18 +4,9 @@
  * This is shared by bootpd and bootpef
  */
 
-#ifdef	SVR4
-/* XXX - Is this really SunOS specific? -gwr */
-/* This is in <time.h> but only visible if (__STDC__ == 1). */
-extern long timezone;
-#else /* SVR4 */
-/* BSD or SunOS */
-# include <sys/time.h>
-# include <syslog.h>
-#endif /* SVR4 */
+#include <time.h>
 
 #include "bptypes.h"
-#include "report.h"
 #include "tzone.h"
 
 /* This is what other modules use. */
@@ -28,17 +19,10 @@
 void
 tzone_init()
 {
-#ifdef	SVR4
-	/* XXX - Is this really SunOS specific? -gwr */
-	secondswest = timezone;
-#else /* SVR4 */
-	struct timezone tzp;		/* Time zone offset for clients */
-	struct timeval tp;			/* Time (extra baggage) */
-	if (gettimeofday(&tp, &tzp) < 0) {
-		secondswest = 0;		/* Assume GMT for lack of anything better */
-		report(LOG_ERR, "gettimeofday: %s", get_errmsg());
-	} else {
-		secondswest = 60L * tzp.tz_minuteswest;	/* Convert to seconds */
-	}
-#endif /* SVR4 */
+	struct tm *tm;
+	time_t now;
+
+	now = time(0);
+	tm = localtime(&now);
+	secondswest = -tm->tm_gmtoff;
 }
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dirk 
Responsible-Changed-By: dirk 
Responsible-Changed-When: Thu Nov 9 02:56:29 PST 2000 
Responsible-Changed-Why:  
I'll handle this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5574 
State-Changed-From-To: open->closed 
State-Changed-By: dirk 
State-Changed-When: Fri Nov 10 04:21:19 PST 2000 
State-Changed-Why:  
Patch committed. Well spotted. Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5574 
>Unformatted:
