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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
|
From 6fe0413366fc02ba3ffdd24db670852bc134110f Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw@redhat.com>
Date: Fri, 17 Dec 2010 09:22:11 -0600
Subject: [PATCH 1/8] policy: stop touching /etc/hosts
Handling of /etc/hosts is highly site- and admin- specific in
many more complex cases, and it's exceedingly hard and error-
prone for NetworkManager to handle all those cases. So remove
this functionality entirely. That's not a big loss, as it
turns out there's a much more elegant solution.
The only requirement is that the machine's hostname map back
to an IP address owned by the machine. That requirement can
be satisifed by nss-myhostname or even possibly the distro's
installer. If the user does not want nss-myhostname then it
can be uninstalled. Distros should use a "recommends" feature
in their packaging system so that the NetworkManager package
does *not* have a hard requirement on nss-myhostname. Thus
everyone is happy; things Just Work when nss-myhostname is
installed, but more advanced users can uninstall it and
customize /etc/hosts as they wish.
Another alternative is a dispatcher script that listents for
the 'hostname' event, and updates /etc/hosts according to the
administrator's preference.
---
src/main.c | 4 +
src/nm-policy-hostname.c | 56 +---
src/nm-policy-hostname.h | 5 +-
src/nm-policy-hosts.c | 520 ++--------------------------
src/nm-policy-hosts.h | 20 +-
src/nm-policy.c | 42 +---
src/tests/test-policy-hosts.c | 761 ++---------------------------------------
7 files changed, 76 insertions(+), 1332 deletions(-)
diff --git a/src/main.c b/src/main.c
index 7e75f05..2db7345 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,7 @@
#include "nm-netlink-monitor.h"
#include "nm-vpn-manager.h"
#include "nm-logging.h"
+#include "nm-policy-hosts.h"
#if !defined(NM_DIST_VERSION)
# define NM_DIST_VERSION VERSION
@@ -713,6 +714,9 @@ main (int argc, char *argv[])
goto done;
}
+ /* Clean leftover "# Added by NetworkManager" entries from /etc/hosts */
+ nm_policy_hosts_clean_etc_hosts ();
+
nm_manager_start (manager);
/* Bring up the loopback interface. */
diff --git a/src/nm-policy-hostname.c b/src/nm-policy-hostname.c
index 42a2e0f..4fe69c5 100644
--- a/src/nm-policy-hostname.c
+++ b/src/nm-policy-hostname.c
@@ -30,7 +30,6 @@
#include "nm-logging.h"
#include "nm-policy-hostname.h"
-#include "nm-policy-hosts.h"
/************************************************************************/
@@ -206,74 +205,39 @@ hostname_thread_is_dead (HostnameThread *ht)
/************************************************************************/
#define FALLBACK_HOSTNAME4 "localhost.localdomain"
-#define FALLBACK_HOSTNAME6 "localhost6.localdomain6"
gboolean
-nm_policy_set_system_hostname (const char *new_hostname,
- const char *ip4_addr,
- const char *ip6_addr,
- const char *msg)
+nm_policy_set_system_hostname (const char *new_hostname, const char *msg)
{
char old_hostname[HOST_NAME_MAX + 1];
- int ret = 0;
const char *name;
- gboolean set_hostname = TRUE, changed = FALSE, old_valid = TRUE;
+ int ret;
if (new_hostname)
g_warn_if_fail (strlen (new_hostname));
- name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
-
old_hostname[HOST_NAME_MAX] = '\0';
errno = 0;
ret = gethostname (old_hostname, HOST_NAME_MAX);
if (ret != 0) {
nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
errno, strerror (errno));
- old_valid = FALSE;
} else {
/* Don't set the hostname if it isn't actually changing */
if ( (new_hostname && !strcmp (old_hostname, new_hostname))
|| (!new_hostname && !strcmp (old_hostname, FALLBACK_HOSTNAME4)))
- set_hostname = FALSE;
-
- if (old_hostname[0] == '\0')
- old_valid = FALSE;
- }
-
- if (set_hostname) {
- nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
- ret = sethostname (name, strlen (name));
- if (ret != 0) {
- nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
- name, errno, strerror (errno));
return FALSE;
- }
}
- /* But even if the hostname isn't changing, always try updating /etc/hosts
- * just in case the hostname changed while NM wasn't running; we need to
- * make sure that /etc/hosts has valid mappings for '127.0.0.1' and the
- * current system hostname. If those exist,
- * nm_policy_hosts_update_etc_hosts() will just return and won't touch
- * /etc/hosts at all.
- */
- if (!nm_policy_hosts_update_etc_hosts (name,
- old_valid ? old_hostname : NULL,
- FALLBACK_HOSTNAME4,
- FALLBACK_HOSTNAME6,
- ip4_addr,
- ip6_addr,
- &changed)) {
- /* error updating /etc/hosts; fallback to localhost.localdomain */
- nm_log_info (LOGD_DNS, "Setting system hostname to '" FALLBACK_HOSTNAME4 "' (error updating /etc/hosts)");
- ret = sethostname (FALLBACK_HOSTNAME4, strlen (FALLBACK_HOSTNAME4));
- if (ret != 0) {
- nm_log_warn (LOGD_DNS, "couldn't set the fallback system hostname (%s): (%d) %s",
- FALLBACK_HOSTNAME4, errno, strerror (errno));
- }
+ name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
+
+ nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
+ ret = sethostname (name, strlen (name));
+ if (ret != 0) {
+ nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
+ name, errno, strerror (errno));
}
- return changed;
+ return (ret == 0);
}
diff --git a/src/nm-policy-hostname.h b/src/nm-policy-hostname.h
index 9c76884..e76713f 100644
--- a/src/nm-policy-hostname.h
+++ b/src/nm-policy-hostname.h
@@ -24,10 +24,7 @@
#include <glib.h>
-gboolean nm_policy_set_system_hostname (const char *new_hostname,
- const char *ip4_addr,
- const char *ip6_addr,
- const char *msg);
+gboolean nm_policy_set_system_hostname (const char *new_hostname, const char *msg);
typedef struct HostnameThread HostnameThread;
diff --git a/src/nm-policy-hosts.c b/src/nm-policy-hosts.c
index 7f9cff8..8bbd1d3 100644
--- a/src/nm-policy-hosts.c
+++ b/src/nm-policy-hosts.c
@@ -20,526 +20,74 @@
#include <config.h>
#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <arpa/inet.h>
#include "nm-policy-hosts.h"
#include "nm-logging.h"
-#define IP4_LH "127.0.0.1"
-#define IP6_LH "::1"
-
-gboolean
-nm_policy_hosts_find_token (const char *line, const char *token)
-{
- const char *start = line, *p = line;
-
- g_return_val_if_fail (line != NULL, FALSE);
- g_return_val_if_fail (token != NULL, FALSE);
- g_return_val_if_fail (strlen (token) > 0, FALSE);
-
- /* Walk through the line to find the next whitespace character */
- while (p <= line + strlen (line)) {
- if (isblank (*p) || (*p == '\0')) {
- /* Token starts with 'start' and ends with 'end' */
- if ((p > start) && *start && (p - start == strlen (token)) && !strncmp (start, token, (p - start)))
- return TRUE; /* found */
-
- /* not found; advance start and continue looking */
- start = p + 1;
- }
- p++;
- }
-
- return FALSE;
-}
-
-static gboolean
-is_local_mapping (const char *str, gboolean ip6, const char *hostname)
-{
- const char *addr = ip6 ? IP6_LH : IP4_LH;
- const char *fallback = ip6 ? "localhost6" : "localhost";
-
- return ( !strncmp (str, addr, strlen (addr))
- && nm_policy_hosts_find_token (str, hostname ? hostname : fallback));
-}
-
-static gboolean
-is_ip4_addr (const char *str)
-{
- struct in_addr found;
- char buf[INET_ADDRSTRLEN + 2];
- const char *p = str;
- guint32 i = 0;
-
- memset (buf, 0, sizeof (buf));
- while (*p && !isblank (*p) && (i < sizeof (buf)))
- buf[i++] = *p++;
-
- return inet_pton (AF_INET, buf, &found) == 1 ? TRUE : FALSE;
-}
-
-static gboolean
-ip4_addr_matches (const char *str, const char *ip4_addr)
-{
- struct in_addr found, given;
- char buf[INET_ADDRSTRLEN + 2];
- const char *p = str;
- guint32 i = 0;
-
- g_return_val_if_fail (ip4_addr != NULL, FALSE);
-
- memset (buf, 0, sizeof (buf));
- while (*p && !isblank (*p) && (i < sizeof (buf)))
- buf[i++] = *p++;
-
- if (inet_pton (AF_INET, buf, &found) != 1)
- return FALSE;
- if (inet_pton (AF_INET, ip4_addr, &given) != 1)
- return FALSE;
-
- return memcmp (&found, &given, sizeof (found)) == 0;
-}
-
-static gboolean
-is_ip6_addr (const char *str)
-{
- struct in6_addr found;
- char buf[INET6_ADDRSTRLEN + 2];
- const char *p = str;
- guint32 i = 0;
-
- memset (buf, 0, sizeof (buf));
- while (*p && !isblank (*p) && (i < sizeof (buf)))
- buf[i++] = *p++;
-
- return inet_pton (AF_INET6, buf, &found) == 1 ? TRUE : FALSE;
-}
-
-static gboolean
-ip6_addr_matches (const char *str, const char *ip6_addr)
-{
- struct in6_addr found, given;
- char buf[INET6_ADDRSTRLEN + 2];
- const char *p = str;
- guint32 i = 0;
-
- g_return_val_if_fail (ip6_addr != NULL, FALSE);
-
- memset (buf, 0, sizeof (buf));
- while (*p && !isblank (*p) && (i < sizeof (buf)))
- buf[i++] = *p++;
-
- if (inet_pton (AF_INET6, buf, &found) != 1)
- return FALSE;
- if (inet_pton (AF_INET6, ip6_addr, &given) != 1)
- return FALSE;
-
- return memcmp (&found, &given, sizeof (found)) == 0;
-}
-
-static char *
-get_custom_hostnames (const char *line,
- const char *hostname,
- const char *old_hostname,
- const char *short_hostname,
- const char *fallback_hostname)
-{
- char **items = NULL, **iter;
- guint start = 0;
- GString *str = NULL;
- char *custom = NULL;
-
- g_return_val_if_fail (line != NULL, NULL);
-
- if (!strncmp (line, IP4_LH, strlen (IP4_LH)))
- start = strlen (IP4_LH);
- else if (!strncmp (line, IP6_LH, strlen (IP6_LH)))
- start = strlen (IP6_LH);
-
- g_return_val_if_fail (start > 0, NULL);
-
- /* Split the line into tokens */
- items = g_strsplit_set (line + start, " \t", -1);
- if (!items)
- return NULL;
-
- str = g_string_sized_new (50);
- /* Ignore current & old hostnames, and localhost-anything */
- for (iter = items; iter && *iter; iter++) {
- if (*iter[0] == '\0')
- continue;
- if (hostname && !strcmp (*iter, hostname))
- continue;
- if (old_hostname && !strcmp (*iter, old_hostname))
- continue;
- if (short_hostname && !strcmp (*iter, short_hostname))
- continue;
- if (fallback_hostname && !strcmp (*iter, fallback_hostname))
- continue;
- if (!strcmp (*iter, "localhost"))
- continue;
- if (!strcmp (*iter, "localhost6"))
- continue;
- if (!strcmp (*iter, "localhost.localdomain"))
- continue;
- if (!strcmp (*iter, "localhost4.localdomain4"))
- continue;
- if (!strcmp (*iter, "localhost6.localdomain6"))
- continue;
-
- /* Found a custom hostname */
- g_string_append_c (str, '\t');
- g_string_append (str, *iter);
- }
-
- if (str->len)
- custom = g_string_free (str, FALSE);
- else
- g_string_free (str, TRUE);
-
- g_strfreev (items);
- return custom;
-}
-
#define ADDED_TAG "# Added by NetworkManager"
GString *
-nm_policy_get_etc_hosts (const char **lines,
- gsize existing_len,
- const char *hostname,
- const char *old_hostname,
- const char *fallback_hostname4,
- const char *fallback_hostname6,
- const char *ip4_addr,
- const char *ip6_addr,
- GError **error)
+nm_policy_get_etc_hosts (const char *contents, gsize contents_len)
{
- GString *contents = NULL;
- const char **line;
- gboolean found_localhost4 = FALSE;
- gboolean found_localhost6 = FALSE;
- gboolean found_host4 = FALSE;
- gboolean found_host6 = FALSE;
- gboolean found_user_host4 = FALSE;
- gboolean found_user_host6 = FALSE;
- gboolean initial_comments = TRUE;
- gboolean added = FALSE;
- gboolean hostname4_is_fallback;
- gboolean hostname6_is_fallback;
- gboolean host4_before = FALSE;
- gboolean host6_before = FALSE;
- gboolean no_stale = TRUE;
- char *short_hostname = NULL;
- char *custom4 = NULL;
- char *custom6 = NULL;
-
- g_return_val_if_fail (lines != NULL, FALSE);
- g_return_val_if_fail (hostname != NULL, FALSE);
-
- hostname4_is_fallback = !strcmp (hostname, fallback_hostname4);
- hostname6_is_fallback = !strcmp (hostname, fallback_hostname6);
-
- /* Find the short hostname, like 'foo' from 'foo.bar.baz'; we want to
- * make sure that the entries we add for this host also include the short
- * hostname too so that if the resolver does not answer queries for the
- * machine's actual hostname/domain, that stuff like 'ping foo' still works.
- */
- if (!hostname4_is_fallback || !hostname6_is_fallback) {
- char *dot;
-
- short_hostname = g_strdup (hostname);
- dot = strchr (short_hostname, '.');
- if (dot && *(dot+1))
- *dot = '\0';
- else {
- g_free (short_hostname);
- short_hostname = NULL;
- }
- }
-
- /* We need the following in /etc/hosts:
- *
- * 1) current hostname mapped to current IPv4 addresses if IPv4 is active
- * 2) current hostname mapped to current IPv6 addresses if IPv6 is active
- * 3) 'localhost' mapped to 127.0.0.1
- * 4) 'localhost6' mapped to ::1
- *
- * If all these things exist we don't need to bother updating the file.
- */
-
- if (!ip4_addr)
- host4_before = TRUE;
- if (!ip6_addr)
- host6_before = TRUE;
-
- /* Look for the four cases from above */
- for (line = lines; lines && *line; line++) {
- gboolean found_hostname = FALSE;
-
- if ((*line[0] == '\0') || (*line[0] == '#'))
- continue;
+ char **lines = NULL, **iter;
+ GString *new_contents = NULL;
- found_hostname = nm_policy_hosts_find_token (*line, hostname);
- if (found_hostname) {
- /* Found the current hostname on this line */
- if (ip4_addr && ip4_addr_matches (*line, ip4_addr)) {
- found_host4 = TRUE;
- if (strstr (*line, ADDED_TAG)) {
- if (!host4_before)
- host4_before = !found_localhost4;
- } else {
- found_user_host4 = TRUE;
- host4_before = TRUE; /* Ignore if user added mapping manually */
- }
- } else if (!ip4_addr && strstr (*line, ADDED_TAG)) {
- /* If this is a stale NM-added IPv4 entry we need to remove it,
- * so make sure we update /etc/hosts.
- */
- if (is_ip4_addr (*line))
- no_stale = FALSE;
- }
+ if (contents_len == 0 || !strstr (contents, ADDED_TAG))
+ return NULL;
- if (ip6_addr && ip6_addr_matches (*line, ip6_addr)) {
- found_host6 = TRUE;
- if (strstr (*line, ADDED_TAG)) {
- if (!host6_before)
- host6_before = !found_localhost6;
- } else {
- found_user_host6 = TRUE;
- host6_before = TRUE; /* Ignore if user added mapping manually */
- }
- } else if (!ip6_addr && strstr (*line, ADDED_TAG)) {
- /* If this is a stale NM-added IPv6 entry we need to remove it,
- * so make sure we update /etc/hosts.
- */
- if (is_ip6_addr (*line))
- no_stale = FALSE;
- }
- }
+ new_contents = g_string_sized_new (contents_len);
- if (is_local_mapping (*line, FALSE, "localhost")) {
- /* a 127.0.0.1 line containing 'localhost' */
- found_localhost4 = TRUE;
- custom4 = get_custom_hostnames (*line, hostname, old_hostname, short_hostname, fallback_hostname4);
- if (!ip4_addr) {
- /* If there's no IP-specific mapping for the current hostname
- * but that hostname is present on in the local mapping line,
- * we've found our IPv4 hostname mapping. If the hostname is
- * the fallback *IPv6* hostname it's not going to show up in
- * the IPv4 local mapping though, so fake it.
- */
- if (hostname6_is_fallback || found_hostname)
- found_host4 = TRUE;
- }
- } else if (is_local_mapping (*line, TRUE, "localhost6")) {
- /* a ::1 line containing 'localhost6' */
- found_localhost6 = TRUE;
- custom6 = get_custom_hostnames (*line, hostname, old_hostname, short_hostname, fallback_hostname6);
- if (!ip6_addr) {
- /* If there's no IP-specific mapping for the current hostname
- * but that hostname is present on in the local mapping line,
- * we've found our IPv6 hostname mapping. If the hostname is
- * the fallback *IPv4* hostname it's not going to show up in
- * the IPv6 local mapping though, so fake it.
- */
- if (hostname4_is_fallback || found_hostname)
- found_host6 = TRUE;
- }
+ /* Remove "# Added ..." lines */
+ lines = g_strsplit_set (contents, "\n\r", -1);
+ for (iter = lines; iter && *iter; iter++) {
+ if (!strstr (*iter, ADDED_TAG)) {
+ g_string_append (new_contents, *iter);
+ g_string_append_c (new_contents, '\n');
}
-
- if ( found_localhost4
- && found_host4
- && found_localhost6
- && found_host6
- && host4_before
- && host6_before
- && no_stale)
- goto out; /* No update required */
- }
-
- contents = g_string_sized_new (existing_len ? existing_len + 100 : 200);
- if (!contents) {
- g_set_error_literal (error, 0, 0, "not enough memory");
- goto out;
}
+ g_strfreev (lines);
- /* Construct the new hosts file; replace any 127.0.0.1/::1 entry that is
- * at the beginning of the file or right after initial comments and contains
- * the string 'localhost' (for IPv4) or 'localhost6' (for IPv6). If there
- * is no 127.0.0.1 or ::1 entry at the beginning or after initial comments
- * that contains 'localhost' or 'localhost6', add one there
- * and ignore any other 127.0.0.1/::1 entries that contain 'localhost' or
- * 'localhost6'.
+ /* Remove last blank line at end of file, if one exists; this is
+ * an artifact of how g_strsplit_set() works.
*/
- for (line = lines, initial_comments = TRUE; lines && *line; line++) {
- /* This is the first line after the initial comments */
- if (strlen (*line) && initial_comments && (*line[0] != '#')) {
- initial_comments = FALSE;
-
- /* If the user added their own mapping for the hostname, just make
- * a simple 'localhost' mapping and assume the user knows what they
- * are doing with their manual hostname entry. Otherwise if the
- * hostname wasn't found somewhere else, add it to the localhost
- * mapping line to make sure it's mapped to something.
- */
-
- /* Add the address mappings first so they take precedence */
- if (!hostname4_is_fallback && ip4_addr && !found_user_host4) {
- g_string_append_printf (contents, "%s\t%s", ip4_addr, hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- g_string_append_printf (contents, "\t%s\n", ADDED_TAG);
- }
- if (!hostname6_is_fallback && ip6_addr && !found_user_host6) {
- g_string_append_printf (contents, "%s\t%s", ip6_addr, hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- g_string_append_printf (contents, "\t%s\n", ADDED_TAG);
- }
+ if ( (new_contents->len > 2)
+ && (new_contents->str[new_contents->len - 1] == '\n'))
+ g_string_truncate (new_contents, new_contents->len - 1);
- /* IPv4 localhost line */
- g_string_append (contents, "127.0.0.1");
- if (!hostname4_is_fallback && !ip4_addr && !found_user_host4) {
- g_string_append_printf (contents, "\t%s", hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- }
- g_string_append_printf (contents, "\t%s\tlocalhost", fallback_hostname4);
- if (custom4)
- g_string_append (contents, custom4);
- g_string_append_c (contents, '\n');
-
- /* IPv6 localhost line */
- g_string_append (contents, "::1");
- if (!hostname6_is_fallback && !hostname4_is_fallback && !ip6_addr && !found_user_host6) {
- g_string_append_printf (contents, "\t%s", hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- }
- g_string_append_printf (contents, "\t%s\tlocalhost6", fallback_hostname6);
- if (custom6)
- g_string_append (contents, custom6);
- g_string_append_c (contents, '\n');
-
- added = TRUE;
- }
-
- /* Don't add the original line if it is a localhost mapping */
- if ( !is_local_mapping (*line, FALSE, "localhost")
- && !is_local_mapping (*line, FALSE, fallback_hostname4)
- && !is_local_mapping (*line, FALSE, hostname)
- && !is_local_mapping (*line, TRUE, "localhost6")
- && !is_local_mapping (*line, TRUE, fallback_hostname6)
- && !is_local_mapping (*line, TRUE, hostname)
- && !strstr (*line, ADDED_TAG)) {
-
- g_string_append (contents, *line);
- /* Only append the new line if this isn't the last line in the file */
- if (*(line+1))
- g_string_append_c (contents, '\n');
- }
- }
-
- /* Hmm, /etc/hosts was empty for some reason */
- if (!added) {
- g_string_append (contents, "# Do not remove the following lines, or various programs\n");
- g_string_append (contents, "# that require network functionality will fail.\n");
-
- /* Add the address mappings first so they take precedence */
- if (!hostname4_is_fallback && ip4_addr) {
- g_string_append_printf (contents, "%s\t%s", ip4_addr, hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- g_string_append_printf (contents, "\t%s\n", ADDED_TAG);
- }
- if (!hostname6_is_fallback && ip6_addr) {
- g_string_append_printf (contents, "%s\t%s", ip6_addr, hostname);
- if (short_hostname)
- g_string_append_printf (contents, "\t%s", short_hostname);
- g_string_append_printf (contents, "\t%s\n", ADDED_TAG);
- }
-
- g_string_append_printf (contents, "127.0.0.1\t%s\tlocalhost\n", fallback_hostname4);
- g_string_append_printf (contents, "::1\t%s\tlocalhost6\n", fallback_hostname6);
- }
-
-out:
- g_free (custom4);
- g_free (custom6);
- g_free (short_hostname);
- return contents;
+ return new_contents;
}
-gboolean
-nm_policy_hosts_update_etc_hosts (const char *hostname,
- const char *old_hostname,
- const char *fallback_hostname4,
- const char *fallback_hostname6,
- const char *ip4_addr,
- const char *ip6_addr,
- gboolean *out_changed)
+/* remove any leftover "# Added by NetworkManager" lines */
+void
+nm_policy_hosts_clean_etc_hosts (void)
{
char *contents = NULL;
- char **lines = NULL;
- GError *error = NULL;
- GString *new_contents = NULL;
gsize contents_len = 0;
- gboolean success = FALSE;
-
- g_return_val_if_fail (hostname != NULL, FALSE);
- g_return_val_if_fail (out_changed != NULL, FALSE);
+ GError *error = NULL;
+ GString *new;
if (!g_file_get_contents (SYSCONFDIR "/hosts", &contents, &contents_len, &error)) {
nm_log_warn (LOGD_DNS, "couldn't read " SYSCONFDIR "/hosts: (%d) %s",
error ? error->code : 0,
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
- return FALSE;
+ return;
}
- /* Get the new /etc/hosts contents */
- lines = g_strsplit_set (contents, "\n\r", 0);
- new_contents = nm_policy_get_etc_hosts ((const char **) lines,
- contents_len,
- hostname,
- old_hostname,
- fallback_hostname4,
- fallback_hostname6,
- ip4_addr,
- ip6_addr,
- &error);
- g_strfreev (lines);
- g_free (contents);
-
- if (new_contents) {
- nm_log_info (LOGD_DNS, "Updating /etc/hosts with new system hostname");
+ new = nm_policy_get_etc_hosts (contents, contents_len);
+ if (new && new->len) {
+ nm_log_info (LOGD_DNS, "Cleaning leftovers from /etc/hosts");
g_clear_error (&error);
- /* And actually update /etc/hosts */
- if (!g_file_set_contents (SYSCONFDIR "/hosts", new_contents->str, -1, &error)) {
- nm_log_warn (LOGD_DNS, "couldn't update " SYSCONFDIR "/hosts: (%d) %s",
- error ? error->code : 0,
- (error && error->message) ? error->message : "(unknown)");
+ if (!g_file_set_contents (SYSCONFDIR "/hosts", new->str, -1, &error)) {
+ nm_log_dbg (LOGD_DNS, "couldn't update " SYSCONFDIR "/hosts: (%d) %s",
+ error ? error->code : 0,
+ (error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
- } else {
- success = TRUE;
- *out_changed = TRUE;
}
-
- g_string_free (new_contents, TRUE);
- } else if (!error) {
- /* No change required */
- success = TRUE;
- } else {
- nm_log_warn (LOGD_DNS, "couldn't read " SYSCONFDIR "/hosts: (%d) %s",
- error->code, error->message ? error->message : "(unknown)");
- g_clear_error (&error);
}
- return success;
+ if (new)
+ g_string_free (new, TRUE);
}
diff --git a/src/nm-policy-hosts.h b/src/nm-policy-hosts.h
index ebaaf0f..9f4bf9a 100644
--- a/src/nm-policy-hosts.h
+++ b/src/nm-policy-hosts.h
@@ -23,26 +23,10 @@
#include <glib.h>
-gboolean nm_policy_hosts_update_etc_hosts (const char *hostname,
- const char *old_hostname,
- const char *fallback_hostname4,
- const char *fallback_hostname6,
- const char *ip4_addr,
- const char *ip6_addr,
- gboolean *out_changed);
+void nm_policy_hosts_clean_etc_hosts (void);
/* Only for testcases; don't use outside of nm-policy-hosts.c */
-gboolean nm_policy_hosts_find_token (const char *line, const char *token);
-
-GString *nm_policy_get_etc_hosts (const char **lines,
- gsize existing_len,
- const char *hostname,
- const char *old_hostname,
- const char *fallback_hostname4,
- const char *fallback_hostname6,
- const char *ip4_addr,
- const char *ip6_addr,
- GError **error);
+GString *nm_policy_get_etc_hosts (const char *contents, gsize contents_len);
#endif /* NM_POLICY_HOSTS_H */
diff --git a/src/nm-policy.c b/src/nm-policy.c
index e8a18d0..709be09 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -42,7 +42,6 @@
#include "nm-system.h"
#include "nm-dns-manager.h"
#include "nm-vpn-manager.h"
-#include "nm-policy-hosts.h"
#include "nm-policy-hostname.h"
struct NMPolicy {
@@ -233,9 +232,6 @@ _set_hostname (NMPolicy *policy,
const char *new_hostname,
const char *msg)
{
- char ip4_addr[INET_ADDRSTRLEN + 1];
- char ip6_addr[INET6_ADDRSTRLEN + 1];
-
if (change_hostname) {
NMDnsManager *dns_mgr;
@@ -247,43 +243,7 @@ _set_hostname (NMPolicy *policy,
g_object_unref (dns_mgr);
}
- /* Get the default IPv4 and IPv6 addresses so we can assign
- * the hostname to them in /etc/hosts.
- */
- memset (ip4_addr, 0, sizeof (ip4_addr));
- if (policy->default_device4) {
- NMIP4Config *config = NULL;
- NMIP4Address *addr = NULL;
-
- config = nm_device_get_ip4_config (policy->default_device4);
- if (config)
- addr = nm_ip4_config_get_address (config, 0);
-
- if (addr) {
- struct in_addr tmp;
-
- tmp.s_addr = nm_ip4_address_get_address (addr);
- inet_ntop (AF_INET, &tmp, ip4_addr, sizeof (ip4_addr));
- }
- }
-
- memset (ip6_addr, 0, sizeof (ip6_addr));
- if (policy->default_device6) {
- NMIP6Config *config = NULL;
- NMIP6Address *addr = NULL;
-
- config = nm_device_get_ip6_config (policy->default_device6);
- if (config)
- addr = nm_ip6_config_get_address (config, 0);
-
- if (addr)
- inet_ntop (AF_INET6, nm_ip6_address_get_address (addr), ip6_addr, sizeof (ip6_addr));
- }
-
- if (nm_policy_set_system_hostname (policy->cur_hostname,
- strlen (ip4_addr) ? ip4_addr : NULL,
- strlen (ip6_addr) ? ip6_addr : NULL,
- msg))
+ if (nm_policy_set_system_hostname (policy->cur_hostname, msg))
nm_utils_call_dispatcher ("hostname", NULL, NULL, NULL);
}
diff --git a/src/tests/test-policy-hosts.c b/src/tests/test-policy-hosts.c
index 8865c42..62862e7 100644
--- a/src/tests/test-policy-hosts.c
+++ b/src/tests/test-policy-hosts.c
@@ -23,41 +23,17 @@
#include "nm-policy-hosts.h"
-#define FALLBACK_HOSTNAME4 "localhost.localdomain"
-#define FALLBACK_HOSTNAME6 "localhost6.localdomain6"
-
-#define DEBUG 0
+#define DEBUG 1
static void
-test_generic (const char *before,
- const char *after,
- const char *hostname,
- const char *ip4_addr,
- const char *ip6_addr,
- gboolean expect_error)
+test_generic (const char *before, const char *after)
{
- char **lines;
GString *newc;
- GError *error = NULL;
/* Get the new /etc/hosts contents */
- lines = g_strsplit_set (before, "\n\r", 0);
- newc = nm_policy_get_etc_hosts ((const char **) lines,
- strlen (before),
- hostname,
- NULL,
- FALLBACK_HOSTNAME4,
- FALLBACK_HOSTNAME6,
- ip4_addr,
- ip6_addr,
- &error);
- g_strfreev (lines);
+ newc = nm_policy_get_etc_hosts (before, strlen (before));
- if (expect_error) {
- g_assert (newc == NULL);
- g_assert (error != NULL);
- g_clear_error (&error);
- } else if (after == NULL) {
+ if (after == NULL) {
/* No change to /etc/hosts required */
#if DEBUG
if (newc != NULL) {
@@ -68,10 +44,8 @@ test_generic (const char *before,
}
#endif
g_assert (newc == NULL);
- g_assert (error == NULL);
} else {
g_assert (newc != NULL);
- g_assert (error == NULL);
#if DEBUG
g_message ("\n- NEW ---------------------------------\n"
@@ -81,7 +55,6 @@ test_generic (const char *before,
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
newc->str, after);
#endif
- g_assert (strlen (newc->str) == strlen (after));
g_assert (strcmp (newc->str, after) == 0);
g_string_free (newc, TRUE);
}
@@ -99,7 +72,7 @@ static const char *generic_before = \
static void
test_hosts_generic (void)
{
- test_generic (generic_before, NULL, "localhost.localdomain", NULL, NULL, FALSE);
+ test_generic (generic_before, NULL);
}
/*******************************************/
@@ -112,311 +85,25 @@ static const char *generic_no_boilerplate_before = \
static void
test_hosts_generic_no_boilerplate (void)
{
- test_generic (generic_no_boilerplate_before, NULL, "localhost.localdomain", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *generic_no_boilerplate_no_lh_before = \
- "127.0.0.1 localhost.localdomain\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *generic_no_boilerplate_no_lh_after = \
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_generic_no_boilerplate_no_lh (void)
-{
- test_generic (generic_no_boilerplate_no_lh_before,
- generic_no_boilerplate_no_lh_after,
- "localhost.localdomain",
- NULL,
- NULL,
- FALSE);
-}
-
-/*******************************************/
-
-
-static const char *generic_no_boilerplate_no_lh_no_host_before = \
- "127.0.0.1 localhost.localdomain\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *generic_no_boilerplate_no_lh_no_host_after = \
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_generic_no_boilerplate_no_lh_no_host (void)
-{
- test_generic (generic_no_boilerplate_no_lh_no_host_before,
- generic_no_boilerplate_no_lh_no_host_after,
- "comet",
- NULL,
- NULL,
- FALSE);
-}
-
-/*******************************************/
-static const char *named_generic_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 playboy localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *named_generic_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 playboy localhost.localdomain localhost\n"
- "::1 playboy localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named_generic (void)
-{
- test_generic (named_generic_before, named_generic_after, "playboy", NULL, NULL, FALSE);
+ test_generic (generic_no_boilerplate_before, NULL);
}
/*******************************************/
-static const char *named4_non127_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 tomcat localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "192.168.1.2 tomcat\n";
-
-static void
-test_hosts_named4_non127 (void)
-{
- test_generic (named4_non127_before, NULL, "tomcat", "192.168.1.2", NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *named6_non127_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 tomcat localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "3001:abba::3234 tomcat\n";
-
-static void
-test_hosts_named6_non127 (void)
-{
- test_generic (named6_non127_before, NULL, "tomcat", NULL, "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named4_non127_more_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 tomcat localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "192.168.1.2 tomcat\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 srx.main.ebayrtm.com\n"
- "127.0.0.1 cdn5.tribalfusion.com\n";
-
-static void
-test_hosts_named4_non127_more (void)
-{
- test_generic (named4_non127_more_before, NULL, "tomcat", "192.168.1.2", NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *named6_non127_more_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 tomcat localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "3001:abba::3234 tomcat\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 srx.main.ebayrtm.com\n"
- "127.0.0.1 cdn5.tribalfusion.com\n";
-
-static void
-test_hosts_named6_non127_more (void)
-{
- test_generic (named6_non127_more_before, NULL, "tomcat", NULL, "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named_no_lh_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "192.168.1.2 tomcat\n";
-
-static const char *named_no_lh_after = \
+static const char *leftover_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
+ "192.168.1.2 comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
- "::1 tomcat localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "192.168.1.2 tomcat\n";
-
-static void
-test_hosts_named_no_localhost (void)
-{
- test_generic (named_no_lh_before, named_no_lh_after, "tomcat", "192.168.1.2", NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *no_lh_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 tomcat\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *no_lh_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 tomcat localhost.localdomain localhost\n"
- "::1 tomcat localhost6.localdomain6 localhost6\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_no_localhost (void)
-{
- test_generic (no_lh_before, no_lh_after, "tomcat", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *named_last_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 sparcbook.ausil.us\n"
- "::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 sparcbook.ausil.us\n";
-
-static void
-test_hosts_named_last (void)
-{
- test_generic (named_last_before, NULL, "sparcbook.ausil.us", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *no_host4_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 srx.main.ebayrtm.com\n"
- "127.0.0.1 cdn5.tribalfusion.com\n"
- "127.0.0.1 a.tribalfusion.com\n";
-
-static const char *no_host4_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 srx.main.ebayrtm.com\n"
- "127.0.0.1 cdn5.tribalfusion.com\n"
- "127.0.0.1 a.tribalfusion.com\n";
-
-static void
-test_hosts_no_host4 (void)
-{
- test_generic (no_host4_before, no_host4_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *no_host6_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *no_host6_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_no_host6 (void)
-{
- test_generic (no_host6_before, no_host6_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet\n"
- "3001:abba::3234 comet\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127 (void)
-{
- test_generic (named46_non127_before, NULL, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_long_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet.space comet\n"
- "3001:abba::3234 comet.space comet\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127_long (void)
-{
- test_generic (named46_non127_long_before, NULL, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_other4_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n"
"192.168.1.3 comet\n"
"3001:abba::3234 comet\n"
"\n"
"127.0.0.1 lcmd.us.intellitxt.com\n";
-static const char *named46_non127_other4_after = \
+static const char *leftover_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
- "192.168.1.2 comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n"
"192.168.1.3 comet\n"
@@ -425,416 +112,44 @@ static const char *named46_non127_other4_after = \
"127.0.0.1 lcmd.us.intellitxt.com\n";
static void
-test_hosts_named46_non127_other4 (void)
+test_hosts_leftover (void)
{
- test_generic (named46_non127_other4_before, named46_non127_other4_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
+ test_generic (leftover_before, leftover_after);
}
/*******************************************/
-static const char *named46_non127_other4_long_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.3 comet.space\n"
- "3001:abba::3234 comet.space\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *named46_non127_other4_long_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "192.168.1.2 comet.space comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.3 comet.space\n"
- "3001:abba::3234 comet.space\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127_other4_long (void)
-{
- test_generic (named46_non127_other4_long_before, named46_non127_other4_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_other6_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet\n"
- "3001:abba::9675 comet\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *named46_non127_other6_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "3001:abba::3234 comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet\n"
- "3001:abba::9675 comet\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127_other6 (void)
-{
- test_generic (named46_non127_other6_before, named46_non127_other6_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_other6_long_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet.space\n"
- "3001:abba::9675 comet.space\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *named46_non127_other6_long_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "3001:abba::3234 comet.space comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.2 comet.space\n"
- "3001:abba::9675 comet.space\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127_other6_long (void)
-{
- test_generic (named46_non127_other6_long_before, named46_non127_other6_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *unnamed46_non127_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *unnamed46_non127_after = \
+static const char *leftover_double_newline_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"192.168.1.2 comet # Added by NetworkManager\n"
- "3001:abba::3234 comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_unnamed46_non127 (void)
-{
- test_generic (unnamed46_non127_before, unnamed46_non127_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *unnamed46_non127_long_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static const char *unnamed46_non127_long_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "192.168.1.2 comet.space comet # Added by NetworkManager\n"
- "3001:abba::3234 comet.space comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n"
+ "192.168.1.3 comet\n"
+ "3001:abba::3234 comet\n"
"\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_unnamed46_non127_long (void)
-{
- test_generic (unnamed46_non127_long_before, unnamed46_non127_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *named46_non127_wrong_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "192.168.1.3 comet # Added by NetworkManager\n"
- "3001:abba::9876 comet # Added by NetworkManager\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
+ "127.0.0.1 lcmd.us.intellitxt.com\n"
+ "\n";
-static const char *named46_non127_wrong_after = \
+static const char *leftover_double_newline_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
- "192.168.1.2 comet # Added by NetworkManager\n"
- "3001:abba::3234 comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n";
-
-static void
-test_hosts_named46_non127_wrong (void)
-{
- test_generic (named46_non127_wrong_before, named46_non127_wrong_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
-}
-
-/*******************************************/
-
-static const char *long_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost comet\n"
- "::1 localhost6.localdomain6 localhost6\n"
- "\n"
- "127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 adserver.adtech.de\n"
- "127.0.0.1 a.as-us.falkag.net\n"
- "127.0.0.1 a.as-eu.falkag.net\n"
- "127.0.0.1 ads.doubleclick.com\n"
- "\n"
- "# random comment\n"
- "127.0.0.1 m1.2mdn.net\n"
- "127.0.0.1 ds.serving-sys.com\n"
- "127.0.0.1 pagead2.googlesyndication.com\n"
- "127.0.0.1 ad.doubleclick.com\n"
- "127.0.0.1 ad.doubleclick.net\n"
- "127.0.0.1 oascentral.movietickets.com\n"
- "127.0.0.1 view.atdmt.com\n"
- "127.0.0.1 ads.chumcity.com\n";
-
-static const char *long_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n"
+ "192.168.1.3 comet\n"
+ "3001:abba::3234 comet\n"
"\n"
"127.0.0.1 lcmd.us.intellitxt.com\n"
- "127.0.0.1 adserver.adtech.de\n"
- "127.0.0.1 a.as-us.falkag.net\n"
- "127.0.0.1 a.as-eu.falkag.net\n"
- "127.0.0.1 ads.doubleclick.com\n"
- "\n"
- "# random comment\n"
- "127.0.0.1 m1.2mdn.net\n"
- "127.0.0.1 ds.serving-sys.com\n"
- "127.0.0.1 pagead2.googlesyndication.com\n"
- "127.0.0.1 ad.doubleclick.com\n"
- "127.0.0.1 ad.doubleclick.net\n"
- "127.0.0.1 oascentral.movietickets.com\n"
- "127.0.0.1 view.atdmt.com\n"
- "127.0.0.1 ads.chumcity.com\n";
-
-static void
-test_hosts_long (void)
-{
- test_generic (long_before, long_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *custom4_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost pintglass\n"
- "::1 localhost6.localdomain6 localhost6\n";
-
-static const char *custom4_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost pintglass\n"
- "::1 comet localhost6.localdomain6 localhost6\n";
-
-static void
-test_hosts_custom4 (void)
-{
- test_generic (custom4_before, custom4_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *custom6_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6 pintglass\n";
-
-static const char *custom6_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6 pintglass\n";
-
-static void
-test_hosts_custom6 (void)
-{
- test_generic (custom6_before, custom6_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *custom46_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost shotglass\n"
- "::1 localhost6.localdomain6 localhost6 pintglass\n";
-
-static const char *custom46_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost shotglass\n"
- "::1 comet localhost6.localdomain6 localhost6 pintglass\n";
-
-static void
-test_hosts_custom46 (void)
-{
- test_generic (custom46_before, custom46_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *custom46_mixed_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 localhost.localdomain localhost shotglass\n"
- "::1 localhost6.localdomain6 localhost6 pintglass\n";
-
-static const char *custom46_mixed_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost shotglass\n"
- "::1 comet localhost6.localdomain6 localhost6 pintglass\n";
-
-static void
-test_hosts_custom46_mixed (void)
-{
- test_generic (custom46_mixed_before, custom46_mixed_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *stale4_removed_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "1.2.3.4 comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n";
-
-static const char *stale4_removed_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n";
+ "\n";
static void
-test_hosts_stale4_removed (void)
+test_hosts_leftover_double_newline (void)
{
- test_generic (stale4_removed_before, stale4_removed_after, "comet", NULL, NULL, FALSE);
+ test_generic (leftover_double_newline_before, leftover_double_newline_after);
}
/*******************************************/
-static const char *stale6_removed_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "3001:abba::3234 comet # Added by NetworkManager\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n";
-
-static const char *stale6_removed_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n";
-
-static void
-test_hosts_stale6_removed (void)
-{
- test_generic (stale6_removed_before, stale6_removed_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-static const char *stale46_removed_before = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "1.2.3.4 comet # Added by NetworkManager\n"
- "3001:abba::3234 comet # Added by NetworkManager\n"
- "127.0.0.1 localhost.localdomain localhost\n"
- "::1 localhost6.localdomain6 localhost6\n";
-
-static const char *stale46_removed_after = \
- "# Do not remove the following line, or various programs\n"
- "# that require network functionality will fail.\n"
- "127.0.0.1 comet localhost.localdomain localhost\n"
- "::1 comet localhost6.localdomain6 localhost6\n";
-
-static void
-test_hosts_stale46_removed (void)
-{
- test_generic (stale46_removed_before, stale46_removed_after, "comet", NULL, NULL, FALSE);
-}
-
-/*******************************************/
-
-typedef struct {
- const char *line;
- const char *token;
- gboolean expected;
-} Foo;
-
-static Foo foo[] = {
- /* Using \t here to easily differentiate tabs vs. spaces for testing */
- { "127.0.0.1\tfoobar\tblah", "blah", TRUE },
- { "", "blah", FALSE },
- { "1.1.1.1\tbork\tfoo", "blah", FALSE },
- { "127.0.0.1 foobar\tblah", "blah", TRUE },
- { "127.0.0.1 foobar blah", "blah", TRUE },
- { "127.0.0.1 localhost", "localhost.localdomain", FALSE },
- { "192.168.1.1 blah borkbork", "blah", TRUE },
- { "192.168.1.1 foobar\tblah borkbork", "blah", TRUE },
- { "192.168.1.1\tfoobar\tblah\tborkbork", "blah", TRUE },
- { "192.168.1.1 \tfoobar \tblah \tborkbork\t ", "blah", TRUE },
- { "\t\t\t\t \t\t\tasdfadf a\t\t\t\t\t \t\t\t\t\t ", "blah", FALSE },
- { NULL, NULL, FALSE }
-};
-
-static void
-test_find_token (void)
-{
- Foo *iter = &foo[0];
-
- while (iter->line) {
- gboolean found;
-
- found = nm_policy_hosts_find_token (iter->line, iter->token);
- if (found != iter->expected) {
- g_warning ("find-token: unexpected token result %d for '%s' <= '%s' (expected %d)",
- found, iter->line, iter->token, iter->expected);
- }
- g_assert (found == iter->expected);
- iter++;
- }
-}
-
#if GLIB_CHECK_VERSION(2,25,12)
typedef GTestFixtureFunc TCFunc;
#else
@@ -851,38 +166,10 @@ int main (int argc, char **argv)
suite = g_test_get_root ();
- g_test_suite_add (suite, TESTCASE (test_find_token, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_generic, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate_no_lh, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate_no_lh_no_host, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named_generic, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named4_non127, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named6_non127, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named4_non127_more, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named6_non127_more, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_long, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other4, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other4_long, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other6, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other6_long, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_wrong, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_unnamed46_non127, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_unnamed46_non127_long, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named_no_localhost, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_no_localhost, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_named_last, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_no_host4, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_no_host6, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_long, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_custom4, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_custom6, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_custom46, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_custom46_mixed, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_stale4_removed, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_stale6_removed, NULL));
- g_test_suite_add (suite, TESTCASE (test_hosts_stale46_removed, NULL));
+ g_test_suite_add (suite, TESTCASE (test_hosts_leftover, NULL));
+ g_test_suite_add (suite, TESTCASE (test_hosts_leftover_double_newline, NULL));
return g_test_run ();
}
--
1.7.3.4
|