summaryrefslogtreecommitdiff
blob: 366e494d6ac081306900999a55e675099cbe955c (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
diff -ur gnome-system-tools-1.0.2/backends/parse.pl.in gnome-system-tools-1.0.2-patched/backends/parse.pl.in
--- gnome-system-tools-1.0.2/backends/parse.pl.in	2004-12-06 18:58:53.000000000 +0800
+++ gnome-system-tools-1.0.2-patched/backends/parse.pl.in	2004-12-19 11:18:06.247737712 +0800
@@ -398,6 +398,22 @@
   }
 
   return \@res;
+}	
+
+sub gst_parse_split_all_array_with_pos
+{
+  my ($file, $key, $pos, $re, $sep, $line_read_proc) = @_;
+  my ($arr, @s, @ret, $i);
+
+  $arr = &gst_parse_split_all ($file, $key, $re, $line_read_proc);
+
+  foreach $i (@$arr)
+  {
+    @s = split ($sep, $i);
+    push @ret, @s[0];
+  }
+  	 
+  return \@ret;
 }
 
 # Same, but for $all = 0. (ie nameserver 10.0.0.1)
diff -ur gnome-system-tools-1.0.2/backends/time-conf.in gnome-system-tools-1.0.2-patched/backends/time-conf.in
--- gnome-system-tools-1.0.2/backends/time-conf.in	2004-08-29 19:50:08.000000000 +0800
+++ gnome-system-tools-1.0.2-patched/backends/time-conf.in	2004-12-19 11:20:17.968713080 +0800
@@ -407,6 +407,73 @@
   return 0;
 }
 
+sub time_replace_ntp_servers
+{
+  my ($file, $key, $re, $value) = @_;
+  my ($fd, @line, @res);
+  my ($buff, $i);
+  my ($pre_space, $post_comment);
+  my ($line_key, $val, $rest);
+  my ($n, $ret);
+
+  &gst_report_enter ();
+  &gst_report ("replace_split", $key, $file);
+
+  $buff = &gst_file_buffer_load ($file);
+  
+  foreach $i (@$buff)
+  {
+    $pre_space = $post_comment = "";
+
+    chomp $i;
+
+    $pre_space    = $1 if $i =~ s/^([ \t]+)//;
+    $post_comment = $1 if $i =~ s/([ \t]*\#.*)//;
+    
+    if ($i ne "")
+    {
+      @line = split ($re, $i, 3);
+      $line_key = shift (@line);
+      $val      = shift (@line);
+      $rest     = shift (@line);
+
+      # found the key?
+      if ($line_key eq $key)
+      {
+        $n = 0;
+
+        while (@$value[$n] && (@$value[$n] ne $val))
+        {
+          $n++;
+        }
+
+        if (@$value[$n] ne $val)
+        {
+          $i = "";
+          next;
+        }
+
+        delete @$value[$n];
+        chomp $val;
+        $i  = &set_value ($key, $val, $re) . " " . $rest;
+      }
+    }
+
+    $i = $pre_space . $i . $post_comment . "\n";
+  }
+
+  foreach $i (@$value)
+  {
+#      print "$key  $i\n";
+    push (@$buff, &set_value ($key, $i, $re) . "\n") if ($i ne "");
+  }
+
+  &gst_file_buffer_clean ($buff);
+  $ret = &gst_file_buffer_save ($buff, $file);
+  &gst_report_leave ();
+  return $ret;
+}
+
 sub conf_set
 {
   my $values_hash = $_[0];
@@ -498,7 +565,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "xntpd" ],
               [ "ntpinstalled", \&gst_service_sysv_installed, "xntpd" ],
               ]
@@ -516,7 +583,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "ntpd" ],
               [ "ntpinstalled", \&gst_service_sysv_installed, "ntpd" ],
               ]
@@ -534,7 +601,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_first_array_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "ntpd" ],
               [ "ntpinstalled", \&gst_service_sysv_installed, "ntp" ],
               ]
