diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-27 23:24:27 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-10-27 23:24:27 +0900 |
commit | 8ccba14bbf77f784f6490130928a26e678f13736 (patch) | |
tree | a3a523c230ed0ea512fa506036473c4693484942 /src/namestore | |
parent | ee022170116cd20fc4983e176b62afd427791e68 (diff) | |
download | gnunet-8ccba14bbf77f784f6490130928a26e678f13736.tar.gz gnunet-8ccba14bbf77f784f6490130928a26e678f13736.zip |
IDENTITY/NAMESTORE:
Remove the concept of "Subsystem default identities".
Add GNUNET_ErrorCodes to IDENTITY subsystem.
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore-zonefile.c | 6 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 120 |
2 files changed, 80 insertions, 46 deletions
diff --git a/src/namestore/gnunet-namestore-zonefile.c b/src/namestore/gnunet-namestore-zonefile.c index 8820dcdfa..d9331aa32 100644 --- a/src/namestore/gnunet-namestore-zonefile.c +++ b/src/namestore/gnunet-namestore-zonefile.c | |||
@@ -283,12 +283,12 @@ parse_origin (char *token, char *origin) | |||
283 | 283 | ||
284 | static void | 284 | static void |
285 | origin_create_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, | 285 | origin_create_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, |
286 | const char *emsg) | 286 | enum GNUNET_ErrorCode ec) |
287 | { | 287 | { |
288 | id_op = NULL; | 288 | id_op = NULL; |
289 | if (NULL != emsg) | 289 | if (GNUNET_EC_NONE != ec) |
290 | { | 290 | { |
291 | fprintf (stderr, "Error: %s\n", emsg); | 291 | fprintf (stderr, "Error: %s\n", GNUNET_ErrorCode_get_hint (ec)); |
292 | ret = 1; | 292 | ret = 1; |
293 | GNUNET_SCHEDULER_shutdown (); | 293 | GNUNET_SCHEDULER_shutdown (); |
294 | return; | 294 | return; |
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index d6154f0aa..843158c68 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1195,6 +1195,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1195 | unsigned int rd_count; | 1195 | unsigned int rd_count; |
1196 | struct GNUNET_GNSRECORD_Data *rd; | 1196 | struct GNUNET_GNSRECORD_Data *rd; |
1197 | 1197 | ||
1198 | if (NULL == ego_name) | ||
1199 | { | ||
1200 | fprintf (stderr, | ||
1201 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1202 | "-z", | ||
1203 | _ ("replace")); | ||
1204 | GNUNET_SCHEDULER_shutdown (); | ||
1205 | ret = 1; | ||
1206 | return; | ||
1207 | } | ||
1198 | if (NULL == name) | 1208 | if (NULL == name) |
1199 | { | 1209 | { |
1200 | fprintf (stderr, | 1210 | fprintf (stderr, |
@@ -1247,6 +1257,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1247 | 1257 | ||
1248 | if (add) | 1258 | if (add) |
1249 | { | 1259 | { |
1260 | if (NULL == ego_name) | ||
1261 | { | ||
1262 | fprintf (stderr, | ||
1263 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1264 | "-z", | ||
1265 | _ ("add")); | ||
1266 | GNUNET_SCHEDULER_shutdown (); | ||
1267 | ret = 1; | ||
1268 | return; | ||
1269 | } | ||
1250 | if (NULL == name) | 1270 | if (NULL == name) |
1251 | { | 1271 | { |
1252 | fprintf (stderr, | 1272 | fprintf (stderr, |
@@ -1334,6 +1354,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1334 | } | 1354 | } |
1335 | if (del) | 1355 | if (del) |
1336 | { | 1356 | { |
1357 | if (NULL == ego_name) | ||
1358 | { | ||
1359 | fprintf (stderr, | ||
1360 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1361 | "-z", | ||
1362 | _ ("del")); | ||
1363 | GNUNET_SCHEDULER_shutdown (); | ||
1364 | ret = 1; | ||
1365 | return; | ||
1366 | } | ||
1337 | if (NULL == name) | 1367 | if (NULL == name) |
1338 | { | 1368 | { |
1339 | fprintf (stderr, | 1369 | fprintf (stderr, |
@@ -1367,6 +1397,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1367 | } | 1397 | } |
1368 | else if (purge_zone) | 1398 | else if (purge_zone) |
1369 | { | 1399 | { |
1400 | if (NULL == ego_name) | ||
1401 | { | ||
1402 | fprintf (stderr, | ||
1403 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1404 | "-z", | ||
1405 | _ ("purge-zone")); | ||
1406 | GNUNET_SCHEDULER_shutdown (); | ||
1407 | ret = 1; | ||
1408 | return; | ||
1409 | } | ||
1370 | list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns, | 1410 | list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns, |
1371 | &zone_pkey, | 1411 | &zone_pkey, |
1372 | &zone_iteration_error_cb, | 1412 | &zone_iteration_error_cb, |
@@ -1381,6 +1421,17 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1381 | else if (list || list_orphaned) | 1421 | else if (list || list_orphaned) |
1382 | { | 1422 | { |
1383 | if (NULL != name) | 1423 | if (NULL != name) |
1424 | { | ||
1425 | if (NULL == ego_name) | ||
1426 | { | ||
1427 | fprintf (stderr, | ||
1428 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1429 | "-z", | ||
1430 | _ ("list")); | ||
1431 | GNUNET_SCHEDULER_shutdown (); | ||
1432 | ret = 1; | ||
1433 | return; | ||
1434 | } | ||
1384 | get_qe = GNUNET_NAMESTORE_records_lookup (ns, | 1435 | get_qe = GNUNET_NAMESTORE_records_lookup (ns, |
1385 | &zone_pkey, | 1436 | &zone_pkey, |
1386 | name, | 1437 | name, |
@@ -1388,6 +1439,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1388 | NULL, | 1439 | NULL, |
1389 | &display_record_lookup, | 1440 | &display_record_lookup, |
1390 | NULL); | 1441 | NULL); |
1442 | } | ||
1391 | else | 1443 | else |
1392 | list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns, | 1444 | list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns, |
1393 | (NULL == ego_name) ? | 1445 | (NULL == ego_name) ? |
@@ -1404,6 +1456,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1404 | { | 1456 | { |
1405 | struct GNUNET_IDENTITY_PublicKey pubkey; | 1457 | struct GNUNET_IDENTITY_PublicKey pubkey; |
1406 | 1458 | ||
1459 | if (NULL == ego_name) | ||
1460 | { | ||
1461 | fprintf (stderr, | ||
1462 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1463 | "-z", | ||
1464 | _ ("reverse-pkey")); | ||
1465 | GNUNET_SCHEDULER_shutdown (); | ||
1466 | ret = 1; | ||
1467 | return; | ||
1468 | } | ||
1407 | if (GNUNET_OK != | 1469 | if (GNUNET_OK != |
1408 | GNUNET_IDENTITY_public_key_from_string (reverse_pkey, | 1470 | GNUNET_IDENTITY_public_key_from_string (reverse_pkey, |
1409 | &pubkey)) | 1471 | &pubkey)) |
@@ -1426,6 +1488,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1426 | char sh[105]; | 1488 | char sh[105]; |
1427 | char sname[64]; | 1489 | char sname[64]; |
1428 | struct GNUNET_IDENTITY_PublicKey pkey; | 1490 | struct GNUNET_IDENTITY_PublicKey pkey; |
1491 | if (NULL == ego_name) | ||
1492 | { | ||
1493 | fprintf (stderr, | ||
1494 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1495 | "-z", | ||
1496 | _ ("uri")); | ||
1497 | GNUNET_SCHEDULER_shutdown (); | ||
1498 | ret = 1; | ||
1499 | return; | ||
1500 | } | ||
1429 | 1501 | ||
1430 | memset (sh, 0, 105); | 1502 | memset (sh, 0, 105); |
1431 | memset (sname, 0, 64); | 1503 | memset (sname, 0, 64); |
@@ -1476,7 +1548,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1476 | if (monitor) | 1548 | if (monitor) |
1477 | { | 1549 | { |
1478 | zm = GNUNET_NAMESTORE_zone_monitor_start2 (cfg, | 1550 | zm = GNUNET_NAMESTORE_zone_monitor_start2 (cfg, |
1479 | &zone_pkey, | 1551 | (NULL != ego_name) ? |
1552 | &zone_pkey : NULL, | ||
1480 | GNUNET_YES, | 1553 | GNUNET_YES, |
1481 | &monitor_error_cb, | 1554 | &monitor_error_cb, |
1482 | NULL, | 1555 | NULL, |
@@ -1523,44 +1596,6 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
1523 | 1596 | ||
1524 | 1597 | ||
1525 | /** | 1598 | /** |
1526 | * Function called with the default ego to be used for GNS | ||
1527 | * operations. Used if the user did not specify a zone via | ||
1528 | * command-line or environment variables. | ||
1529 | * | ||
1530 | * @param cls NULL | ||
1531 | * @param ego default ego, NULL for none | ||
1532 | * @param ctx NULL | ||
1533 | * @param name unused | ||
1534 | */ | ||
1535 | static void | ||
1536 | default_ego_cb (void *cls, | ||
1537 | struct GNUNET_IDENTITY_Ego *ego, | ||
1538 | void **ctx, | ||
1539 | const char *name) | ||
1540 | { | ||
1541 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
1542 | |||
1543 | (void) ctx; | ||
1544 | (void) name; | ||
1545 | get_default = NULL; | ||
1546 | if (NULL == ego) | ||
1547 | { | ||
1548 | fprintf (stderr, | ||
1549 | _ ("No default identity configured for `namestore' subsystem\n" | ||
1550 | "Run gnunet-identity -s namestore -e $NAME to set the default to $NAME\n" | ||
1551 | "Run gnunet-identity -d to get a list of choices for $NAME\n")); | ||
1552 | GNUNET_SCHEDULER_shutdown (); | ||
1553 | ret = -1; | ||
1554 | return; | ||
1555 | } | ||
1556 | else | ||
1557 | { | ||
1558 | identity_cb ((void *) cfg, ego); | ||
1559 | } | ||
1560 | } | ||
1561 | |||
1562 | |||
1563 | /** | ||
1564 | * Function called with ALL of the egos known to the | 1599 | * Function called with ALL of the egos known to the |
1565 | * identity service, used on startup if the user did | 1600 | * identity service, used on startup if the user did |
1566 | * not specify a zone on the command-line. | 1601 | * not specify a zone on the command-line. |
@@ -1597,11 +1632,10 @@ id_connect_cb (void *cls, | |||
1597 | } | 1632 | } |
1598 | if (NULL != ego) | 1633 | if (NULL != ego) |
1599 | return; | 1634 | return; |
1600 | if (NULL != ego_name) | 1635 | if (NULL == ego_name) |
1601 | el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg); | 1636 | run_with_zone_pkey (cfg); |
1602 | else | 1637 | else |
1603 | get_default = | 1638 | el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg); |
1604 | GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg); | ||
1605 | } | 1639 | } |
1606 | 1640 | ||
1607 | 1641 | ||