diff --git a/timezone-2016g-absolute-TZDEFAULT.patch b/timezone-2016g-absolute-TZDEFAULT.patch new file mode 100644 index 0000000..3f808e8 --- /dev/null +++ b/timezone-2016g-absolute-TZDEFAULT.patch @@ -0,0 +1,107 @@ +From df9991a2186d4236ba1e97e6638fa53b578bc6d7 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Thu, 6 Oct 2016 11:47:17 -0700 +Subject: [PATCH] Do not assume TZDEFAULT is relative. + +Problem reported by Andreas Stieger in: +http://mm.icann.org/pipermail/tz/2016-October/024280.html +* NEWS: Document this. +* zic.c (relname): New function. +(dolink): Use it. +--- + zic.c | 65 ++++++++++++++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 44 insertions(+), 21 deletions(-) + +--- + +Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1003324 + +diff --git a/zic.c b/zic.c +index 2505c11..eba223c 100644 +--- a/zic.c ++++ b/zic.c +@@ -764,6 +764,44 @@ namecheck(const char *name) + return componentcheck(name, component, cp); + } + ++/* Create symlink contents suitable for symlinking FROM to TO, as a ++ freshly allocated string. FROM should be a relative file name, and ++ is relative to the global variable DIRECTORY. TO can be either ++ relative or absolute. */ ++static char * ++relname(char const *from, char const *to) ++{ ++ size_t i, taillen, dotdotetcsize; ++ size_t dir_len = 0, dotdots = 0, linksize = SIZE_MAX; ++ char const *f = from; ++ char *result = NULL; ++ if (*to == '/') { ++ /* Make F absolute too. */ ++ size_t len = strlen(directory); ++ bool needslash = len && directory[len - 1] != '/'; ++ linksize = len + needslash + strlen(from) + 1; ++ f = result = emalloc(linksize); ++ strcpy(result, directory); ++ result[len] = '/'; ++ strcpy(result + len + needslash, from); ++ } ++ for (i = 0; f[i] && f[i] == to[i]; i++) ++ if (f[i] == '/') ++ dir_len = i + 1; ++ for (; f[i]; i++) ++ dotdots += f[i] == '/' && f[i - 1] != '/'; ++ taillen = i - dir_len; ++ dotdotetcsize = 3 * dotdots + taillen + 1; ++ if (dotdotetcsize <= linksize) { ++ if (!result) ++ result = emalloc(dotdotetcsize); ++ for (i = 0; i < dotdots; i++) ++ memcpy(result + 3 * i, "../", 3); ++ memmove(result + 3 * dotdots, f + dir_len, taillen + 1); ++ } ++ return result; ++} ++ + static void + dolink(char const *fromfield, char const *tofield, bool staysymlink) + { +@@ -800,30 +838,15 @@ dolink(char const *fromfield, char const *tofield, bool staysymlink) + link_errno = link(fromfield, tofield) == 0 ? 0 : errno; + } + if (link_errno != 0) { +- const char *s = fromfield; +- const char *t; +- char *p; +- size_t dotdots = 0; +- char *symlinkcontents; +- int symlink_errno; +- +- do +- t = s; +- while ((s = strchr(s, '/')) +- && strncmp(fromfield, tofield, ++s - fromfield) == 0); +- +- for (s = tofield + (t - fromfield); *s; s++) +- dotdots += *s == '/'; +- symlinkcontents = emalloc(3 * dotdots + strlen(t) + 1); +- for (p = symlinkcontents; dotdots-- != 0; p += 3) +- memcpy(p, "../", 3); +- strcpy(p, t); +- symlink_errno = symlink(symlinkcontents, tofield) == 0 ? 0 : errno; ++ bool absolute = *fromfield == '/'; ++ char *linkalloc = absolute ? NULL : relname(fromfield, tofield); ++ char const *contents = absolute ? fromfield : linkalloc; ++ int symlink_errno = symlink(contents, tofield) == 0 ? 0 : errno; + if (symlink_errno == ENOENT && !todirs_made) { + mkdirs(tofield, true); +- symlink_errno = symlink(symlinkcontents, tofield) == 0 ? 0 : errno; ++ symlink_errno = symlink(contents, tofield) == 0 ? 0 : errno; + } +- free(symlinkcontents); ++ free(linkalloc); + if (symlink_errno == 0) { + if (link_errno != ENOTSUP) + warning(_("symbolic link used because hard link failed: %s"), +-- +2.10.1 + diff --git a/timezone-java.changes b/timezone-java.changes index dc38305..12f2d3c 100644 --- a/timezone-java.changes +++ b/timezone-java.changes @@ -1,5 +1,5 @@ ------------------------------------------------------------------- -Thu Oct 6 13:38:20 UTC 2016 - astieger@suse.com +Thu Oct 6 19:14:45 UTC 2016 - astieger@suse.com - timezone update 2016g: * Turkey will remain on UTC+03 after 2016-10-30 bsc#997830 @@ -26,8 +26,10 @@ Thu Oct 6 13:38:20 UTC 2016 - astieger@suse.com tzcode-revert-03-39fd078a6.patch tzcode-symlink.patch tzcode-zic.diff - + tzcode-fromname.patch was updated to continue ensure correct - path exansion, preventing bsc#1003324 + tzcode-fromname.patch + + Upstream changes did not account for TZDEFAULT being an + absolute path. Prevent broken symlinks (bsc#1003324), + add timezone-2016g-absolute-TZDEFAULT.patch * zdump has a new -i option to generate transitions in a more-compact but still human-readable format. (experimental) diff --git a/timezone-java.spec b/timezone-java.spec index be26b30..c602bb4 100644 --- a/timezone-java.spec +++ b/timezone-java.spec @@ -34,8 +34,8 @@ Source3: https://www.iana.org/time-zones/repository/releases/tzcode%{vers Source4: %{name}.keyring Source5: %{name}.changes Patch0: tzdata-china.diff -Patch2: tzcode-fromname.patch Patch3: iso3166-uk.diff +Patch4: timezone-2016g-absolute-TZDEFAULT.patch # COMMON-END # COMMON-END Url: http://www.gnu.org/software/libc/libc.html @@ -56,8 +56,8 @@ package is intended for Java Virtual Machine based on OpenJDK. # COMMON-PREP-BEGIN # COMMON-PREP-BEGIN %patch0 -p1 -%patch2 -p1 %patch3 -p1 +%patch4 -p1 sed -ri 's@/usr/local/etc/zoneinfo@%{_datadir}/zoneinfo@g' *.[1358] # COMMON-PREP-END # COMMON-PREP-END diff --git a/timezone.changes b/timezone.changes index dc38305..12f2d3c 100644 --- a/timezone.changes +++ b/timezone.changes @@ -1,5 +1,5 @@ ------------------------------------------------------------------- -Thu Oct 6 13:38:20 UTC 2016 - astieger@suse.com +Thu Oct 6 19:14:45 UTC 2016 - astieger@suse.com - timezone update 2016g: * Turkey will remain on UTC+03 after 2016-10-30 bsc#997830 @@ -26,8 +26,10 @@ Thu Oct 6 13:38:20 UTC 2016 - astieger@suse.com tzcode-revert-03-39fd078a6.patch tzcode-symlink.patch tzcode-zic.diff - + tzcode-fromname.patch was updated to continue ensure correct - path exansion, preventing bsc#1003324 + tzcode-fromname.patch + + Upstream changes did not account for TZDEFAULT being an + absolute path. Prevent broken symlinks (bsc#1003324), + add timezone-2016g-absolute-TZDEFAULT.patch * zdump has a new -i option to generate transitions in a more-compact but still human-readable format. (experimental) diff --git a/timezone.spec b/timezone.spec index 7ba0254..6616e92 100644 --- a/timezone.spec +++ b/timezone.spec @@ -32,8 +32,8 @@ Source3: https://www.iana.org/time-zones/repository/releases/tzcode%{vers Source4: %{name}.keyring Source5: %{name}.changes Patch0: tzdata-china.diff -Patch2: tzcode-fromname.patch Patch3: iso3166-uk.diff +Patch4: timezone-2016g-absolute-TZDEFAULT.patch # COMMON-END BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -50,8 +50,8 @@ can select an appropriate time zone for your system with YaST. %setup -q -c -a 1 # COMMON-PREP-BEGIN %patch0 -p1 -%patch2 -p1 %patch3 -p1 +%patch4 -p1 sed -ri 's@/usr/local/etc/zoneinfo@%{_datadir}/zoneinfo@g' *.[1358] # COMMON-PREP-END diff --git a/tzcode-fromname.patch b/tzcode-fromname.patch deleted file mode 100644 index 31eddd5..0000000 --- a/tzcode-fromname.patch +++ /dev/null @@ -1,70 +0,0 @@ -From: Andreas Stieger -Date: Thu, 06 Oct 2016 13:26:04 +0000 -References: bsc#845530 bsc#1003324 - -This patch ensures correct path expansion for the local time zone link. - -The 2016g release re-worked much of the code, however the problem -with broken symlinks remain. - -Brought up on mailing list: -http://mm.icann.org/pipermail/tz/2016-October/024280.html - -Index: timezone-2016g/zic.c -=================================================================== ---- timezone-2016g.orig/zic.c 2016-09-06 04:39:50.000000000 +0000 -+++ timezone-2016g/zic.c 2016-10-06 13:18:13.752297564 +0000 -@@ -764,12 +764,32 @@ namecheck(const char *name) - return componentcheck(name, component, cp); - } - -+static char * -+relname(char const *dir, char const *base) -+{ -+ if (*base == '/') -+ return ecpyalloc(base); -+ else { -+ size_t dir_len = strlen(dir); -+ bool needs_slash = dir_len && dir[dir_len - 1] != '/'; -+ char *result = emalloc(dir_len + needs_slash + strlen(base) + 1); -+ result[dir_len] = '/'; -+ strcpy(result + dir_len + needs_slash, base); -+ return memcpy(result, dir, dir_len); -+ } -+} -+ - static void - dolink(char const *fromfield, char const *tofield, bool staysymlink) - { - register int fromisdir; - bool todirs_made = false; - int link_errno; -+ register char * fromname; -+ register char * toname; -+ -+ fromname = relname(directory, fromfield); -+ toname = relname(directory, tofield); - - /* - ** We get to be careful here since -@@ -800,7 +820,7 @@ dolink(char const *fromfield, char const - link_errno = link(fromfield, tofield) == 0 ? 0 : errno; - } - if (link_errno != 0) { -- const char *s = fromfield; -+ const char *s = fromname; - const char *t; - char *p; - size_t dotdots = 0; -@@ -810,9 +830,9 @@ dolink(char const *fromfield, char const - do - t = s; - while ((s = strchr(s, '/')) -- && strncmp(fromfield, tofield, ++s - fromfield) == 0); -+ && strncmp(fromname, tofield, ++s - fromname) == 0); - -- for (s = tofield + (t - fromfield); *s; s++) -+ for (s = tofield + (t - fromname); *s; s++) - dotdots += *s == '/'; - symlinkcontents = emalloc(3 * dotdots + strlen(t) + 1); - for (p = symlinkcontents; dotdots-- != 0; p += 3)