y2k-dst
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
y2k-dst [2018/08/30 22:24] – external edit 127.0.0.1 | y2k-dst [2022/03/19 17:32] (current) – added setclk patch info and link to original a.org thread wiki_admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Y2K ====== | + | ===== Amix & Y2K ===== |
- | (TODO) | + | The built-in setclk |
- | ====== | + | A patched version can be downloaded [[http:// |
+ | |||
+ | The discussion that led to the patched setclk utility is presented below. Thanks to Failure, Piru and a_petri [[https:// | ||
+ | |||
+ | Piru: | ||
+ | |||
+ | > The bug was in sscanf() using %02d for the year. The year is 3 digits with years 2000++ so only first two first digits were parsed (year ended up 10 instead of 106). Also various buffers had to be extended to accommodate the extra char so no buffer overflow will occur. | ||
+ | > | ||
+ | > However, if date can't grock it (which might well be the case), / | ||
+ | > | ||
+ | > If you find the patch above useful please feel free to use it as you wish. I hereby place it in public domain. | ||
+ | > | ||
+ | > Now assuming / | ||
+ | |||
+ | < | ||
+ | |||
+ | --- setclk.c-orig Sat Feb 11 02:48:57 2006 | ||
+ | +++ setclk.c Sat Feb 11 10:41:14 2006 | ||
+ | @@ -51,7 +51,7 @@ | ||
+ | |||
+ | if (!strcmp(*argv, | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | |||
+ | retval | ||
+ | |||
+ | @@ -80,7 +80,7 @@ | ||
+ | if (argc == 1) | ||
+ | { | ||
+ | time_t thetime | ||
+ | - char buffer[BUFSIZ*2], | ||
+ | + char buffer[BUFSIZ*2], | ||
+ | |||
+ | /* | ||
+ | ** Set the system time to what the hardware thinks is correct. | ||
+ | @@ -138,7 +138,7 @@ | ||
+ | |||
+ | if (set_clock) | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | struct tm *tm; | ||
+ | time_t thetime; | ||
+ | |||
+ | @@ -175,7 +175,7 @@ | ||
+ | |||
+ | if (display_clock) | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | |||
+ | retval = read_clock(buffer); | ||
+ | |||
+ | @@ -299,7 +299,7 @@ | ||
+ | return FALSE; | ||
+ | } | ||
+ | |||
+ | - if (sscanf(buffer, | ||
+ | + if (sscanf(buffer, | ||
+ | & | ||
+ | { | ||
+ | (void) fprintf(stderr, | ||
+ | </ | ||
+ | |||
+ | a_petri: | ||
+ | |||
+ | > I have stumbled to this topic accidentally, | ||
+ | > | ||
+ | > I investigated the problem, and I found some interesting facts: | ||
+ | > | ||
+ | > - The setclk command is able to handle the " | ||
+ | > | ||
+ | > - The date command is able to handle the four-digit year format, but not the three-digit format. | ||
+ | > | ||
+ | > - The two commands call each other in a tricky way: setclk without arguments call date with an argument decoded from reading the RTC, and date with a single date argument calls setclk with the -s argument. | ||
+ | > | ||
+ | > Therefore I tried to modify the argument passed to the date command in setclk.c to the four-digit year format. | ||
+ | > | ||
+ | > My patch is the following (against Piru's version published here). With this patch, the compiled setclk binary seems to work correctly with both pre-Y2K and post-Y2K dates. | ||
+ | |||
+ | < | ||
+ | *** setclk.c.piru | ||
+ | --- setclk.c | ||
+ | ************** | ||
+ | *** 81,87 **** | ||
+ | --- 81,87 ---- | ||
+ | if (argc == 1) | ||
+ | { | ||
+ | time_t thetime = read_from_clock_device(); | ||
+ | - char buffer[BUFSIZ*2], | ||
+ | + char buffer[BUFSIZ*2], | ||
+ | |||
+ | /* | ||
+ | ** Set the system time to what the hardware thinks is correct. | ||
+ | *************** | ||
+ | *** 96,101 **** | ||
+ | --- 96,109 ---- | ||
+ | } | ||
+ | |||
+ | convert_time(thetime, | ||
+ | + if (tmpbuf[8] == ' | ||
+ | + { | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + } | ||
+ | sprintf(buffer, | ||
+ | system(buffer); | ||
+ | </ | ||
+ | |||
+ | ===== 2007 DST changes | ||
There' | There' | ||
Line 11: | Line 124: | ||
Go here: | Go here: | ||
+ | < | ||
ftp:// | ftp:// | ||
cd /pub | cd /pub | ||
get tzdata2007b.tar.gz | get tzdata2007b.tar.gz | ||
bye | bye | ||
+ | </ | ||
Next, open up two shell sessions on the box. At the command prompt: | Next, open up two shell sessions on the box. At the command prompt: | ||
+ | < | ||
mkdir tzdata && cd tzdata | mkdir tzdata && cd tzdata | ||
gzip -dc ../ | gzip -dc ../ | ||
vi northamerica | vi northamerica | ||
+ | </ | ||
In the other window, head over to the TZ data, located in / | In the other window, head over to the TZ data, located in / | ||
+ | < | ||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S | # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S | ||
Rule US 1969 max - Oct lastSun 2:00 0 S | Rule US 1969 max - Oct lastSun 2:00 0 S | ||
+ | </ | ||
And delete every Rule US line in there. If you're using vi just type d6d. Replace it with the longer Rule US section (near the top after many lines of comments) from the tzdata/ | And delete every Rule US line in there. If you're using vi just type d6d. Replace it with the longer Rule US section (near the top after many lines of comments) from the tzdata/ | ||
- | Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace | + | < |
AMIX doesn' | AMIX doesn' | ||
- | zic -d . northamerica | + | < |
You're all set. If you want to put the output files elsewhere, create a directory and change the . argument to that directory. Happy SysVR4 in 2007 and beyond! | You're all set. If you want to put the output files elsewhere, create a directory and change the . argument to that directory. Happy SysVR4 in 2007 and beyond! |
y2k-dst.1535660650.txt.gz · Last modified: 2021/09/19 17:59 (external edit)