summaryrefslogtreecommitdiff
blob: 1c6ed0fe50e6332fadbf1af9ee1f5f1a48cb270e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc	2013-05-07 11:05:09 +0000
+++ b/sql/tztime.cc	2013-11-13 15:16:35 +0000
@@ -2494,7 +2494,7 @@
 
 */
 my_bool
-scan_tz_dir(char * name_end)
+scan_tz_dir(char * name_end, uint symlink_recursion_level)
 {
   MY_DIR *cur_dir;
   char *name_end_tmp;
@@ -2514,7 +2514,32 @@
 
       if (MY_S_ISDIR(cur_dir->dir_entry[i].mystat->st_mode))
       {
-        if (scan_tz_dir(name_end_tmp))
+        my_bool is_symlink;
+        if ((is_symlink= my_is_symlink(fullname, NULL)) &&
+            symlink_recursion_level > 0)
+        {
+          /*
+            The timezone definition data in some Linux distributions
+             (e.g. the "timezone-data-2013f" package in Gentoo)
+            may have synlimks like:
+              /usr/share/zoneinfo/posix/ -> /usr/share/zoneinfo/,
+            so the same timezone files are available under two names
+            (e.g. "CET" and "posix/CET").
+
+            We allow one level of symlink recursion for backward
+            compatibility with earlier timezone data packages that have
+            duplicate copies of the same timezone files inside the root
+            directory and the "posix" subdirectory (instead of symlinking).
+            This makes "posix/CET" still available, but helps to avoid
+            following such symlinks infinitely:
+              /usr/share/zoneinfo/posix/posix/posix/.../posix/
+          */
+          fflush(stdout);
+          fprintf(stderr, "Warning: Skipping directory '%s': "
+                          "to avoid infinite symlink recursion.\n", fullname);
+          continue;
+        }
+        if (scan_tz_dir(name_end_tmp, symlink_recursion_level + is_symlink))
         {
           my_dirend(cur_dir);
           return 1;
@@ -2526,14 +2551,20 @@
         if (!tz_load(fullname, &tz_info, &tz_storage))
           print_tz_as_sql(root_name_end + 1, &tz_info);
         else
+        {
+          fflush(stdout);
           fprintf(stderr,
                   "Warning: Unable to load '%s' as time zone. Skipping it.\n",
                   fullname);
+        }
         free_root(&tz_storage, MYF(0));
       }
       else
+      {
+        fflush(stdout);
         fprintf(stderr, "Warning: '%s' is not regular file or directory\n",
                 fullname);
+      }
     }
   }
 
@@ -2566,8 +2597,9 @@
     printf("TRUNCATE TABLE time_zone_transition;\n");
     printf("TRUNCATE TABLE time_zone_transition_type;\n");
 
-    if (scan_tz_dir(root_name_end))
+    if (scan_tz_dir(root_name_end, 0))
     {
+      fflush(stdout);
       fprintf(stderr, "There were fatal errors during processing "
                       "of zoneinfo directory\n");
       return 1;
@@ -2586,6 +2618,7 @@
     {
       if (tz_load(argv[2], &tz_info, &tz_storage))
       {
+        fflush(stdout);
         fprintf(stderr, "Problems with zoneinfo file '%s'\n", argv[2]);
         return 1;
       }
@@ -2595,6 +2628,7 @@
     {
       if (tz_load(argv[1], &tz_info, &tz_storage))
       {
+        fflush(stdout);
         fprintf(stderr, "Problems with zoneinfo file '%s'\n", argv[2]);
         return 1;
       }
@@ -2604,6 +2638,7 @@
     free_root(&tz_storage, MYF(0));
   }
 
+  my_end(0);
   return 0;
 }