Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Jan 1998 14:18:36 -0700 (MST)
From:      Bart Robinson <lomew@marker.cs.utah.edu>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   misc/5574: bootpd gets timezone incorrectly
Message-ID:  <199801262118.OAA04902@marker.cs.utah.edu>

next in thread | raw e-mail | index | archive | help

>Number:         5574
>Category:       misc
>Synopsis:       bootpd gets timezone incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 26 13:20:00 PST 1998
>Last-Modified:
>Originator:     Bart Robinson
>Organization:
Utah Flux Project
>Release:        FreeBSD 2.2.5-STABLE i386
>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;
 }
>Audit-Trail:
>Unformatted:



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