diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-21 15:43:43 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-21 15:43:43 +0900 |
commit | bdab06894ca42106651e7328657cf87c779b6acf (patch) | |
tree | 09e6a71ac7a28325f05e6163a3f1e985c58f143b | |
parent | dcc603a15131602fc0da292b08609383335c1485 (diff) | |
download | gnunet-bdab06894ca42106651e7328657cf87c779b6acf.tar.gz gnunet-bdab06894ca42106651e7328657cf87c779b6acf.zip |
-fix ztld parsing in recordline; add test for that
-rw-r--r-- | src/namestore/gnunet-namestore.c | 56 | ||||
-rwxr-xr-x | src/namestore/test_namestore_put_stdin.sh | 8 |
2 files changed, 53 insertions, 11 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index ee59e7432..207394dd9 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1371,12 +1371,12 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1371 | struct GNUNET_GNSRECORD_Data *rd; | 1371 | struct GNUNET_GNSRECORD_Data *rd; |
1372 | 1372 | ||
1373 | /* FIXME: We could easily support append and delete with this as well */ | 1373 | /* FIXME: We could easily support append and delete with this as well */ |
1374 | if (!add) | 1374 | if (! add) |
1375 | { | 1375 | { |
1376 | fprintf (stderr, _("Recordlines only work with option `%s'\n"), | 1376 | fprintf (stderr, _ ("Recordlines only work with option `%s'\n"), |
1377 | "-a"); | 1377 | "-a"); |
1378 | ret = 1; | 1378 | ret = 1; |
1379 | finish_command(); | 1379 | finish_command (); |
1380 | return; | 1380 | return; |
1381 | } | 1381 | } |
1382 | if (NULL == name) | 1382 | if (NULL == name) |
@@ -1741,10 +1741,47 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1741 | 1741 | ||
1742 | #define MAX_ARGS 20 | 1742 | #define MAX_ARGS 20 |
1743 | 1743 | ||
1744 | static int | ||
1745 | get_identity_for_string (const char *str, | ||
1746 | struct GNUNET_IDENTITY_PrivateKey *zk) | ||
1747 | { | ||
1748 | const struct GNUNET_IDENTITY_PrivateKey *privkey; | ||
1749 | struct GNUNET_IDENTITY_PublicKey pubkey; | ||
1750 | struct GNUNET_IDENTITY_PublicKey ego_pubkey; | ||
1751 | struct EgoEntry *ego_entry; | ||
1752 | |||
1753 | if (GNUNET_OK == GNUNET_IDENTITY_public_key_from_string (str, | ||
1754 | &pubkey)) | ||
1755 | { | ||
1756 | for (ego_entry = ego_head; | ||
1757 | NULL != ego_entry; ego_entry = ego_entry->next) | ||
1758 | { | ||
1759 | privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
1760 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey); | ||
1761 | if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey))) | ||
1762 | { | ||
1763 | *zk = *privkey; | ||
1764 | return GNUNET_OK; | ||
1765 | } | ||
1766 | } | ||
1767 | } | ||
1768 | else | ||
1769 | { | ||
1770 | for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
1771 | { | ||
1772 | /** FIXME: Check for zTLD? **/ | ||
1773 | if (0 != strcmp (str, ego_entry->identifier)) | ||
1774 | continue; | ||
1775 | *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
1776 | return GNUNET_OK; | ||
1777 | } | ||
1778 | } | ||
1779 | return GNUNET_NO; | ||
1780 | } | ||
1781 | |||
1744 | static void | 1782 | static void |
1745 | process_command_stdin () | 1783 | process_command_stdin () |
1746 | { | 1784 | { |
1747 | struct EgoEntry *ego_entry; | ||
1748 | char buf[MAX_LINE_LEN]; | 1785 | char buf[MAX_LINE_LEN]; |
1749 | static struct GNUNET_IDENTITY_PrivateKey next_zone_key; | 1786 | static struct GNUNET_IDENTITY_PrivateKey next_zone_key; |
1750 | static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; | 1787 | static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; |
@@ -1783,13 +1820,12 @@ process_command_stdin () | |||
1783 | ret = 1; | 1820 | ret = 1; |
1784 | return; | 1821 | return; |
1785 | } | 1822 | } |
1786 | for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | 1823 | if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key)) |
1787 | { | 1824 | { |
1788 | /** FIXME: Check for zTLD? **/ | 1825 | fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1); |
1789 | if (0 != strcmp (tmp + 1, ego_entry->identifier)) | 1826 | ret = 1; |
1790 | continue; | 1827 | GNUNET_SCHEDULER_shutdown (); |
1791 | next_zone_key = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 1828 | return; |
1792 | break; | ||
1793 | } | 1829 | } |
1794 | *tmp = '\0'; | 1830 | *tmp = '\0'; |
1795 | printf ("Switching to new name `%s' in zone `%s'\n", next_name, tmp + 1); | 1831 | printf ("Switching to new name `%s' in zone `%s'\n", next_name, tmp + 1); |
diff --git a/src/namestore/test_namestore_put_stdin.sh b/src/namestore/test_namestore_put_stdin.sh index 8fdcaa23f..deb7bc4cb 100755 --- a/src/namestore/test_namestore_put_stdin.sh +++ b/src/namestore/test_namestore_put_stdin.sh | |||
@@ -26,17 +26,20 @@ function start_peer | |||
26 | { | 26 | { |
27 | gnunet-arm -s -c $CONFIGURATION | 27 | gnunet-arm -s -c $CONFIGURATION |
28 | gnunet-identity -C testego -c $CONFIGURATION | 28 | gnunet-identity -C testego -c $CONFIGURATION |
29 | gnunet-identity -C testego2 -c $CONFIGURATION | ||
29 | } | 30 | } |
30 | 31 | ||
31 | function stop_peer | 32 | function stop_peer |
32 | { | 33 | { |
33 | gnunet-identity -D testego -c $CONFIGURATION | 34 | gnunet-identity -D testego -c $CONFIGURATION |
35 | gnunet-identity -D testego2 -c $CONFIGURATION | ||
34 | gnunet-arm -e -c $CONFIGURATION | 36 | gnunet-arm -e -c $CONFIGURATION |
35 | } | 37 | } |
36 | 38 | ||
37 | 39 | ||
38 | start_peer | 40 | start_peer |
39 | # Create a public record | 41 | # Create a public record |
42 | EGOKEY=`gnunet-identity -d | grep testego2 | cut -d' ' -f3` | ||
40 | gnunet-namestore -a -c $CONFIGURATION -S <<EOF | 43 | gnunet-namestore -a -c $CONFIGURATION -S <<EOF |
41 | $TEST_RECORD_NAME.testego: | 44 | $TEST_RECORD_NAME.testego: |
42 | A 3600000000 [pr] $TEST_IP | 45 | A 3600000000 [pr] $TEST_IP |
@@ -48,9 +51,12 @@ $TEST_RECORD_NAME2.testego: | |||
48 | AAAA 324241223 [prS] ::dead:beef | 51 | AAAA 324241223 [prS] ::dead:beef |
49 | A 111324241223000000 [pC] 1.1.1.1 | 52 | A 111324241223000000 [pC] 1.1.1.1 |
50 | 53 | ||
54 | www7.$EGOKEY: | ||
55 | A 3600000000 [pr] $TEST_IP | ||
56 | |||
51 | EOF | 57 | EOF |
52 | NAMESTORE_RES=$? | 58 | NAMESTORE_RES=$? |
53 | gnunet-namestore -z testego -D -r -c $CONFIGURATION | 59 | gnunet-namestore -D -r -c $CONFIGURATION |
54 | stop_peer | 60 | stop_peer |
55 | 61 | ||
56 | if [ $NAMESTORE_RES = 0 ] | 62 | if [ $NAMESTORE_RES = 0 ] |