@@ -552,7 +619,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "ntpd" ],
               [ "ntpinstalled", \&gst_service_list_any_installed, [ "ntp-simple", "ntp-refclock" ] ],
               ]
@@ -570,7 +637,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "xntpd" ],
               [ "ntpinstalled", \&gst_service_sysv_installed, "xntpd" ],
               ]
@@ -588,7 +655,7 @@
          [
           [ "local_time",   \&time_get_local_time ],
           [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-          [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
           [ "sync_active",  \&gst_service_get_status, "xntpd" ],
           [ "ntpinstalled", \&gst_service_installed,  "xntpd" ],
          ]
@@ -606,7 +673,7 @@
              [
               [ "local_time",   \&time_get_local_time ],
               [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-              [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_get_status, "ntpd" ],
               [ "ntpinstalled", \&gst_service_sysv_installed, "ntpd" ],
               ]
@@ -624,7 +691,7 @@
          [
           [ "local_time",   \&time_get_local_time ],
           [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-          [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
           [ "sync_active",  \&gst_service_gentoo_get_status, "ntpd" ],
           [ "ntpinstalled", \&gst_service_installed, "ntpd" ],
           ]
@@ -642,7 +709,7 @@
          [
           [ "local_time",   \&time_get_local_time ],
           [ "timezone",     \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
-          [ "sync",         \&gst_parse_split_all_hash_comment, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ],
           [ "sync_active",  \&gst_service_rcng_get_status, "ntpd" ],
           [ "ntpinstalled", \&gst_service_installed, "ntpd" ],
           ]
@@ -726,7 +793,7 @@
              [
               [ "timezone",    \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
               [ "local_time",  \&time_set_local_time ],
-              [ "sync",        \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",        \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
               [ "sync_active", \&gst_service_sysv_set_status, 90, "xntpd", "%sync_active%" ],
               ]
                 },
@@ -743,7 +810,7 @@
              [
               [ "timezone",     \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
               [ "local_time",   \&time_set_local_time ],
-              [ "sync",         \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_set_status, 90, "ntpd", "%sync_active%" ],
               ]
                 },
@@ -760,7 +827,7 @@
              [
               [ "timezone",    \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
               [ "local_time",  \&time_set_local_time ],
-              [ "sync",        \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",        \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
               [ "sync_active", \&gst_service_sysv_set_status, 23, "ntp", "%sync_active%" ],
               ]
                 },
@@ -777,7 +844,7 @@
              [
               [ "timezone",    \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
               [ "local_time",  \&time_set_local_time ],
-              [ "sync",        \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",        \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
               [ "sync_active", \&gst_service_sysv_set_status, 23, "ntp-simple", "%sync_active%" ],
               ]
                 },
@@ -794,7 +861,7 @@
              [
               [ "timezone",     \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
               [ "local_time",   \&time_set_local_time ],
-              [ "sync",         \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+              [ "sync",         \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
               [ "sync_active",  \&gst_service_sysv_set_status, 90, "xntpd", "%sync_active%" ],
               ]
                 },
@@ -811,7 +878,7 @@
          [
           [ "timezone",     \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
           [ "local_time",   \&time_set_local_time ],
-          [ "sync",         \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
           [ "sync_active",  \&gst_service_suse_set_status, "xntpd" ],
          ]
        },
@@ -844,7 +911,7 @@
          [
           [ "timezone",     \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
           [ "local_time",   \&time_set_local_time ],
-          [ "sync",         \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
           [ "sync_active",  \&gst_service_gentoo_set_status, "ntpd", 1, "%sync_active%" ],
           ]
         },
@@ -861,7 +928,7 @@
          [
           [ "timezone",     \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ],
           [ "local_time",   \&time_set_local_time ],
-          [ "sync",         \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ],
+          [ "sync",         \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ],
           [ "sync_active",  \&gst_service_rcng_set_status, "ntpd", "%sync_active%" ],
           ]
         },