diff options
author | t3sserakt <t3ss@posteo.de> | 2021-01-05 13:35:49 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-01-05 13:35:49 +0100 |
commit | fac97cea47df432d6418e0399e799e47057e89d7 (patch) | |
tree | 33412732a2e78342a07649d70c9eff0b706709d2 /src | |
parent | 5affc9ad078e8d90c47a2972d67cd9d65529792d (diff) | |
parent | fd30e4bf7ebd4d628f04e0158c527607870759d4 (diff) | |
download | gnunet-fac97cea47df432d6418e0399e799e47057e89d7.tar.gz gnunet-fac97cea47df432d6418e0399e799e47057e89d7.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
56 files changed, 1314 insertions, 1783 deletions
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index d25ae55e6..e49609b18 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -111,17 +111,20 @@ clean_task (void *cls) | |||
111 | ctx = NULL; | 111 | ctx = NULL; |
112 | if (output_filename == NULL) | 112 | if (output_filename == NULL) |
113 | return; | 113 | return; |
114 | if (GNUNET_OK != GNUNET_FS_directory_builder_finish (db, &dsize, &ddata)) | 114 | if (GNUNET_OK != |
115 | GNUNET_FS_directory_builder_finish (db, &dsize, &ddata)) | ||
115 | { | 116 | { |
116 | GNUNET_break (0); | 117 | GNUNET_break (0); |
117 | GNUNET_free (output_filename); | 118 | GNUNET_free (output_filename); |
118 | return; | 119 | return; |
119 | } | 120 | } |
120 | if (dsize != GNUNET_DISK_fn_write (output_filename, | 121 | (void) GNUNET_DISK_directory_remove (output_filename); |
121 | ddata, | 122 | if (GNUNET_OK != |
122 | dsize, | 123 | GNUNET_DISK_fn_write (output_filename, |
123 | GNUNET_DISK_PERM_USER_READ | 124 | ddata, |
124 | | GNUNET_DISK_PERM_USER_WRITE)) | 125 | dsize, |
126 | GNUNET_DISK_PERM_USER_READ | ||
127 | | GNUNET_DISK_PERM_USER_WRITE)) | ||
125 | { | 128 | { |
126 | fprintf (stderr, | 129 | fprintf (stderr, |
127 | _ ("Failed to write directory with search results to `%s'\n"), | 130 | _ ("Failed to write directory with search results to `%s'\n"), |
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 2be2e7f6a..2fe0da77c 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c | |||
@@ -299,8 +299,11 @@ run (void *cls, | |||
299 | "USE_INDEX")) | 299 | "USE_INDEX")) |
300 | { | 300 | { |
301 | fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test"); | 301 | fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test"); |
302 | GNUNET_assert (FILESIZE == | 302 | (void) GNUNET_DISK_directory_remove (fn1); |
303 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 303 | GNUNET_assert (GNUNET_OK == |
304 | GNUNET_DISK_fn_write (fn1, | ||
305 | buf, | ||
306 | FILESIZE, | ||
304 | GNUNET_DISK_PERM_USER_READ | 307 | GNUNET_DISK_PERM_USER_READ |
305 | | GNUNET_DISK_PERM_USER_WRITE)); | 308 | | GNUNET_DISK_PERM_USER_WRITE)); |
306 | GNUNET_free (buf); | 309 | GNUNET_free (buf); |
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index 9305471d6..9d0978e06 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c | |||
@@ -82,7 +82,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
82 | buf = GNUNET_malloc (FILESIZE); | 82 | buf = GNUNET_malloc (FILESIZE); |
83 | for (i = 0; i < FILESIZE; i++) | 83 | for (i = 0; i < FILESIZE; i++) |
84 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 84 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
85 | GNUNET_assert (FILESIZE == | 85 | (void) GNUNET_DISK_directory_remove (fn1); |
86 | GNUNET_assert (GNUNET_OK == | ||
86 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 87 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, |
87 | GNUNET_DISK_PERM_USER_READ | 88 | GNUNET_DISK_PERM_USER_READ |
88 | | GNUNET_DISK_PERM_USER_WRITE)); | 89 | | GNUNET_DISK_PERM_USER_WRITE)); |
@@ -92,7 +93,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
92 | buf = GNUNET_malloc (FILESIZE); | 93 | buf = GNUNET_malloc (FILESIZE); |
93 | for (i = 0; i < FILESIZE; i++) | 94 | for (i = 0; i < FILESIZE; i++) |
94 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 95 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
95 | GNUNET_assert (FILESIZE == | 96 | (void) GNUNET_DISK_directory_remove (fn2); |
97 | GNUNET_assert (GNUNET_OK == | ||
96 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, | 98 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, |
97 | GNUNET_DISK_PERM_USER_READ | 99 | GNUNET_DISK_PERM_USER_READ |
98 | | GNUNET_DISK_PERM_USER_WRITE)); | 100 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index 93367883f..2f04a017a 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c | |||
@@ -198,7 +198,8 @@ run (void *cls, | |||
198 | buf = GNUNET_malloc (FILESIZE); | 198 | buf = GNUNET_malloc (FILESIZE); |
199 | for (i = 0; i < FILESIZE; i++) | 199 | for (i = 0; i < FILESIZE; i++) |
200 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 200 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
201 | GNUNET_assert (FILESIZE == | 201 | (void) GNUNET_DISK_directory_remove (fn1); |
202 | GNUNET_assert (GNUNET_OK == | ||
202 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 203 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, |
203 | GNUNET_DISK_PERM_USER_READ | 204 | GNUNET_DISK_PERM_USER_READ |
204 | | GNUNET_DISK_PERM_USER_WRITE)); | 205 | | GNUNET_DISK_PERM_USER_WRITE)); |
@@ -208,7 +209,8 @@ run (void *cls, | |||
208 | buf = GNUNET_malloc (FILESIZE); | 209 | buf = GNUNET_malloc (FILESIZE); |
209 | for (i = 0; i < FILESIZE; i++) | 210 | for (i = 0; i < FILESIZE; i++) |
210 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 211 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
211 | GNUNET_assert (FILESIZE == | 212 | (void) GNUNET_DISK_directory_remove (fn2); |
213 | GNUNET_assert (GNUNET_OK == | ||
212 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, | 214 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, |
213 | GNUNET_DISK_PERM_USER_READ | 215 | GNUNET_DISK_PERM_USER_READ |
214 | | GNUNET_DISK_PERM_USER_WRITE)); | 216 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index c42e546e3..2ffc722da 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c | |||
@@ -184,7 +184,8 @@ run (void *cls, | |||
184 | buf = GNUNET_malloc (FILESIZE); | 184 | buf = GNUNET_malloc (FILESIZE); |
185 | for (i = 0; i < FILESIZE; i++) | 185 | for (i = 0; i < FILESIZE; i++) |
186 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 186 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
187 | GNUNET_assert (FILESIZE == | 187 | (void) GNUNET_DISK_directory_remove (fn1); |
188 | GNUNET_assert (GNUNET_OK == | ||
188 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 189 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, |
189 | GNUNET_DISK_PERM_USER_READ | 190 | GNUNET_DISK_PERM_USER_READ |
190 | | GNUNET_DISK_PERM_USER_WRITE)); | 191 | | GNUNET_DISK_PERM_USER_WRITE)); |
@@ -194,7 +195,8 @@ run (void *cls, | |||
194 | buf = GNUNET_malloc (FILESIZE); | 195 | buf = GNUNET_malloc (FILESIZE); |
195 | for (i = 0; i < FILESIZE; i++) | 196 | for (i = 0; i < FILESIZE; i++) |
196 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 197 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
197 | GNUNET_assert (FILESIZE == | 198 | (void) GNUNET_DISK_directory_remove (fn2); |
199 | GNUNET_assert (GNUNET_OK == | ||
198 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, | 200 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, |
199 | GNUNET_DISK_PERM_USER_READ | 201 | GNUNET_DISK_PERM_USER_READ |
200 | | GNUNET_DISK_PERM_USER_WRITE)); | 202 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index 4ec39d06e..da0209793 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c | |||
@@ -258,7 +258,8 @@ run (void *cls, | |||
258 | buf = GNUNET_malloc (FILESIZE); | 258 | buf = GNUNET_malloc (FILESIZE); |
259 | for (i = 0; i < FILESIZE; i++) | 259 | for (i = 0; i < FILESIZE; i++) |
260 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 260 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
261 | GNUNET_assert (FILESIZE == | 261 | (void) GNUNET_DISK_directory_remove (fn1); |
262 | GNUNET_assert (GNUNET_OK == | ||
262 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 263 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, |
263 | GNUNET_DISK_PERM_USER_READ | 264 | GNUNET_DISK_PERM_USER_READ |
264 | | GNUNET_DISK_PERM_USER_WRITE)); | 265 | | GNUNET_DISK_PERM_USER_WRITE)); |
@@ -268,7 +269,8 @@ run (void *cls, | |||
268 | buf = GNUNET_malloc (FILESIZE); | 269 | buf = GNUNET_malloc (FILESIZE); |
269 | for (i = 0; i < FILESIZE; i++) | 270 | for (i = 0; i < FILESIZE; i++) |
270 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 271 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
271 | GNUNET_assert (FILESIZE == | 272 | (void) GNUNET_DISK_directory_remove (fn2); |
273 | GNUNET_assert (GNUNET_OK == | ||
272 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, | 274 | GNUNET_DISK_fn_write (fn2, buf, FILESIZE, |
273 | GNUNET_DISK_PERM_USER_READ | 275 | GNUNET_DISK_PERM_USER_READ |
274 | | GNUNET_DISK_PERM_USER_WRITE)); | 276 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index a11c574c1..992672244 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c | |||
@@ -197,7 +197,8 @@ run (void *cls, | |||
197 | buf = GNUNET_malloc (FILESIZE); | 197 | buf = GNUNET_malloc (FILESIZE); |
198 | for (i = 0; i < FILESIZE; i++) | 198 | for (i = 0; i < FILESIZE; i++) |
199 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 199 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
200 | GNUNET_assert (FILESIZE == | 200 | (void) GNUNET_DISK_directory_remove (fn); |
201 | GNUNET_assert (GNUNET_OK == | ||
201 | GNUNET_DISK_fn_write (fn, buf, FILESIZE, | 202 | GNUNET_DISK_fn_write (fn, buf, FILESIZE, |
202 | GNUNET_DISK_PERM_USER_READ | 203 | GNUNET_DISK_PERM_USER_READ |
203 | | GNUNET_DISK_PERM_USER_WRITE)); | 204 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index c3668f4e0..802aaf7ca 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c | |||
@@ -267,7 +267,8 @@ run (void *cls, | |||
267 | buf = GNUNET_malloc (FILESIZE); | 267 | buf = GNUNET_malloc (FILESIZE); |
268 | for (i = 0; i < FILESIZE; i++) | 268 | for (i = 0; i < FILESIZE; i++) |
269 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 269 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); |
270 | GNUNET_assert (FILESIZE == | 270 | (void) GNUNET_DISK_directory_remove (fn); |
271 | GNUNET_assert (GNUNET_OK == | ||
271 | GNUNET_DISK_fn_write (fn, buf, FILESIZE, | 272 | GNUNET_DISK_fn_write (fn, buf, FILESIZE, |
272 | GNUNET_DISK_PERM_USER_READ | 273 | GNUNET_DISK_PERM_USER_READ |
273 | | GNUNET_DISK_PERM_USER_WRITE)); | 274 | | GNUNET_DISK_PERM_USER_WRITE)); |
diff --git a/src/gns/test_gnunet_gns.sh.in b/src/gns/test_gnunet_gns.sh.in index 8cdd062c7..8a96ff034 100755 --- a/src/gns/test_gnunet_gns.sh.in +++ b/src/gns/test_gnunet_gns.sh.in | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | # test -z being correct was a false assumption here. | 3 | # test -z being correct was a false assumption here. |
4 | # I have no executable 'fooble', but this will | 4 | # I have no executable 'fooble', but this will |
diff --git a/src/gns/test_proxy.sh b/src/gns/test_proxy.sh index 7c17cd4c5..ee288413f 100755 --- a/src/gns/test_proxy.sh +++ b/src/gns/test_proxy.sh | |||
@@ -31,10 +31,10 @@ cat local.crt > /tmp/server_cacert.pem | |||
31 | cat local.key >> /tmp/server_cacert.pem | 31 | cat local.key >> /tmp/server_cacert.pem |
32 | 32 | ||
33 | gnunet-identity -C test -c test_gns_proxy.conf | 33 | gnunet-identity -C test -c test_gns_proxy.conf |
34 | gnunet-namestore -p -z test -a -n www -t A -V 127.0.0.1 -e never -c test_gns_proxy.conf | 34 | gnunet-namestore -p -z "test" -a -n www -t A -V 127.0.0.1 -e never -c test_gns_proxy.conf |
35 | gnunet-namestore -p -z test -a -n www -t LEHO -V "test.local" -e never -c test_gns_proxy.conf | 35 | gnunet-namestore -p -z "test" -a -n www -t LEHO -V "test.local" -e never -c test_gns_proxy.conf |
36 | gnunet-namestore -p -z test -a -n www -t BOX -V "$OLDBOXVALUE" -e never -c test_gns_proxy.conf | 36 | gnunet-namestore -p -z "test" -a -n www -t BOX -V "$OLDBOXVALUE" -e never -c test_gns_proxy.conf |
37 | gnunet-namestore -p -z test -a -n www -t BOX -V "$BOXVALUE" -e never -c test_gns_proxy.conf | 37 | gnunet-namestore -p -z "test" -a -n www -t BOX -V "$BOXVALUE" -e never -c test_gns_proxy.conf |
38 | 38 | ||
39 | gnunet-arm -i gns-proxy -c test_gns_proxy.conf | 39 | gnunet-arm -i gns-proxy -c test_gns_proxy.conf |
40 | 40 | ||
diff --git a/src/gnsrecord/Makefile.am b/src/gnsrecord/Makefile.am index ab604eb92..7c0df461f 100644 --- a/src/gnsrecord/Makefile.am +++ b/src/gnsrecord/Makefile.am | |||
@@ -106,6 +106,7 @@ test_gnsrecord_crypto_SOURCES = \ | |||
106 | test_gnsrecord_crypto.c | 106 | test_gnsrecord_crypto.c |
107 | test_gnsrecord_crypto_LDADD = \ | 107 | test_gnsrecord_crypto_LDADD = \ |
108 | $(top_builddir)/src/testing/libgnunettesting.la \ | 108 | $(top_builddir)/src/testing/libgnunettesting.la \ |
109 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
109 | libgnunetgnsrecord.la \ | 110 | libgnunetgnsrecord.la \ |
110 | $(top_builddir)/src/util/libgnunetutil.la | 111 | $(top_builddir)/src/util/libgnunetutil.la |
111 | 112 | ||
@@ -114,5 +115,6 @@ perf_gnsrecord_crypto_SOURCES = \ | |||
114 | perf_gnsrecord_crypto.c | 115 | perf_gnsrecord_crypto.c |
115 | perf_gnsrecord_crypto_LDADD = \ | 116 | perf_gnsrecord_crypto_LDADD = \ |
116 | $(top_builddir)/src/testing/libgnunettesting.la \ | 117 | $(top_builddir)/src/testing/libgnunettesting.la \ |
118 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
117 | libgnunetgnsrecord.la \ | 119 | libgnunetgnsrecord.la \ |
118 | $(top_builddir)/src/util/libgnunetutil.la | 120 | $(top_builddir)/src/util/libgnunetutil.la |
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index 6cdb1c2f7..2bb4b0897 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -697,8 +697,7 @@ check_create_message (void *cls, | |||
697 | 697 | ||
698 | 698 | ||
699 | /** | 699 | /** |
700 | * Handler for CREATE message from client, creates | 700 | * Handler for CREATE message from client, creates new identity. |
701 | * new identity. | ||
702 | * | 701 | * |
703 | * @param cls unused | 702 | * @param cls unused |
704 | * @param client who sent the message | 703 | * @param client who sent the message |
@@ -737,8 +736,7 @@ handle_create_message (void *cls, | |||
737 | ego); | 736 | ego); |
738 | send_result_code (client, 0, NULL); | 737 | send_result_code (client, 0, NULL); |
739 | fn = get_ego_filename (ego); | 738 | fn = get_ego_filename (ego); |
740 | (void) GNUNET_DISK_directory_create_for_file (fn); | 739 | if (GNUNET_OK != |
741 | if (sizeof(struct GNUNET_IDENTITY_PrivateKey) != | ||
742 | GNUNET_DISK_fn_write (fn, | 740 | GNUNET_DISK_fn_write (fn, |
743 | &crm->private_key, | 741 | &crm->private_key, |
744 | sizeof(struct GNUNET_IDENTITY_PrivateKey), | 742 | sizeof(struct GNUNET_IDENTITY_PrivateKey), |
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index bc2055709..707108289 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -71,7 +71,7 @@ extern "C" { | |||
71 | /** | 71 | /** |
72 | * Version of the API (for entire gnunetutil.so library). | 72 | * Version of the API (for entire gnunetutil.so library). |
73 | */ | 73 | */ |
74 | #define GNUNET_UTIL_VERSION 0x000A0103 | 74 | #define GNUNET_UTIL_VERSION 0x000A0104 |
75 | 75 | ||
76 | 76 | ||
77 | /** | 77 | /** |
@@ -345,7 +345,7 @@ struct GNUNET_AsyncScopeSave | |||
345 | * #GNUNET_NO to stop iteration with no error, | 345 | * #GNUNET_NO to stop iteration with no error, |
346 | * #GNUNET_SYSERR to abort iteration with error! | 346 | * #GNUNET_SYSERR to abort iteration with error! |
347 | */ | 347 | */ |
348 | typedef int | 348 | typedef enum GNUNET_GenericReturnValue |
349 | (*GNUNET_FileNameCallback) (void *cls, | 349 | (*GNUNET_FileNameCallback) (void *cls, |
350 | const char *filename); | 350 | const char *filename); |
351 | 351 | ||
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index b4e7f7d8f..ad55c1b9a 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h | |||
@@ -82,7 +82,7 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg); | |||
82 | * @param filename name of the configuration file, NULL to load defaults | 82 | * @param filename name of the configuration file, NULL to load defaults |
83 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 83 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
84 | */ | 84 | */ |
85 | int | 85 | enum GNUNET_GenericReturnValue |
86 | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | 86 | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, |
87 | const char *filename); | 87 | const char *filename); |
88 | 88 | ||
@@ -95,7 +95,7 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
95 | * @param defaults_d directory with the defaults | 95 | * @param defaults_d directory with the defaults |
96 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 96 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
97 | */ | 97 | */ |
98 | int | 98 | enum GNUNET_GenericReturnValue |
99 | GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, | 99 | GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, |
100 | const char *defaults_d); | 100 | const char *defaults_d); |
101 | 101 | ||
@@ -120,7 +120,7 @@ GNUNET_CONFIGURATION_default (void); | |||
120 | * @param filename name of the configuration file | 120 | * @param filename name of the configuration file |
121 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 121 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
122 | */ | 122 | */ |
123 | int | 123 | enum GNUNET_GenericReturnValue |
124 | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | 124 | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, |
125 | const char *filename); | 125 | const char *filename); |
126 | 126 | ||
@@ -149,7 +149,7 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
149 | * when we come across them | 149 | * when we come across them |
150 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 150 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
151 | */ | 151 | */ |
152 | int | 152 | enum GNUNET_GenericReturnValue |
153 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | 153 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, |
154 | const char *mem, | 154 | const char *mem, |
155 | size_t size, | 155 | size_t size, |
@@ -163,19 +163,20 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
163 | * @param filename where to write the configuration | 163 | * @param filename where to write the configuration |
164 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 164 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
165 | */ | 165 | */ |
166 | int | 166 | enum GNUNET_GenericReturnValue |
167 | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | 167 | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, |
168 | const char *filename); | 168 | const char *filename); |
169 | 169 | ||
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Write only configuration entries that have been changed to configuration file | 172 | * Write only configuration entries that have been changed to configuration file |
173 | * | ||
173 | * @param cfg_default default configuration | 174 | * @param cfg_default default configuration |
174 | * @param cfg_new new configuration | 175 | * @param cfg_new new configuration |
175 | * @param filename where to write the configuration diff between default and new | 176 | * @param filename where to write the configuration diff between default and new |
176 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 177 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
177 | */ | 178 | */ |
178 | int | 179 | enum GNUNET_GenericReturnValue |
179 | GNUNET_CONFIGURATION_write_diffs (const struct | 180 | GNUNET_CONFIGURATION_write_diffs (const struct |
180 | GNUNET_CONFIGURATION_Handle *cfg_default, | 181 | GNUNET_CONFIGURATION_Handle *cfg_default, |
181 | const struct | 182 | const struct |
@@ -204,7 +205,7 @@ GNUNET_CONFIGURATION_get_diff (const struct | |||
204 | * @param cfg configuration to inspect | 205 | * @param cfg configuration to inspect |
205 | * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on error (i.e. last save failed) | 206 | * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on error (i.e. last save failed) |
206 | */ | 207 | */ |
207 | int | 208 | enum GNUNET_GenericReturnValue |
208 | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg); | 209 | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg); |
209 | 210 | ||
210 | 211 | ||
@@ -215,7 +216,7 @@ GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
215 | * @param cfg the configuration | 216 | * @param cfg the configuration |
216 | * @return status code | 217 | * @return status code |
217 | */ | 218 | */ |
218 | typedef int | 219 | typedef enum GNUNET_GenericReturnValue |
219 | (*GNUNET_CONFIGURATION_Callback)(void *cls, | 220 | (*GNUNET_CONFIGURATION_Callback)(void *cls, |
220 | const struct GNUNET_CONFIGURATION_Handle *cfg); | 221 | const struct GNUNET_CONFIGURATION_Handle *cfg); |
221 | 222 | ||
@@ -231,7 +232,7 @@ typedef int | |||
231 | * @return #GNUNET_SYSERR if parsing the configuration failed, | 232 | * @return #GNUNET_SYSERR if parsing the configuration failed, |
232 | * otherwise return value from @a cb. | 233 | * otherwise return value from @a cb. |
233 | */ | 234 | */ |
234 | int | 235 | enum GNUNET_GenericReturnValue |
235 | GNUNET_CONFIGURATION_parse_and_run (const char *filename, | 236 | GNUNET_CONFIGURATION_parse_and_run (const char *filename, |
236 | GNUNET_CONFIGURATION_Callback cb, | 237 | GNUNET_CONFIGURATION_Callback cb, |
237 | void *cb_cls); | 238 | void *cb_cls); |
@@ -311,7 +312,7 @@ GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
311 | * @param number where to store the numeric value of the option | 312 | * @param number where to store the numeric value of the option |
312 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 313 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
313 | */ | 314 | */ |
314 | int | 315 | enum GNUNET_GenericReturnValue |
315 | GNUNET_CONFIGURATION_get_value_number (const struct | 316 | GNUNET_CONFIGURATION_get_value_number (const struct |
316 | GNUNET_CONFIGURATION_Handle *cfg, | 317 | GNUNET_CONFIGURATION_Handle *cfg, |
317 | const char *section, | 318 | const char *section, |
@@ -328,7 +329,7 @@ GNUNET_CONFIGURATION_get_value_number (const struct | |||
328 | * @param number where to store the floating value of the option | 329 | * @param number where to store the floating value of the option |
329 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 330 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
330 | */ | 331 | */ |
331 | int | 332 | enum GNUNET_GenericReturnValue |
332 | GNUNET_CONFIGURATION_get_value_float (const struct | 333 | GNUNET_CONFIGURATION_get_value_float (const struct |
333 | GNUNET_CONFIGURATION_Handle *cfg, | 334 | GNUNET_CONFIGURATION_Handle *cfg, |
334 | const char *section, | 335 | const char *section, |
@@ -345,7 +346,7 @@ GNUNET_CONFIGURATION_get_value_float (const struct | |||
345 | * @param time set to the time value stored in the configuration | 346 | * @param time set to the time value stored in the configuration |
346 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 347 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
347 | */ | 348 | */ |
348 | int | 349 | enum GNUNET_GenericReturnValue |
349 | GNUNET_CONFIGURATION_get_value_time (const struct | 350 | GNUNET_CONFIGURATION_get_value_time (const struct |
350 | GNUNET_CONFIGURATION_Handle *cfg, | 351 | GNUNET_CONFIGURATION_Handle *cfg, |
351 | const char *section, | 352 | const char *section, |
@@ -362,7 +363,7 @@ GNUNET_CONFIGURATION_get_value_time (const struct | |||
362 | * @param size set to the size in bytes as stored in the configuration | 363 | * @param size set to the size in bytes as stored in the configuration |
363 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 364 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
364 | */ | 365 | */ |
365 | int | 366 | enum GNUNET_GenericReturnValue |
366 | GNUNET_CONFIGURATION_get_value_size (const struct | 367 | GNUNET_CONFIGURATION_get_value_size (const struct |
367 | GNUNET_CONFIGURATION_Handle *cfg, | 368 | GNUNET_CONFIGURATION_Handle *cfg, |
368 | const char *section, | 369 | const char *section, |
@@ -378,7 +379,7 @@ GNUNET_CONFIGURATION_get_value_size (const struct | |||
378 | * @param option option of interest | 379 | * @param option option of interest |
379 | * @return #GNUNET_YES if so, #GNUNET_NO if not. | 380 | * @return #GNUNET_YES if so, #GNUNET_NO if not. |
380 | */ | 381 | */ |
381 | int | 382 | enum GNUNET_GenericReturnValue |
382 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, | 383 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, |
383 | const char *section, | 384 | const char *section, |
384 | const char *option); | 385 | const char *option); |
@@ -394,12 +395,12 @@ GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
394 | * value, or NULL if option is not specified | 395 | * value, or NULL if option is not specified |
395 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 396 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
396 | */ | 397 | */ |
397 | int | 398 | enum GNUNET_GenericReturnValue |
398 | GNUNET_CONFIGURATION_get_value_string (const struct | 399 | GNUNET_CONFIGURATION_get_value_string ( |
399 | GNUNET_CONFIGURATION_Handle *cfg, | 400 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
400 | const char *section, | 401 | const char *section, |
401 | const char *option, | 402 | const char *option, |
402 | char **value); | 403 | char **value); |
403 | 404 | ||
404 | 405 | ||
405 | /** | 406 | /** |
@@ -413,7 +414,7 @@ GNUNET_CONFIGURATION_get_value_string (const struct | |||
413 | * value, or NULL if option is not specified | 414 | * value, or NULL if option is not specified |
414 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 415 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
415 | */ | 416 | */ |
416 | int | 417 | enum GNUNET_GenericReturnValue |
417 | GNUNET_CONFIGURATION_get_value_filename (const struct | 418 | GNUNET_CONFIGURATION_get_value_filename (const struct |
418 | GNUNET_CONFIGURATION_Handle *cfg, | 419 | GNUNET_CONFIGURATION_Handle *cfg, |
419 | const char *section, | 420 | const char *section, |
@@ -466,7 +467,7 @@ GNUNET_CONFIGURATION_iterate_section_values (const struct | |||
466 | * or NULL if option is not specified and no default given | 467 | * or NULL if option is not specified and no default given |
467 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 468 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
468 | */ | 469 | */ |
469 | int | 470 | enum GNUNET_GenericReturnValue |
470 | GNUNET_CONFIGURATION_get_value_choice (const struct | 471 | GNUNET_CONFIGURATION_get_value_choice (const struct |
471 | GNUNET_CONFIGURATION_Handle *cfg, | 472 | GNUNET_CONFIGURATION_Handle *cfg, |
472 | const char *section, | 473 | const char *section, |
@@ -483,7 +484,7 @@ GNUNET_CONFIGURATION_get_value_choice (const struct | |||
483 | * @param option option of interest | 484 | * @param option option of interest |
484 | * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET_SYSERR | 485 | * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET_SYSERR |
485 | */ | 486 | */ |
486 | int | 487 | enum GNUNET_GenericReturnValue |
487 | GNUNET_CONFIGURATION_get_value_yesno (const struct | 488 | GNUNET_CONFIGURATION_get_value_yesno (const struct |
488 | GNUNET_CONFIGURATION_Handle *cfg, | 489 | GNUNET_CONFIGURATION_Handle *cfg, |
489 | const char *section, | 490 | const char *section, |
@@ -502,7 +503,7 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct | |||
502 | * #GNUNET_NO is the value does not exist | 503 | * #GNUNET_NO is the value does not exist |
503 | * #GNUNET_SYSERR on decoding error | 504 | * #GNUNET_SYSERR on decoding error |
504 | */ | 505 | */ |
505 | int | 506 | enum GNUNET_GenericReturnValue |
506 | GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, | 507 | GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, |
507 | const char *section, | 508 | const char *section, |
508 | const char *option, | 509 | const char *option, |
@@ -527,9 +528,9 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
527 | * @return $-expanded string | 528 | * @return $-expanded string |
528 | */ | 529 | */ |
529 | char * | 530 | char * |
530 | GNUNET_CONFIGURATION_expand_dollar (const struct | 531 | GNUNET_CONFIGURATION_expand_dollar ( |
531 | GNUNET_CONFIGURATION_Handle *cfg, | 532 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
532 | char *orig); | 533 | char *orig); |
533 | 534 | ||
534 | 535 | ||
535 | /** | 536 | /** |
@@ -573,7 +574,7 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
573 | * @return #GNUNET_OK on success, | 574 | * @return #GNUNET_OK on success, |
574 | * #GNUNET_SYSERR if the filename is not in the list | 575 | * #GNUNET_SYSERR if the filename is not in the list |
575 | */ | 576 | */ |
576 | int | 577 | enum GNUNET_GenericReturnValue |
577 | GNUNET_CONFIGURATION_remove_value_filename (struct | 578 | GNUNET_CONFIGURATION_remove_value_filename (struct |
578 | GNUNET_CONFIGURATION_Handle *cfg, | 579 | GNUNET_CONFIGURATION_Handle *cfg, |
579 | const char *section, | 580 | const char *section, |
@@ -592,7 +593,7 @@ GNUNET_CONFIGURATION_remove_value_filename (struct | |||
592 | * @return #GNUNET_OK on success, | 593 | * @return #GNUNET_OK on success, |
593 | * #GNUNET_SYSERR if the filename already in the list | 594 | * #GNUNET_SYSERR if the filename already in the list |
594 | */ | 595 | */ |
595 | int | 596 | enum GNUNET_GenericReturnValue |
596 | GNUNET_CONFIGURATION_append_value_filename (struct | 597 | GNUNET_CONFIGURATION_append_value_filename (struct |
597 | GNUNET_CONFIGURATION_Handle *cfg, | 598 | GNUNET_CONFIGURATION_Handle *cfg, |
598 | const char *section, | 599 | const char *section, |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 6dc56f0e4..5521dad3c 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -1023,7 +1023,7 @@ GNUNET_CRYPTO_hmac_derive_key ( | |||
1023 | * @param ... pair of void * & size_t for context chunks, terminated by NULL | 1023 | * @param ... pair of void * & size_t for context chunks, terminated by NULL |
1024 | * @return #GNUNET_YES on success | 1024 | * @return #GNUNET_YES on success |
1025 | */ | 1025 | */ |
1026 | int | 1026 | enum GNUNET_GenericReturnValue |
1027 | GNUNET_CRYPTO_hkdf (void *result, | 1027 | GNUNET_CRYPTO_hkdf (void *result, |
1028 | size_t out_len, | 1028 | size_t out_len, |
1029 | int xtr_algo, | 1029 | int xtr_algo, |
@@ -1049,7 +1049,7 @@ GNUNET_CRYPTO_hkdf (void *result, | |||
1049 | * @param argp va_list of void * & size_t pairs for context chunks | 1049 | * @param argp va_list of void * & size_t pairs for context chunks |
1050 | * @return #GNUNET_YES on success | 1050 | * @return #GNUNET_YES on success |
1051 | */ | 1051 | */ |
1052 | int | 1052 | enum GNUNET_GenericReturnValue |
1053 | GNUNET_CRYPTO_hkdf_v (void *result, | 1053 | GNUNET_CRYPTO_hkdf_v (void *result, |
1054 | size_t out_len, | 1054 | size_t out_len, |
1055 | int xtr_algo, | 1055 | int xtr_algo, |
@@ -1072,7 +1072,7 @@ GNUNET_CRYPTO_hkdf_v (void *result, | |||
1072 | * @param argp va_list of void * & size_t pairs for context chunks | 1072 | * @param argp va_list of void * & size_t pairs for context chunks |
1073 | * @return #GNUNET_YES on success | 1073 | * @return #GNUNET_YES on success |
1074 | */ | 1074 | */ |
1075 | int | 1075 | enum GNUNET_GenericReturnValue |
1076 | GNUNET_CRYPTO_kdf_v (void *result, | 1076 | GNUNET_CRYPTO_kdf_v (void *result, |
1077 | size_t out_len, | 1077 | size_t out_len, |
1078 | const void *xts, | 1078 | const void *xts, |
@@ -1116,7 +1116,7 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, | |||
1116 | * @param ... void * & size_t pairs for context chunks | 1116 | * @param ... void * & size_t pairs for context chunks |
1117 | * @return #GNUNET_YES on success | 1117 | * @return #GNUNET_YES on success |
1118 | */ | 1118 | */ |
1119 | int | 1119 | enum GNUNET_GenericReturnValue |
1120 | GNUNET_CRYPTO_kdf (void *result, | 1120 | GNUNET_CRYPTO_kdf (void *result, |
1121 | size_t out_len, | 1121 | size_t out_len, |
1122 | const void *xts, | 1122 | const void *xts, |
@@ -1215,7 +1215,7 @@ GNUNET_CRYPTO_eddsa_public_key_to_string ( | |||
1215 | * @param pub where to store the public key | 1215 | * @param pub where to store the public key |
1216 | * @return #GNUNET_OK on success | 1216 | * @return #GNUNET_OK on success |
1217 | */ | 1217 | */ |
1218 | int | 1218 | enum GNUNET_GenericReturnValue |
1219 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( | 1219 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( |
1220 | const char *enc, | 1220 | const char *enc, |
1221 | size_t enclen, | 1221 | size_t enclen, |
@@ -1245,7 +1245,7 @@ GNUNET_CRYPTO_eddsa_private_key_from_string ( | |||
1245 | * @param pub where to store the public key | 1245 | * @param pub where to store the public key |
1246 | * @return #GNUNET_OK on success | 1246 | * @return #GNUNET_OK on success |
1247 | */ | 1247 | */ |
1248 | int | 1248 | enum GNUNET_GenericReturnValue |
1249 | GNUNET_CRYPTO_eddsa_public_key_from_string ( | 1249 | GNUNET_CRYPTO_eddsa_public_key_from_string ( |
1250 | const char *enc, | 1250 | const char *enc, |
1251 | size_t enclen, | 1251 | size_t enclen, |
@@ -1267,7 +1267,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string ( | |||
1267 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but | 1267 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but |
1268 | * we found an existing file, #GNUNET_SYSERR on failure | 1268 | * we found an existing file, #GNUNET_SYSERR on failure |
1269 | */ | 1269 | */ |
1270 | int | 1270 | enum GNUNET_GenericReturnValue |
1271 | GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, | 1271 | GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, |
1272 | int do_create, | 1272 | int do_create, |
1273 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey); | 1273 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey); |
@@ -1606,7 +1606,7 @@ GNUNET_CRYPTO_ecc_dlog_release (struct GNUNET_CRYPTO_EccDlogContext *dlc); | |||
1606 | * @param key_material where to write the key material (xyG) | 1606 | * @param key_material where to write the key material (xyG) |
1607 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1607 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1608 | */ | 1608 | */ |
1609 | int | 1609 | enum GNUNET_GenericReturnValue |
1610 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1610 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1611 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1611 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1612 | struct GNUNET_HashCode *key_material); | 1612 | struct GNUNET_HashCode *key_material); |
@@ -1622,7 +1622,7 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1622 | * @param key_material where to write the key material H(h(x)yG) | 1622 | * @param key_material where to write the key material H(h(x)yG) |
1623 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1623 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1624 | */ | 1624 | */ |
1625 | int | 1625 | enum GNUNET_GenericReturnValue |
1626 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1626 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1627 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1627 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1628 | struct GNUNET_HashCode *key_material); | 1628 | struct GNUNET_HashCode *key_material); |
@@ -1637,7 +1637,7 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1637 | * @param key_material where to write the key material H(h(x)yG) | 1637 | * @param key_material where to write the key material H(h(x)yG) |
1638 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1638 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1639 | */ | 1639 | */ |
1640 | int | 1640 | enum GNUNET_GenericReturnValue |
1641 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1641 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1642 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1642 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1643 | struct GNUNET_HashCode *key_material); | 1643 | struct GNUNET_HashCode *key_material); |
@@ -1653,7 +1653,7 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1653 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | 1653 | * @param key_material where to write the key material H(yX)=H(h(x)yG) |
1654 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1654 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1655 | */ | 1655 | */ |
1656 | int | 1656 | enum GNUNET_GenericReturnValue |
1657 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1657 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1658 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 1658 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1659 | struct GNUNET_HashCode *key_material); | 1659 | struct GNUNET_HashCode *key_material); |
@@ -1668,7 +1668,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1668 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | 1668 | * @param key_material where to write the key material H(yX)=H(h(x)yG) |
1669 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1669 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1670 | */ | 1670 | */ |
1671 | int | 1671 | enum GNUNET_GenericReturnValue |
1672 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1672 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1673 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1673 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1674 | struct GNUNET_HashCode *key_material); | 1674 | struct GNUNET_HashCode *key_material); |
@@ -1689,7 +1689,7 @@ GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1689 | * @param[out] sig where to write the signature | 1689 | * @param[out] sig where to write the signature |
1690 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1690 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1691 | */ | 1691 | */ |
1692 | int | 1692 | enum GNUNET_GenericReturnValue |
1693 | GNUNET_CRYPTO_eddsa_sign_ ( | 1693 | GNUNET_CRYPTO_eddsa_sign_ ( |
1694 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1694 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1695 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1695 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -1736,7 +1736,7 @@ GNUNET_CRYPTO_eddsa_sign_ ( | |||
1736 | * @param[out] sig where to write the signature | 1736 | * @param[out] sig where to write the signature |
1737 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1737 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1738 | */ | 1738 | */ |
1739 | int | 1739 | enum GNUNET_GenericReturnValue |
1740 | GNUNET_CRYPTO_ecdsa_sign_ ( | 1740 | GNUNET_CRYPTO_ecdsa_sign_ ( |
1741 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1741 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1742 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1742 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -2333,7 +2333,7 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
2333 | * @param public_key public key of the signer | 2333 | * @param public_key public key of the signer |
2334 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature | 2334 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature |
2335 | */ | 2335 | */ |
2336 | int | 2336 | enum GNUNET_GenericReturnValue |
2337 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | 2337 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, |
2338 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 2338 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2339 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); | 2339 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); |
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 3f29dc2e4..e45ab84f4 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -251,7 +251,7 @@ enum GNUNET_DISK_PipeEnd | |||
251 | * @param h handle to check | 251 | * @param h handle to check |
252 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid | 252 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid |
253 | */ | 253 | */ |
254 | int | 254 | enum GNUNET_GenericReturnValue |
255 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); | 255 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); |
256 | 256 | ||
257 | 257 | ||
@@ -263,7 +263,7 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); | |||
263 | * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something | 263 | * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something |
264 | * else (will print an error message in that case, too). | 264 | * else (will print an error message in that case, too). |
265 | */ | 265 | */ |
266 | int | 266 | enum GNUNET_GenericReturnValue |
267 | GNUNET_DISK_file_test (const char *fil); | 267 | GNUNET_DISK_file_test (const char *fil); |
268 | 268 | ||
269 | 269 | ||
@@ -304,7 +304,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, | |||
304 | * and return #GNUNET_SYSERR for directories. | 304 | * and return #GNUNET_SYSERR for directories. |
305 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 305 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
306 | */ | 306 | */ |
307 | int | 307 | enum GNUNET_GenericReturnValue |
308 | GNUNET_DISK_file_size (const char *filename, | 308 | GNUNET_DISK_file_size (const char *filename, |
309 | uint64_t *size, | 309 | uint64_t *size, |
310 | int include_symbolic_links, | 310 | int include_symbolic_links, |
@@ -326,7 +326,7 @@ GNUNET_DISK_file_size (const char *filename, | |||
326 | * @param ino set to the inode ID | 326 | * @param ino set to the inode ID |
327 | * @return #GNUNET_OK on success | 327 | * @return #GNUNET_OK on success |
328 | */ | 328 | */ |
329 | int | 329 | enum GNUNET_GenericReturnValue |
330 | GNUNET_DISK_file_get_identifiers (const char *filename, | 330 | GNUNET_DISK_file_get_identifiers (const char *filename, |
331 | uint64_t *dev, | 331 | uint64_t *dev, |
332 | uint64_t *ino); | 332 | uint64_t *ino); |
@@ -385,7 +385,7 @@ GNUNET_DISK_file_open (const char *fn, | |||
385 | * @param size where to write size of the file | 385 | * @param size where to write size of the file |
386 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 386 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
387 | */ | 387 | */ |
388 | int | 388 | enum GNUNET_GenericReturnValue |
389 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | 389 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
390 | off_t *size); | 390 | off_t *size); |
391 | 391 | ||
@@ -447,7 +447,7 @@ GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, | |||
447 | * @param p pipe | 447 | * @param p pipe |
448 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 448 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
449 | */ | 449 | */ |
450 | int | 450 | enum GNUNET_GenericReturnValue |
451 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | 451 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); |
452 | 452 | ||
453 | 453 | ||
@@ -458,7 +458,7 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | |||
458 | * @param end which end of the pipe to close | 458 | * @param end which end of the pipe to close |
459 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 459 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
460 | */ | 460 | */ |
461 | int | 461 | enum GNUNET_GenericReturnValue |
462 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, | 462 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, |
463 | enum GNUNET_DISK_PipeEnd end); | 463 | enum GNUNET_DISK_PipeEnd end); |
464 | 464 | ||
@@ -485,7 +485,7 @@ GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, | |||
485 | * @param h file handle | 485 | * @param h file handle |
486 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 486 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
487 | */ | 487 | */ |
488 | int | 488 | enum GNUNET_GenericReturnValue |
489 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); | 489 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); |
490 | 490 | ||
491 | 491 | ||
@@ -609,19 +609,22 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, | |||
609 | 609 | ||
610 | 610 | ||
611 | /** | 611 | /** |
612 | * Write a buffer to a file. If the file is longer than | 612 | * Write a buffer to a file atomically. The directory is created if |
613 | * the given buffer size, it will be truncated. | 613 | * necessary. Fail if @a filename already exists or if not exactly @a buf |
614 | * with @a buf_size bytes could be written to @a filename. | ||
614 | * | 615 | * |
615 | * @param fn file name | 616 | * @param fn file name |
616 | * @param buffer the data to write | 617 | * @param buf the data to write |
617 | * @param n number of bytes to write | 618 | * @param buf_size number of bytes to write from @a buf |
618 | * @param mode file permissions | 619 | * @param mode file permissions |
619 | * @return number of bytes written on success, #GNUNET_SYSERR on error | 620 | * @return #GNUNET_OK on success, |
621 | * #GNUNET_NO if a file existed under @a filename | ||
622 | * #GNUNET_SYSERR on failure | ||
620 | */ | 623 | */ |
621 | ssize_t | 624 | enum GNUNET_GenericReturnValue |
622 | GNUNET_DISK_fn_write (const char *fn, | 625 | GNUNET_DISK_fn_write (const char *fn, |
623 | const void *buffer, | 626 | const void *buf, |
624 | size_t n, | 627 | size_t buf_size, |
625 | enum GNUNET_DISK_AccessPermissions mode); | 628 | enum GNUNET_DISK_AccessPermissions mode); |
626 | 629 | ||
627 | 630 | ||
@@ -632,7 +635,7 @@ GNUNET_DISK_fn_write (const char *fn, | |||
632 | * @param dst destination file name | 635 | * @param dst destination file name |
633 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 636 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
634 | */ | 637 | */ |
635 | int | 638 | enum GNUNET_GenericReturnValue |
636 | GNUNET_DISK_file_copy (const char *src, | 639 | GNUNET_DISK_file_copy (const char *src, |
637 | const char *dst); | 640 | const char *dst); |
638 | 641 | ||
@@ -659,7 +662,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
659 | * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, | 662 | * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, |
660 | * #GNUNET_NO if directory exists but is not writeable | 663 | * #GNUNET_NO if directory exists but is not writeable |
661 | */ | 664 | */ |
662 | int | 665 | enum GNUNET_GenericReturnValue |
663 | GNUNET_DISK_directory_create_for_file (const char *filename); | 666 | GNUNET_DISK_directory_create_for_file (const char *filename); |
664 | 667 | ||
665 | 668 | ||
@@ -675,8 +678,9 @@ GNUNET_DISK_directory_create_for_file (const char *filename); | |||
675 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it | 678 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it |
676 | * does not exist or `stat`ed | 679 | * does not exist or `stat`ed |
677 | */ | 680 | */ |
678 | int | 681 | enum GNUNET_GenericReturnValue |
679 | GNUNET_DISK_directory_test (const char *fil, int is_readable); | 682 | GNUNET_DISK_directory_test (const char *fil, |
683 | int is_readable); | ||
680 | 684 | ||
681 | 685 | ||
682 | /** | 686 | /** |
@@ -685,7 +689,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable); | |||
685 | * @param filename the file to remove | 689 | * @param filename the file to remove |
686 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 690 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
687 | */ | 691 | */ |
688 | int | 692 | enum GNUNET_GenericReturnValue |
689 | GNUNET_DISK_directory_remove (const char *filename); | 693 | GNUNET_DISK_directory_remove (const char *filename); |
690 | 694 | ||
691 | 695 | ||
@@ -707,7 +711,7 @@ GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, | |||
707 | * @param dir the directory to create | 711 | * @param dir the directory to create |
708 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise | 712 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise |
709 | */ | 713 | */ |
710 | int | 714 | enum GNUNET_GenericReturnValue |
711 | GNUNET_DISK_directory_create (const char *dir); | 715 | GNUNET_DISK_directory_create (const char *dir); |
712 | 716 | ||
713 | 717 | ||
@@ -725,7 +729,7 @@ GNUNET_DISK_filename_canonicalize (char *fn); | |||
725 | * @param user new owner of the file | 729 | * @param user new owner of the file |
726 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 730 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
727 | */ | 731 | */ |
728 | int | 732 | enum GNUNET_GenericReturnValue |
729 | GNUNET_DISK_file_change_owner (const char *filename, | 733 | GNUNET_DISK_file_change_owner (const char *filename, |
730 | const char *user); | 734 | const char *user); |
731 | 735 | ||
@@ -758,7 +762,7 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | |||
758 | * @param h mapping handle | 762 | * @param h mapping handle |
759 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 763 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
760 | */ | 764 | */ |
761 | int | 765 | enum GNUNET_GenericReturnValue |
762 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | 766 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); |
763 | 767 | ||
764 | 768 | ||
@@ -768,7 +772,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | |||
768 | * @param h handle to an open file | 772 | * @param h handle to an open file |
769 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 773 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
770 | */ | 774 | */ |
771 | int | 775 | enum GNUNET_GenericReturnValue |
772 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); | 776 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); |
773 | 777 | ||
774 | 778 | ||
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index b828e2db7..158f1d83b 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -497,13 +497,11 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task); | |||
497 | * @param priority priority to use for the task | 497 | * @param priority priority to use for the task |
498 | */ | 498 | */ |
499 | void | 499 | void |
500 | GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback | 500 | GNUNET_SCHEDULER_add_with_reason_and_priority ( |
501 | task, | 501 | GNUNET_SCHEDULER_TaskCallback task, |
502 | void *task_cls, | 502 | void *task_cls, |
503 | enum GNUNET_SCHEDULER_Reason | 503 | enum GNUNET_SCHEDULER_Reason reason, |
504 | reason, | 504 | enum GNUNET_SCHEDULER_Priority priority); |
505 | enum GNUNET_SCHEDULER_Priority | ||
506 | priority); | ||
507 | 505 | ||
508 | 506 | ||
509 | /** | 507 | /** |
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am index 836a6b5d9..8ffa85ddb 100644 --- a/src/namecache/Makefile.am +++ b/src/namecache/Makefile.am | |||
@@ -148,6 +148,7 @@ test_namecache_api_cache_block_SOURCES = \ | |||
148 | test_namecache_api_cache_block.c | 148 | test_namecache_api_cache_block.c |
149 | test_namecache_api_cache_block_LDADD = \ | 149 | test_namecache_api_cache_block_LDADD = \ |
150 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 150 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
151 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
151 | libgnunetnamecache.la \ | 152 | libgnunetnamecache.la \ |
152 | $(top_builddir)/src/testing/libgnunettesting.la \ | 153 | $(top_builddir)/src/testing/libgnunettesting.la \ |
153 | $(top_builddir)/src/util/libgnunetutil.la | 154 | $(top_builddir)/src/util/libgnunetutil.la |
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 3a92f98c9..df4e5d662 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -268,6 +268,7 @@ test_namestore_api_store_update_flat_SOURCES = \ | |||
268 | test_namestore_api_store_update_flat_LDADD = \ | 268 | test_namestore_api_store_update_flat_LDADD = \ |
269 | $(top_builddir)/src/testing/libgnunettesting.la \ | 269 | $(top_builddir)/src/testing/libgnunettesting.la \ |
270 | $(top_builddir)/src/util/libgnunetutil.la \ | 270 | $(top_builddir)/src/util/libgnunetutil.la \ |
271 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
271 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 272 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
272 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 273 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
273 | libgnunetnamestore.la | 274 | libgnunetnamestore.la |
@@ -277,6 +278,7 @@ test_namestore_api_store_update_sqlite_SOURCES = \ | |||
277 | test_namestore_api_store_update_sqlite_LDADD = \ | 278 | test_namestore_api_store_update_sqlite_LDADD = \ |
278 | $(top_builddir)/src/testing/libgnunettesting.la \ | 279 | $(top_builddir)/src/testing/libgnunettesting.la \ |
279 | $(top_builddir)/src/util/libgnunetutil.la \ | 280 | $(top_builddir)/src/util/libgnunetutil.la \ |
281 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
280 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 282 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
281 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 283 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
282 | libgnunetnamestore.la | 284 | libgnunetnamestore.la |
@@ -286,6 +288,7 @@ test_namestore_api_store_update_postgres_SOURCES = \ | |||
286 | test_namestore_api_store_update_postgres_LDADD = \ | 288 | test_namestore_api_store_update_postgres_LDADD = \ |
287 | $(top_builddir)/src/testing/libgnunettesting.la \ | 289 | $(top_builddir)/src/testing/libgnunettesting.la \ |
288 | $(top_builddir)/src/util/libgnunetutil.la \ | 290 | $(top_builddir)/src/util/libgnunetutil.la \ |
291 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
289 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 292 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
290 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 293 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
291 | libgnunetnamestore.la | 294 | libgnunetnamestore.la |
@@ -294,6 +297,7 @@ test_namestore_api_lookup_public_flat_SOURCES = \ | |||
294 | test_namestore_api_lookup_public.c | 297 | test_namestore_api_lookup_public.c |
295 | test_namestore_api_lookup_public_flat_LDADD = \ | 298 | test_namestore_api_lookup_public_flat_LDADD = \ |
296 | $(top_builddir)/src/testing/libgnunettesting.la \ | 299 | $(top_builddir)/src/testing/libgnunettesting.la \ |
300 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
297 | $(top_builddir)/src/util/libgnunetutil.la \ | 301 | $(top_builddir)/src/util/libgnunetutil.la \ |
298 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 302 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
299 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 303 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -304,6 +308,7 @@ test_namestore_api_lookup_public_sqlite_SOURCES = \ | |||
304 | test_namestore_api_lookup_public_sqlite_LDADD = \ | 308 | test_namestore_api_lookup_public_sqlite_LDADD = \ |
305 | $(top_builddir)/src/testing/libgnunettesting.la \ | 309 | $(top_builddir)/src/testing/libgnunettesting.la \ |
306 | $(top_builddir)/src/util/libgnunetutil.la \ | 310 | $(top_builddir)/src/util/libgnunetutil.la \ |
311 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
307 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 312 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
308 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 313 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
309 | libgnunetnamestore.la | 314 | libgnunetnamestore.la |
@@ -313,6 +318,7 @@ test_namestore_api_lookup_public_postgres_SOURCES = \ | |||
313 | test_namestore_api_lookup_public_postgres_LDADD = \ | 318 | test_namestore_api_lookup_public_postgres_LDADD = \ |
314 | $(top_builddir)/src/testing/libgnunettesting.la \ | 319 | $(top_builddir)/src/testing/libgnunettesting.la \ |
315 | $(top_builddir)/src/util/libgnunetutil.la \ | 320 | $(top_builddir)/src/util/libgnunetutil.la \ |
321 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
316 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 322 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
317 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 323 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
318 | libgnunetnamestore.la | 324 | libgnunetnamestore.la |
@@ -322,6 +328,7 @@ test_namestore_api_lookup_nick_sqlite_SOURCES = \ | |||
322 | test_namestore_api_lookup_nick_sqlite_LDADD = \ | 328 | test_namestore_api_lookup_nick_sqlite_LDADD = \ |
323 | $(top_builddir)/src/testing/libgnunettesting.la \ | 329 | $(top_builddir)/src/testing/libgnunettesting.la \ |
324 | $(top_builddir)/src/util/libgnunetutil.la \ | 330 | $(top_builddir)/src/util/libgnunetutil.la \ |
331 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
325 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 332 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
326 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 333 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
327 | libgnunetnamestore.la | 334 | libgnunetnamestore.la |
@@ -331,6 +338,7 @@ test_namestore_api_lookup_nick_postgres_SOURCES = \ | |||
331 | test_namestore_api_lookup_nick_postgres_LDADD = \ | 338 | test_namestore_api_lookup_nick_postgres_LDADD = \ |
332 | $(top_builddir)/src/testing/libgnunettesting.la \ | 339 | $(top_builddir)/src/testing/libgnunettesting.la \ |
333 | $(top_builddir)/src/util/libgnunetutil.la \ | 340 | $(top_builddir)/src/util/libgnunetutil.la \ |
341 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
334 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 342 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
335 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 343 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
336 | libgnunetnamestore.la | 344 | libgnunetnamestore.la |
@@ -339,6 +347,7 @@ test_namestore_api_lookup_nick_flat_SOURCES = \ | |||
339 | test_namestore_api_lookup_nick.c | 347 | test_namestore_api_lookup_nick.c |
340 | test_namestore_api_lookup_nick_flat_LDADD = \ | 348 | test_namestore_api_lookup_nick_flat_LDADD = \ |
341 | $(top_builddir)/src/testing/libgnunettesting.la \ | 349 | $(top_builddir)/src/testing/libgnunettesting.la \ |
350 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
342 | $(top_builddir)/src/util/libgnunetutil.la \ | 351 | $(top_builddir)/src/util/libgnunetutil.la \ |
343 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 352 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
344 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 353 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -348,6 +357,7 @@ test_namestore_api_lookup_private_flat_SOURCES = \ | |||
348 | test_namestore_api_lookup_private.c | 357 | test_namestore_api_lookup_private.c |
349 | test_namestore_api_lookup_private_flat_LDADD = \ | 358 | test_namestore_api_lookup_private_flat_LDADD = \ |
350 | $(top_builddir)/src/testing/libgnunettesting.la \ | 359 | $(top_builddir)/src/testing/libgnunettesting.la \ |
360 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
351 | $(top_builddir)/src/util/libgnunetutil.la \ | 361 | $(top_builddir)/src/util/libgnunetutil.la \ |
352 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 362 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
353 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 363 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -357,6 +367,7 @@ test_namestore_api_lookup_private_sqlite_SOURCES = \ | |||
357 | test_namestore_api_lookup_private.c | 367 | test_namestore_api_lookup_private.c |
358 | test_namestore_api_lookup_private_sqlite_LDADD = \ | 368 | test_namestore_api_lookup_private_sqlite_LDADD = \ |
359 | $(top_builddir)/src/testing/libgnunettesting.la \ | 369 | $(top_builddir)/src/testing/libgnunettesting.la \ |
370 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
360 | $(top_builddir)/src/util/libgnunetutil.la \ | 371 | $(top_builddir)/src/util/libgnunetutil.la \ |
361 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 372 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
362 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 373 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -365,6 +376,7 @@ test_namestore_api_lookup_private_sqlite_LDADD = \ | |||
365 | test_namestore_api_lookup_private_postgres_SOURCES = \ | 376 | test_namestore_api_lookup_private_postgres_SOURCES = \ |
366 | test_namestore_api_lookup_private.c | 377 | test_namestore_api_lookup_private.c |
367 | test_namestore_api_lookup_private_postgres_LDADD = \ | 378 | test_namestore_api_lookup_private_postgres_LDADD = \ |
379 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
368 | $(top_builddir)/src/testing/libgnunettesting.la \ | 380 | $(top_builddir)/src/testing/libgnunettesting.la \ |
369 | $(top_builddir)/src/util/libgnunetutil.la \ | 381 | $(top_builddir)/src/util/libgnunetutil.la \ |
370 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 382 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -375,6 +387,7 @@ test_namestore_api_lookup_shadow_flat_SOURCES = \ | |||
375 | test_namestore_api_lookup_shadow.c | 387 | test_namestore_api_lookup_shadow.c |
376 | test_namestore_api_lookup_shadow_flat_LDADD = \ | 388 | test_namestore_api_lookup_shadow_flat_LDADD = \ |
377 | $(top_builddir)/src/testing/libgnunettesting.la \ | 389 | $(top_builddir)/src/testing/libgnunettesting.la \ |
390 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
378 | $(top_builddir)/src/util/libgnunetutil.la \ | 391 | $(top_builddir)/src/util/libgnunetutil.la \ |
379 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 392 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
380 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 393 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -385,6 +398,7 @@ test_namestore_api_lookup_shadow_sqlite_SOURCES = \ | |||
385 | test_namestore_api_lookup_shadow_sqlite_LDADD = \ | 398 | test_namestore_api_lookup_shadow_sqlite_LDADD = \ |
386 | $(top_builddir)/src/testing/libgnunettesting.la \ | 399 | $(top_builddir)/src/testing/libgnunettesting.la \ |
387 | $(top_builddir)/src/util/libgnunetutil.la \ | 400 | $(top_builddir)/src/util/libgnunetutil.la \ |
401 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
388 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 402 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
389 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 403 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
390 | libgnunetnamestore.la | 404 | libgnunetnamestore.la |
@@ -394,6 +408,7 @@ test_namestore_api_lookup_shadow_postgres_SOURCES = \ | |||
394 | test_namestore_api_lookup_shadow_postgres_LDADD = \ | 408 | test_namestore_api_lookup_shadow_postgres_LDADD = \ |
395 | $(top_builddir)/src/testing/libgnunettesting.la \ | 409 | $(top_builddir)/src/testing/libgnunettesting.la \ |
396 | $(top_builddir)/src/util/libgnunetutil.la \ | 410 | $(top_builddir)/src/util/libgnunetutil.la \ |
411 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
397 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 412 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
398 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 413 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
399 | libgnunetnamestore.la | 414 | libgnunetnamestore.la |
@@ -403,6 +418,7 @@ test_namestore_api_lookup_shadow_filter_flat_SOURCES = \ | |||
403 | test_namestore_api_lookup_shadow_filter_flat_LDADD = \ | 418 | test_namestore_api_lookup_shadow_filter_flat_LDADD = \ |
404 | $(top_builddir)/src/testing/libgnunettesting.la \ | 419 | $(top_builddir)/src/testing/libgnunettesting.la \ |
405 | $(top_builddir)/src/util/libgnunetutil.la \ | 420 | $(top_builddir)/src/util/libgnunetutil.la \ |
421 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
406 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 422 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
407 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 423 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
408 | libgnunetnamestore.la | 424 | libgnunetnamestore.la |
@@ -411,6 +427,7 @@ test_namestore_api_lookup_shadow_filter_sqlite_SOURCES = \ | |||
411 | test_namestore_api_lookup_shadow_filter.c | 427 | test_namestore_api_lookup_shadow_filter.c |
412 | test_namestore_api_lookup_shadow_filter_sqlite_LDADD = \ | 428 | test_namestore_api_lookup_shadow_filter_sqlite_LDADD = \ |
413 | $(top_builddir)/src/testing/libgnunettesting.la \ | 429 | $(top_builddir)/src/testing/libgnunettesting.la \ |
430 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
414 | $(top_builddir)/src/util/libgnunetutil.la \ | 431 | $(top_builddir)/src/util/libgnunetutil.la \ |
415 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 432 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
416 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 433 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -419,6 +436,7 @@ test_namestore_api_lookup_shadow_filter_postgres_SOURCES = \ | |||
419 | test_namestore_api_lookup_shadow_filter.c | 436 | test_namestore_api_lookup_shadow_filter.c |
420 | test_namestore_api_lookup_shadow_filter_postgres_LDADD = \ | 437 | test_namestore_api_lookup_shadow_filter_postgres_LDADD = \ |
421 | $(top_builddir)/src/testing/libgnunettesting.la \ | 438 | $(top_builddir)/src/testing/libgnunettesting.la \ |
439 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
422 | $(top_builddir)/src/util/libgnunetutil.la \ | 440 | $(top_builddir)/src/util/libgnunetutil.la \ |
423 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 441 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
424 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 442 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
@@ -427,6 +445,7 @@ test_namestore_api_lookup_shadow_filter_postgres_LDADD = \ | |||
427 | test_namestore_api_remove_sqlite_SOURCES = \ | 445 | test_namestore_api_remove_sqlite_SOURCES = \ |
428 | test_namestore_api_remove.c | 446 | test_namestore_api_remove.c |
429 | test_namestore_api_remove_sqlite_LDADD = \ | 447 | test_namestore_api_remove_sqlite_LDADD = \ |
448 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
430 | $(top_builddir)/src/testing/libgnunettesting.la \ | 449 | $(top_builddir)/src/testing/libgnunettesting.la \ |
431 | $(top_builddir)/src/util/libgnunetutil.la \ | 450 | $(top_builddir)/src/util/libgnunetutil.la \ |
432 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 451 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -435,6 +454,7 @@ test_namestore_api_remove_sqlite_LDADD = \ | |||
435 | test_namestore_api_remove_postgres_SOURCES = \ | 454 | test_namestore_api_remove_postgres_SOURCES = \ |
436 | test_namestore_api_remove.c | 455 | test_namestore_api_remove.c |
437 | test_namestore_api_remove_postgres_LDADD = \ | 456 | test_namestore_api_remove_postgres_LDADD = \ |
457 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
438 | $(top_builddir)/src/testing/libgnunettesting.la \ | 458 | $(top_builddir)/src/testing/libgnunettesting.la \ |
439 | $(top_builddir)/src/util/libgnunetutil.la \ | 459 | $(top_builddir)/src/util/libgnunetutil.la \ |
440 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 460 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -444,6 +464,7 @@ test_namestore_api_remove_flat_SOURCES = \ | |||
444 | test_namestore_api_remove.c | 464 | test_namestore_api_remove.c |
445 | test_namestore_api_remove_flat_LDADD = \ | 465 | test_namestore_api_remove_flat_LDADD = \ |
446 | $(top_builddir)/src/testing/libgnunettesting.la \ | 466 | $(top_builddir)/src/testing/libgnunettesting.la \ |
467 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
447 | $(top_builddir)/src/util/libgnunetutil.la \ | 468 | $(top_builddir)/src/util/libgnunetutil.la \ |
448 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 469 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
449 | libgnunetnamestore.la | 470 | libgnunetnamestore.la |
@@ -452,6 +473,7 @@ test_namestore_api_remove_not_existing_record_flat_SOURCES = \ | |||
452 | test_namestore_api_remove_not_existing_record.c | 473 | test_namestore_api_remove_not_existing_record.c |
453 | test_namestore_api_remove_not_existing_record_flat_LDADD = \ | 474 | test_namestore_api_remove_not_existing_record_flat_LDADD = \ |
454 | $(top_builddir)/src/testing/libgnunettesting.la \ | 475 | $(top_builddir)/src/testing/libgnunettesting.la \ |
476 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
455 | $(top_builddir)/src/util/libgnunetutil.la \ | 477 | $(top_builddir)/src/util/libgnunetutil.la \ |
456 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 478 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
457 | libgnunetnamestore.la | 479 | libgnunetnamestore.la |
@@ -461,6 +483,7 @@ test_namestore_api_remove_not_existing_record_sqlite_SOURCES = \ | |||
461 | test_namestore_api_remove_not_existing_record_sqlite_LDADD = \ | 483 | test_namestore_api_remove_not_existing_record_sqlite_LDADD = \ |
462 | $(top_builddir)/src/testing/libgnunettesting.la \ | 484 | $(top_builddir)/src/testing/libgnunettesting.la \ |
463 | $(top_builddir)/src/util/libgnunetutil.la \ | 485 | $(top_builddir)/src/util/libgnunetutil.la \ |
486 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
464 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 487 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
465 | libgnunetnamestore.la | 488 | libgnunetnamestore.la |
466 | 489 | ||
@@ -468,6 +491,7 @@ test_namestore_api_remove_not_existing_record_postgres_SOURCES = \ | |||
468 | test_namestore_api_remove_not_existing_record.c | 491 | test_namestore_api_remove_not_existing_record.c |
469 | test_namestore_api_remove_not_existing_record_postgres_LDADD = \ | 492 | test_namestore_api_remove_not_existing_record_postgres_LDADD = \ |
470 | $(top_builddir)/src/testing/libgnunettesting.la \ | 493 | $(top_builddir)/src/testing/libgnunettesting.la \ |
494 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
471 | $(top_builddir)/src/util/libgnunetutil.la \ | 495 | $(top_builddir)/src/util/libgnunetutil.la \ |
472 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 496 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
473 | libgnunetnamestore.la | 497 | libgnunetnamestore.la |
@@ -475,6 +499,7 @@ test_namestore_api_remove_not_existing_record_postgres_LDADD = \ | |||
475 | test_namestore_api_zone_to_name_flat_SOURCES = \ | 499 | test_namestore_api_zone_to_name_flat_SOURCES = \ |
476 | test_namestore_api_zone_to_name.c | 500 | test_namestore_api_zone_to_name.c |
477 | test_namestore_api_zone_to_name_flat_LDADD = \ | 501 | test_namestore_api_zone_to_name_flat_LDADD = \ |
502 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
478 | $(top_builddir)/src/testing/libgnunettesting.la \ | 503 | $(top_builddir)/src/testing/libgnunettesting.la \ |
479 | $(top_builddir)/src/util/libgnunetutil.la \ | 504 | $(top_builddir)/src/util/libgnunetutil.la \ |
480 | libgnunetnamestore.la | 505 | libgnunetnamestore.la |
@@ -482,6 +507,7 @@ test_namestore_api_zone_to_name_flat_LDADD = \ | |||
482 | test_namestore_api_zone_to_name_sqlite_SOURCES = \ | 507 | test_namestore_api_zone_to_name_sqlite_SOURCES = \ |
483 | test_namestore_api_zone_to_name.c | 508 | test_namestore_api_zone_to_name.c |
484 | test_namestore_api_zone_to_name_sqlite_LDADD = \ | 509 | test_namestore_api_zone_to_name_sqlite_LDADD = \ |
510 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
485 | $(top_builddir)/src/testing/libgnunettesting.la \ | 511 | $(top_builddir)/src/testing/libgnunettesting.la \ |
486 | $(top_builddir)/src/util/libgnunetutil.la \ | 512 | $(top_builddir)/src/util/libgnunetutil.la \ |
487 | libgnunetnamestore.la | 513 | libgnunetnamestore.la |
@@ -489,6 +515,7 @@ test_namestore_api_zone_to_name_sqlite_LDADD = \ | |||
489 | test_namestore_api_zone_to_name_postgres_SOURCES = \ | 515 | test_namestore_api_zone_to_name_postgres_SOURCES = \ |
490 | test_namestore_api_zone_to_name.c | 516 | test_namestore_api_zone_to_name.c |
491 | test_namestore_api_zone_to_name_postgres_LDADD = \ | 517 | test_namestore_api_zone_to_name_postgres_LDADD = \ |
518 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
492 | $(top_builddir)/src/testing/libgnunettesting.la \ | 519 | $(top_builddir)/src/testing/libgnunettesting.la \ |
493 | $(top_builddir)/src/util/libgnunetutil.la \ | 520 | $(top_builddir)/src/util/libgnunetutil.la \ |
494 | libgnunetnamestore.la | 521 | libgnunetnamestore.la |
@@ -498,12 +525,14 @@ test_namestore_api_monitoring_flat_SOURCES = \ | |||
498 | test_namestore_api_monitoring_flat_LDADD = \ | 525 | test_namestore_api_monitoring_flat_LDADD = \ |
499 | $(top_builddir)/src/testing/libgnunettesting.la \ | 526 | $(top_builddir)/src/testing/libgnunettesting.la \ |
500 | libgnunetnamestore.la \ | 527 | libgnunetnamestore.la \ |
528 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
501 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 529 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
502 | $(top_builddir)/src/util/libgnunetutil.la | 530 | $(top_builddir)/src/util/libgnunetutil.la |
503 | 531 | ||
504 | test_namestore_api_monitoring_sqlite_SOURCES = \ | 532 | test_namestore_api_monitoring_sqlite_SOURCES = \ |
505 | test_namestore_api_monitoring.c | 533 | test_namestore_api_monitoring.c |
506 | test_namestore_api_monitoring_sqlite_LDADD = \ | 534 | test_namestore_api_monitoring_sqlite_LDADD = \ |
535 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
507 | $(top_builddir)/src/testing/libgnunettesting.la \ | 536 | $(top_builddir)/src/testing/libgnunettesting.la \ |
508 | libgnunetnamestore.la \ | 537 | libgnunetnamestore.la \ |
509 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 538 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -513,6 +542,7 @@ test_namestore_api_monitoring_postgres_SOURCES = \ | |||
513 | test_namestore_api_monitoring.c | 542 | test_namestore_api_monitoring.c |
514 | test_namestore_api_monitoring_postgres_LDADD = \ | 543 | test_namestore_api_monitoring_postgres_LDADD = \ |
515 | $(top_builddir)/src/testing/libgnunettesting.la \ | 544 | $(top_builddir)/src/testing/libgnunettesting.la \ |
545 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
516 | libgnunetnamestore.la \ | 546 | libgnunetnamestore.la \ |
517 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 547 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
518 | $(top_builddir)/src/util/libgnunetutil.la | 548 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -521,6 +551,7 @@ test_namestore_api_monitoring_existing_flat_SOURCES = \ | |||
521 | test_namestore_api_monitoring_existing.c | 551 | test_namestore_api_monitoring_existing.c |
522 | test_namestore_api_monitoring_existing_flat_LDADD = \ | 552 | test_namestore_api_monitoring_existing_flat_LDADD = \ |
523 | $(top_builddir)/src/testing/libgnunettesting.la \ | 553 | $(top_builddir)/src/testing/libgnunettesting.la \ |
554 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
524 | libgnunetnamestore.la \ | 555 | libgnunetnamestore.la \ |
525 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 556 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
526 | $(top_builddir)/src/util/libgnunetutil.la | 557 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -529,6 +560,7 @@ test_namestore_api_monitoring_existing_sqlite_SOURCES = \ | |||
529 | test_namestore_api_monitoring_existing.c | 560 | test_namestore_api_monitoring_existing.c |
530 | test_namestore_api_monitoring_existing_sqlite_LDADD = \ | 561 | test_namestore_api_monitoring_existing_sqlite_LDADD = \ |
531 | $(top_builddir)/src/testing/libgnunettesting.la \ | 562 | $(top_builddir)/src/testing/libgnunettesting.la \ |
563 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
532 | libgnunetnamestore.la \ | 564 | libgnunetnamestore.la \ |
533 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 565 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
534 | $(top_builddir)/src/util/libgnunetutil.la | 566 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -539,12 +571,14 @@ test_namestore_api_monitoring_existing_postgres_LDADD = \ | |||
539 | $(top_builddir)/src/testing/libgnunettesting.la \ | 571 | $(top_builddir)/src/testing/libgnunettesting.la \ |
540 | libgnunetnamestore.la \ | 572 | libgnunetnamestore.la \ |
541 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 573 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
574 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
542 | $(top_builddir)/src/util/libgnunetutil.la | 575 | $(top_builddir)/src/util/libgnunetutil.la |
543 | 576 | ||
544 | test_namestore_api_zone_iteration_flat_SOURCES = \ | 577 | test_namestore_api_zone_iteration_flat_SOURCES = \ |
545 | test_namestore_api_zone_iteration.c | 578 | test_namestore_api_zone_iteration.c |
546 | test_namestore_api_zone_iteration_flat_LDADD = \ | 579 | test_namestore_api_zone_iteration_flat_LDADD = \ |
547 | $(top_builddir)/src/testing/libgnunettesting.la \ | 580 | $(top_builddir)/src/testing/libgnunettesting.la \ |
581 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
548 | $(top_builddir)/src/util/libgnunetutil.la \ | 582 | $(top_builddir)/src/util/libgnunetutil.la \ |
549 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 583 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
550 | libgnunetnamestore.la | 584 | libgnunetnamestore.la |
@@ -553,6 +587,7 @@ test_namestore_api_zone_iteration_sqlite_SOURCES = \ | |||
553 | test_namestore_api_zone_iteration.c | 587 | test_namestore_api_zone_iteration.c |
554 | test_namestore_api_zone_iteration_sqlite_LDADD = \ | 588 | test_namestore_api_zone_iteration_sqlite_LDADD = \ |
555 | $(top_builddir)/src/testing/libgnunettesting.la \ | 589 | $(top_builddir)/src/testing/libgnunettesting.la \ |
590 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
556 | $(top_builddir)/src/util/libgnunetutil.la \ | 591 | $(top_builddir)/src/util/libgnunetutil.la \ |
557 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 592 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
558 | libgnunetnamestore.la | 593 | libgnunetnamestore.la |
@@ -561,6 +596,7 @@ test_namestore_api_zone_iteration_postgres_SOURCES = \ | |||
561 | test_namestore_api_zone_iteration.c | 596 | test_namestore_api_zone_iteration.c |
562 | test_namestore_api_zone_iteration_postgres_LDADD = \ | 597 | test_namestore_api_zone_iteration_postgres_LDADD = \ |
563 | $(top_builddir)/src/testing/libgnunettesting.la \ | 598 | $(top_builddir)/src/testing/libgnunettesting.la \ |
599 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
564 | $(top_builddir)/src/util/libgnunetutil.la \ | 600 | $(top_builddir)/src/util/libgnunetutil.la \ |
565 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 601 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
566 | libgnunetnamestore.la | 602 | libgnunetnamestore.la |
@@ -570,6 +606,7 @@ perf_namestore_api_zone_iteration_postgres_SOURCES = \ | |||
570 | perf_namestore_api_zone_iteration_postgres_LDADD = \ | 606 | perf_namestore_api_zone_iteration_postgres_LDADD = \ |
571 | $(top_builddir)/src/testing/libgnunettesting.la \ | 607 | $(top_builddir)/src/testing/libgnunettesting.la \ |
572 | $(top_builddir)/src/util/libgnunetutil.la \ | 608 | $(top_builddir)/src/util/libgnunetutil.la \ |
609 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
573 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 610 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
574 | libgnunetnamestore.la | 611 | libgnunetnamestore.la |
575 | 612 | ||
@@ -577,6 +614,7 @@ perf_namestore_api_zone_iteration_sqlite_SOURCES = \ | |||
577 | perf_namestore_api_zone_iteration.c | 614 | perf_namestore_api_zone_iteration.c |
578 | perf_namestore_api_zone_iteration_sqlite_LDADD = \ | 615 | perf_namestore_api_zone_iteration_sqlite_LDADD = \ |
579 | $(top_builddir)/src/testing/libgnunettesting.la \ | 616 | $(top_builddir)/src/testing/libgnunettesting.la \ |
617 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
580 | $(top_builddir)/src/util/libgnunetutil.la \ | 618 | $(top_builddir)/src/util/libgnunetutil.la \ |
581 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 619 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
582 | libgnunetnamestore.la | 620 | libgnunetnamestore.la |
@@ -585,6 +623,7 @@ perf_namestore_api_zone_iteration_flat_SOURCES = \ | |||
585 | perf_namestore_api_zone_iteration.c | 623 | perf_namestore_api_zone_iteration.c |
586 | perf_namestore_api_zone_iteration_flat_LDADD = \ | 624 | perf_namestore_api_zone_iteration_flat_LDADD = \ |
587 | $(top_builddir)/src/testing/libgnunettesting.la \ | 625 | $(top_builddir)/src/testing/libgnunettesting.la \ |
626 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
588 | $(top_builddir)/src/util/libgnunetutil.la \ | 627 | $(top_builddir)/src/util/libgnunetutil.la \ |
589 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 628 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
590 | libgnunetnamestore.la | 629 | libgnunetnamestore.la |
@@ -594,6 +633,7 @@ test_namestore_api_zone_iteration_nick_flat_SOURCES = \ | |||
594 | test_namestore_api_zone_iteration_nick_flat_LDADD = \ | 633 | test_namestore_api_zone_iteration_nick_flat_LDADD = \ |
595 | $(top_builddir)/src/testing/libgnunettesting.la \ | 634 | $(top_builddir)/src/testing/libgnunettesting.la \ |
596 | $(top_builddir)/src/util/libgnunetutil.la \ | 635 | $(top_builddir)/src/util/libgnunetutil.la \ |
636 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
597 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 637 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
598 | libgnunetnamestore.la | 638 | libgnunetnamestore.la |
599 | 639 | ||
@@ -601,6 +641,7 @@ test_namestore_api_zone_iteration_nick_sqlite_SOURCES = \ | |||
601 | test_namestore_api_zone_iteration_nick.c | 641 | test_namestore_api_zone_iteration_nick.c |
602 | test_namestore_api_zone_iteration_nick_sqlite_LDADD = \ | 642 | test_namestore_api_zone_iteration_nick_sqlite_LDADD = \ |
603 | $(top_builddir)/src/testing/libgnunettesting.la \ | 643 | $(top_builddir)/src/testing/libgnunettesting.la \ |
644 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
604 | $(top_builddir)/src/util/libgnunetutil.la \ | 645 | $(top_builddir)/src/util/libgnunetutil.la \ |
605 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 646 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
606 | libgnunetnamestore.la | 647 | libgnunetnamestore.la |
@@ -609,6 +650,7 @@ test_namestore_api_zone_iteration_nick_postgres_SOURCES = \ | |||
609 | test_namestore_api_zone_iteration_nick.c | 650 | test_namestore_api_zone_iteration_nick.c |
610 | test_namestore_api_zone_iteration_nick_postgres_LDADD = \ | 651 | test_namestore_api_zone_iteration_nick_postgres_LDADD = \ |
611 | $(top_builddir)/src/testing/libgnunettesting.la \ | 652 | $(top_builddir)/src/testing/libgnunettesting.la \ |
653 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
612 | $(top_builddir)/src/util/libgnunetutil.la \ | 654 | $(top_builddir)/src/util/libgnunetutil.la \ |
613 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 655 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
614 | libgnunetnamestore.la | 656 | libgnunetnamestore.la |
@@ -617,6 +659,7 @@ test_namestore_api_zone_iteration_specific_zone_flat_SOURCES = \ | |||
617 | test_namestore_api_zone_iteration_specific_zone.c | 659 | test_namestore_api_zone_iteration_specific_zone.c |
618 | test_namestore_api_zone_iteration_specific_zone_flat_LDADD = \ | 660 | test_namestore_api_zone_iteration_specific_zone_flat_LDADD = \ |
619 | $(top_builddir)/src/testing/libgnunettesting.la \ | 661 | $(top_builddir)/src/testing/libgnunettesting.la \ |
662 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
620 | $(top_builddir)/src/util/libgnunetutil.la \ | 663 | $(top_builddir)/src/util/libgnunetutil.la \ |
621 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 664 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
622 | libgnunetnamestore.la | 665 | libgnunetnamestore.la |
@@ -625,6 +668,7 @@ test_namestore_api_zone_iteration_specific_zone_sqlite_SOURCES = \ | |||
625 | test_namestore_api_zone_iteration_specific_zone.c | 668 | test_namestore_api_zone_iteration_specific_zone.c |
626 | test_namestore_api_zone_iteration_specific_zone_sqlite_LDADD = \ | 669 | test_namestore_api_zone_iteration_specific_zone_sqlite_LDADD = \ |
627 | $(top_builddir)/src/testing/libgnunettesting.la \ | 670 | $(top_builddir)/src/testing/libgnunettesting.la \ |
671 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
628 | $(top_builddir)/src/util/libgnunetutil.la \ | 672 | $(top_builddir)/src/util/libgnunetutil.la \ |
629 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 673 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
630 | libgnunetnamestore.la | 674 | libgnunetnamestore.la |
@@ -633,6 +677,7 @@ test_namestore_api_zone_iteration_specific_zone_postgres_SOURCES = \ | |||
633 | test_namestore_api_zone_iteration_specific_zone.c | 677 | test_namestore_api_zone_iteration_specific_zone.c |
634 | test_namestore_api_zone_iteration_specific_zone_postgres_LDADD = \ | 678 | test_namestore_api_zone_iteration_specific_zone_postgres_LDADD = \ |
635 | $(top_builddir)/src/testing/libgnunettesting.la \ | 679 | $(top_builddir)/src/testing/libgnunettesting.la \ |
680 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
636 | $(top_builddir)/src/util/libgnunetutil.la \ | 681 | $(top_builddir)/src/util/libgnunetutil.la \ |
637 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 682 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
638 | libgnunetnamestore.la | 683 | libgnunetnamestore.la |
@@ -641,6 +686,7 @@ test_namestore_api_zone_iteration_stop_flat_SOURCES = \ | |||
641 | test_namestore_api_zone_iteration_stop.c | 686 | test_namestore_api_zone_iteration_stop.c |
642 | test_namestore_api_zone_iteration_stop_flat_LDADD = \ | 687 | test_namestore_api_zone_iteration_stop_flat_LDADD = \ |
643 | $(top_builddir)/src/testing/libgnunettesting.la \ | 688 | $(top_builddir)/src/testing/libgnunettesting.la \ |
689 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
644 | $(top_builddir)/src/util/libgnunetutil.la \ | 690 | $(top_builddir)/src/util/libgnunetutil.la \ |
645 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 691 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
646 | libgnunetnamestore.la | 692 | libgnunetnamestore.la |
@@ -649,6 +695,7 @@ test_namestore_api_zone_iteration_stop_sqlite_SOURCES = \ | |||
649 | test_namestore_api_zone_iteration_stop.c | 695 | test_namestore_api_zone_iteration_stop.c |
650 | test_namestore_api_zone_iteration_stop_sqlite_LDADD = \ | 696 | test_namestore_api_zone_iteration_stop_sqlite_LDADD = \ |
651 | $(top_builddir)/src/testing/libgnunettesting.la \ | 697 | $(top_builddir)/src/testing/libgnunettesting.la \ |
698 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
652 | $(top_builddir)/src/util/libgnunetutil.la \ | 699 | $(top_builddir)/src/util/libgnunetutil.la \ |
653 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 700 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
654 | libgnunetnamestore.la | 701 | libgnunetnamestore.la |
@@ -657,6 +704,7 @@ test_namestore_api_zone_iteration_stop_postgres_SOURCES = \ | |||
657 | test_namestore_api_zone_iteration_stop.c | 704 | test_namestore_api_zone_iteration_stop.c |
658 | test_namestore_api_zone_iteration_stop_postgres_LDADD = \ | 705 | test_namestore_api_zone_iteration_stop_postgres_LDADD = \ |
659 | $(top_builddir)/src/testing/libgnunettesting.la \ | 706 | $(top_builddir)/src/testing/libgnunettesting.la \ |
707 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
660 | $(top_builddir)/src/util/libgnunetutil.la \ | 708 | $(top_builddir)/src/util/libgnunetutil.la \ |
661 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 709 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
662 | libgnunetnamestore.la | 710 | libgnunetnamestore.la |
@@ -664,20 +712,23 @@ test_namestore_api_zone_iteration_stop_postgres_LDADD = \ | |||
664 | test_plugin_namestore_flat_SOURCES = \ | 712 | test_plugin_namestore_flat_SOURCES = \ |
665 | test_plugin_namestore.c | 713 | test_plugin_namestore.c |
666 | test_plugin_namestore_flat_LDADD = \ | 714 | test_plugin_namestore_flat_LDADD = \ |
667 | $(top_builddir)/src/testing/libgnunettesting.la \ | 715 | $(top_builddir)/src/testing/libgnunettesting.la \ |
668 | $(top_builddir)/src/util/libgnunetutil.la | 716 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
717 | $(top_builddir)/src/util/libgnunetutil.la | ||
669 | 718 | ||
670 | test_plugin_namestore_sqlite_SOURCES = \ | 719 | test_plugin_namestore_sqlite_SOURCES = \ |
671 | test_plugin_namestore.c | 720 | test_plugin_namestore.c |
672 | test_plugin_namestore_sqlite_LDADD = \ | 721 | test_plugin_namestore_sqlite_LDADD = \ |
673 | $(top_builddir)/src/testing/libgnunettesting.la \ | 722 | $(top_builddir)/src/testing/libgnunettesting.la \ |
674 | $(top_builddir)/src/util/libgnunetutil.la | 723 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
724 | $(top_builddir)/src/util/libgnunetutil.la | ||
675 | 725 | ||
676 | test_plugin_namestore_postgres_SOURCES = \ | 726 | test_plugin_namestore_postgres_SOURCES = \ |
677 | test_plugin_namestore.c | 727 | test_plugin_namestore.c |
678 | test_plugin_namestore_postgres_LDADD = \ | 728 | test_plugin_namestore_postgres_LDADD = \ |
679 | $(top_builddir)/src/testing/libgnunettesting.la \ | 729 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
680 | $(top_builddir)/src/util/libgnunetutil.la | 730 | $(top_builddir)/src/testing/libgnunettesting.la \ |
731 | $(top_builddir)/src/util/libgnunetutil.la | ||
681 | 732 | ||
682 | check_SCRIPTS = \ | 733 | check_SCRIPTS = \ |
683 | test_namestore_put.sh \ | 734 | test_namestore_put.sh \ |
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index dfd71e57a..8e9cd0c9d 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -824,19 +824,26 @@ check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, | |||
824 | * Write our current proof to disk. | 824 | * Write our current proof to disk. |
825 | */ | 825 | */ |
826 | static void | 826 | static void |
827 | write_proof () | 827 | write_proof (void) |
828 | { | 828 | { |
829 | char *proof; | 829 | char *proof; |
830 | 830 | ||
831 | if (GNUNET_OK != | 831 | if (GNUNET_OK != |
832 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) | 832 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
833 | "NSE", | ||
834 | "PROOFFILE", | ||
835 | &proof)) | ||
833 | return; | 836 | return; |
834 | if (sizeof(my_proof) != GNUNET_DISK_fn_write (proof, | 837 | (void) GNUNET_DISK_directory_remove (proof); |
835 | &my_proof, | 838 | if (GNUNET_OK != |
836 | sizeof(my_proof), | 839 | GNUNET_DISK_fn_write (proof, |
837 | GNUNET_DISK_PERM_USER_READ | 840 | &my_proof, |
838 | | GNUNET_DISK_PERM_USER_WRITE)) | 841 | sizeof(my_proof), |
839 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); | 842 | GNUNET_DISK_PERM_USER_READ |
843 | | GNUNET_DISK_PERM_USER_WRITE)) | ||
844 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
845 | "write", | ||
846 | proof); | ||
840 | GNUNET_free (proof); | 847 | GNUNET_free (proof); |
841 | } | 848 | } |
842 | 849 | ||
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 987c7c3a0..8b149c98e 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -451,13 +451,14 @@ dump_my_hello () | |||
451 | fprintf (stderr, _ ("Failure: Received invalid %s\n"), "HELLO"); | 451 | fprintf (stderr, _ ("Failure: Received invalid %s\n"), "HELLO"); |
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (dump_hello, | 454 | if (GNUNET_SYSERR == |
455 | my_hello, | 455 | GNUNET_DISK_fn_write (dump_hello, |
456 | size, | 456 | my_hello, |
457 | GNUNET_DISK_PERM_USER_READ | 457 | size, |
458 | | GNUNET_DISK_PERM_USER_WRITE | 458 | GNUNET_DISK_PERM_USER_READ |
459 | | GNUNET_DISK_PERM_GROUP_READ | 459 | | GNUNET_DISK_PERM_USER_WRITE |
460 | | GNUNET_DISK_PERM_OTHER_READ)) | 460 | | GNUNET_DISK_PERM_GROUP_READ |
461 | | GNUNET_DISK_PERM_OTHER_READ)) | ||
461 | { | 462 | { |
462 | fprintf (stderr, | 463 | fprintf (stderr, |
463 | _ ("Failed to write HELLO with %u bytes to file `%s'\n"), | 464 | _ ("Failed to write HELLO with %u bytes to file `%s'\n"), |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 79af90dd4..1b1232ecb 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -807,13 +807,14 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
807 | } | 807 | } |
808 | GNUNET_assert (pos == size); | 808 | GNUNET_assert (pos == size); |
809 | 809 | ||
810 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, | 810 | if (GNUNET_SYSERR == |
811 | buffer, | 811 | GNUNET_DISK_fn_write (fn, |
812 | size, | 812 | buffer, |
813 | GNUNET_DISK_PERM_USER_READ | 813 | size, |
814 | | GNUNET_DISK_PERM_USER_WRITE | 814 | GNUNET_DISK_PERM_USER_READ |
815 | | GNUNET_DISK_PERM_GROUP_READ | 815 | | GNUNET_DISK_PERM_USER_WRITE |
816 | | GNUNET_DISK_PERM_OTHER_READ)) | 816 | | GNUNET_DISK_PERM_GROUP_READ |
817 | | GNUNET_DISK_PERM_OTHER_READ)) | ||
817 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); | 818 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); |
818 | else | 819 | else |
819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -987,13 +988,15 @@ discard_hosts_helper (void *cls, const char *fn) | |||
987 | 988 | ||
988 | if (0 < write_pos) | 989 | if (0 < write_pos) |
989 | { | 990 | { |
990 | GNUNET_DISK_fn_write (fn, | 991 | (void) GNUNET_DISK_directory_remove (fn); |
991 | writebuffer, | 992 | GNUNET_assert (GNUNET_OK == |
992 | write_pos, | 993 | GNUNET_DISK_fn_write (fn, |
993 | GNUNET_DISK_PERM_USER_READ | 994 | writebuffer, |
994 | | GNUNET_DISK_PERM_USER_WRITE | 995 | write_pos, |
995 | | GNUNET_DISK_PERM_GROUP_READ | 996 | GNUNET_DISK_PERM_USER_READ |
996 | | GNUNET_DISK_PERM_OTHER_READ); | 997 | | GNUNET_DISK_PERM_USER_WRITE |
998 | | GNUNET_DISK_PERM_GROUP_READ | ||
999 | | GNUNET_DISK_PERM_OTHER_READ)); | ||
997 | } | 1000 | } |
998 | else if (0 != unlink (fn)) | 1001 | else if (0 != unlink (fn)) |
999 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | 1002 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index 22230cf5c..fd73cf0d8 100644 --- a/src/pq/pq_connect.c +++ b/src/pq/pq_connect.c | |||
@@ -190,7 +190,7 @@ apply_patch (struct GNUNET_PQ_Context *db, | |||
190 | if ( (GNUNET_OS_PROCESS_EXITED != type) || | 190 | if ( (GNUNET_OS_PROCESS_EXITED != type) || |
191 | (0 != code) ) | 191 | (0 != code) ) |
192 | { | 192 | { |
193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 193 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
194 | "Could not run PSQL on file %s: %d\n", | 194 | "Could not run PSQL on file %s: %d\n", |
195 | buf, | 195 | buf, |
196 | (int) code); | 196 | (int) code); |
@@ -419,7 +419,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
419 | GNUNET_PQ_run_sql (db, | 419 | GNUNET_PQ_run_sql (db, |
420 | db->load_path)) | 420 | db->load_path)) |
421 | { | 421 | { |
422 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 422 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
423 | "Failed to load SQL statements from `%s*'\n", | 423 | "Failed to load SQL statements from `%s*'\n", |
424 | db->load_path); | 424 | db->load_path); |
425 | PQfinish (db->conn); | 425 | PQfinish (db->conn); |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 5614f05db..913b667b7 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -300,6 +300,16 @@ struct AttributeDeleteHandle | |||
300 | struct TicketRecordsEntry *tickets_to_update_tail; | 300 | struct TicketRecordsEntry *tickets_to_update_tail; |
301 | 301 | ||
302 | /** | 302 | /** |
303 | * Existing attributes | ||
304 | */ | ||
305 | struct GNUNET_RECLAIM_AttributeList *existing_attributes; | ||
306 | |||
307 | /** | ||
308 | * Existing credentials | ||
309 | */ | ||
310 | struct GNUNET_RECLAIM_CredentialList *existing_credentials; | ||
311 | |||
312 | /** | ||
303 | * Attribute label | 313 | * Attribute label |
304 | */ | 314 | */ |
305 | char *label; | 315 | char *label; |
@@ -490,6 +500,10 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
490 | GNUNET_free (adh->claim); | 500 | GNUNET_free (adh->claim); |
491 | if (NULL != adh->credential) | 501 | if (NULL != adh->credential) |
492 | GNUNET_free (adh->credential); | 502 | GNUNET_free (adh->credential); |
503 | if (NULL != adh->existing_credentials) | ||
504 | GNUNET_RECLAIM_credential_list_destroy (adh->existing_credentials); | ||
505 | if (NULL != adh->existing_attributes) | ||
506 | GNUNET_RECLAIM_attribute_list_destroy (adh->existing_attributes); | ||
493 | while (NULL != (le = adh->tickets_to_update_head)) | 507 | while (NULL != (le = adh->tickets_to_update_head)) |
494 | { | 508 | { |
495 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 509 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
@@ -1301,7 +1315,7 @@ send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | |||
1301 | * @param rd record data | 1315 | * @param rd record data |
1302 | */ | 1316 | */ |
1303 | static void | 1317 | static void |
1304 | ticket_iter (void *cls, | 1318 | consistency_iter (void *cls, |
1305 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 1319 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
1306 | const char *label, | 1320 | const char *label, |
1307 | unsigned int rd_count, | 1321 | unsigned int rd_count, |
@@ -1309,26 +1323,42 @@ ticket_iter (void *cls, | |||
1309 | { | 1323 | { |
1310 | struct AttributeDeleteHandle *adh = cls; | 1324 | struct AttributeDeleteHandle *adh = cls; |
1311 | struct TicketRecordsEntry *le; | 1325 | struct TicketRecordsEntry *le; |
1312 | int has_changed = GNUNET_NO; | 1326 | struct GNUNET_RECLAIM_AttributeListEntry *ale; |
1327 | struct GNUNET_RECLAIM_CredentialListEntry *cle; | ||
1328 | int is_ticket = GNUNET_NO; | ||
1313 | for (int i = 0; i < rd_count; i++) | 1329 | for (int i = 0; i < rd_count; i++) |
1314 | { | 1330 | { |
1315 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) | 1331 | switch (rd[i].record_type) { |
1316 | continue; | 1332 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE: |
1317 | if (adh->claim != NULL) | 1333 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry); |
1318 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1334 | GNUNET_RECLAIM_attribute_deserialize (rd[i].data, |
1319 | &adh->claim->id)) | 1335 | rd[i].data_size, |
1320 | continue; | 1336 | &ale->attribute); |
1321 | if (adh->credential != NULL) | 1337 | GNUNET_CONTAINER_DLL_insert (adh->existing_attributes->list_head, |
1322 | if (GNUNET_YES != GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1338 | adh->existing_attributes->list_tail, |
1323 | &adh->credential->id)) | 1339 | ale); |
1324 | continue; | 1340 | break; |
1325 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1341 | case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL: |
1326 | "Attribute to delete found (%s)\n", | 1342 | cle = GNUNET_new (struct GNUNET_RECLAIM_CredentialListEntry); |
1327 | adh->label); | 1343 | cle->credential = GNUNET_RECLAIM_credential_deserialize (rd[i].data, |
1328 | has_changed = GNUNET_YES; | 1344 | rd[i].data_size); |
1329 | break; | 1345 | GNUNET_CONTAINER_DLL_insert (adh->existing_credentials->list_head, |
1346 | adh->existing_credentials->list_tail, | ||
1347 | cle); | ||
1348 | break; | ||
1349 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: | ||
1350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1351 | "Ticket to delete found (%s)\n", | ||
1352 | label); | ||
1353 | is_ticket = GNUNET_YES; | ||
1354 | break; | ||
1355 | default: | ||
1356 | break; | ||
1357 | } | ||
1358 | if (GNUNET_YES == is_ticket) | ||
1359 | break; | ||
1330 | } | 1360 | } |
1331 | if (GNUNET_YES == has_changed) | 1361 | if (GNUNET_YES == is_ticket) |
1332 | { | 1362 | { |
1333 | le = GNUNET_new (struct TicketRecordsEntry); | 1363 | le = GNUNET_new (struct TicketRecordsEntry); |
1334 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 1364 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); |
@@ -1384,15 +1414,12 @@ update_tickets (void *cls) | |||
1384 | 1414 | ||
1385 | if (NULL == adh->tickets_to_update_head) | 1415 | if (NULL == adh->tickets_to_update_head) |
1386 | { | 1416 | { |
1387 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1388 | "Finished updating tickets, success\n"); | 1418 | "Finished updating tickets, success\n"); |
1389 | send_delete_response (adh, GNUNET_OK); | 1419 | send_delete_response (adh, GNUNET_OK); |
1390 | cleanup_adh (adh); | 1420 | cleanup_adh (adh); |
1391 | return; | 1421 | return; |
1392 | } | 1422 | } |
1393 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1394 | "Updating %s\n", | ||
1395 | adh->tickets_to_update_head->label); | ||
1396 | le = adh->tickets_to_update_head; | 1423 | le = adh->tickets_to_update_head; |
1397 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 1424 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
1398 | adh->tickets_to_update_tail, | 1425 | adh->tickets_to_update_tail, |
@@ -1411,21 +1438,53 @@ update_tickets (void *cls) | |||
1411 | return; | 1438 | return; |
1412 | } | 1439 | } |
1413 | int j = 0; | 1440 | int j = 0; |
1414 | for (int i = 0; i < le->rd_count; i++) | 1441 | int i = 0; |
1442 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | ||
1443 | struct GNUNET_RECLAIM_CredentialListEntry *cle; | ||
1444 | struct GNUNET_RECLAIM_Presentation *presentation; | ||
1445 | for (i = 0; i < le->rd_count; i++) | ||
1415 | { | 1446 | { |
1416 | if (adh->claim != NULL) | 1447 | switch (rd[i].record_type) { |
1417 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) | 1448 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: |
1418 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1449 | for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next) { |
1419 | &adh->claim->id))) | 1450 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, |
1420 | continue; | 1451 | &ale->attribute->id)) { |
1421 | if (adh->credential != NULL) | 1452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1422 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[i].record_type) | 1453 | "Found attribute %s, readding...\n", |
1423 | && (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (rd[i].data, | 1454 | ale->attribute->name); |
1424 | &adh->credential->id))) | 1455 | rd_new[j] = rd[i]; |
1425 | continue; | 1456 | j++; |
1426 | rd_new[j] = rd[i]; | 1457 | break; //Found and added |
1427 | j++; | 1458 | } |
1459 | } | ||
1460 | break; | ||
1461 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: | ||
1462 | presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data, | ||
1463 | rd[i].data_size); | ||
1464 | for (cle = adh->existing_credentials->list_head; NULL != cle; cle = cle->next) { | ||
1465 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&presentation->credential_id, | ||
1466 | &cle->credential->id)) { | ||
1467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1468 | "Found presentation for credential %s, readding...\n", | ||
1469 | cle->credential->name); | ||
1470 | rd_new[j] = rd[i]; | ||
1471 | j++; | ||
1472 | break; //Found and added | ||
1473 | } | ||
1474 | } | ||
1475 | GNUNET_free (presentation); | ||
1476 | break; | ||
1477 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: | ||
1478 | rd_new[j] = rd[i]; | ||
1479 | j++; | ||
1480 | break; //Found and added | ||
1481 | default: | ||
1482 | GNUNET_break (0); | ||
1483 | } | ||
1428 | } | 1484 | } |
1485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1486 | "Updating ticket with %d entries (%d before)...\n", | ||
1487 | j, i); | ||
1429 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1488 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
1430 | &adh->identity, | 1489 | &adh->identity, |
1431 | le->label, | 1490 | le->label, |
@@ -1438,6 +1497,90 @@ update_tickets (void *cls) | |||
1438 | GNUNET_free (le); | 1497 | GNUNET_free (le); |
1439 | } | 1498 | } |
1440 | 1499 | ||
1500 | /** | ||
1501 | * Delete all attributes which reference credentials | ||
1502 | * that no longer exist | ||
1503 | */ | ||
1504 | static void | ||
1505 | purge_attributes (void *cls);; | ||
1506 | |||
1507 | static void | ||
1508 | offending_attr_delete_cont (void *cls, int32_t success, const char *emsg) | ||
1509 | { | ||
1510 | struct AttributeDeleteHandle *adh = cls; | ||
1511 | |||
1512 | adh->ns_qe = NULL; | ||
1513 | if (GNUNET_SYSERR == success) | ||
1514 | { | ||
1515 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1516 | "Error deleting attribute %s\n", | ||
1517 | adh->label); | ||
1518 | send_delete_response (adh, GNUNET_SYSERR); | ||
1519 | cleanup_adh (adh); | ||
1520 | return; | ||
1521 | } | ||
1522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing consistency check...\n"); | ||
1523 | GNUNET_SCHEDULER_add_now (&purge_attributes, adh); | ||
1524 | } | ||
1525 | |||
1526 | |||
1527 | |||
1528 | /** | ||
1529 | * Delete all attributes which reference credentials | ||
1530 | * that no longer exist | ||
1531 | */ | ||
1532 | static void | ||
1533 | purge_attributes (void *cls) | ||
1534 | { | ||
1535 | struct AttributeDeleteHandle *adh = cls; | ||
1536 | struct GNUNET_RECLAIM_AttributeListEntry *ale; | ||
1537 | struct GNUNET_RECLAIM_CredentialListEntry *cle; | ||
1538 | |||
1539 | for (ale = adh->existing_attributes->list_head; NULL != ale; ale = ale->next) | ||
1540 | { | ||
1541 | if (GNUNET_YES == | ||
1542 | GNUNET_RECLAIM_id_is_zero (&ale->attribute->credential)) | ||
1543 | continue; | ||
1544 | |||
1545 | for (cle = adh->existing_credentials->list_head; | ||
1546 | NULL != cle; cle = cle->next) { | ||
1547 | if (GNUNET_YES != | ||
1548 | GNUNET_RECLAIM_id_is_equal (&cle->credential->id, | ||
1549 | &ale->attribute->credential)) | ||
1550 | continue; | ||
1551 | break; | ||
1552 | } | ||
1553 | if (NULL == cle) { | ||
1554 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1555 | "Found attribute with missing credential\n"); | ||
1556 | break; | ||
1557 | } | ||
1558 | } | ||
1559 | if (NULL == ale) { | ||
1560 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1561 | "Attributes consistent, updating tickets.\n"); | ||
1562 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | ||
1563 | return; | ||
1564 | } | ||
1565 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1566 | "Attributes inconsistent, deleting offending attribute.\n"); | ||
1567 | char *label | ||
1568 | = GNUNET_STRINGS_data_to_string_alloc (&ale->attribute->id, | ||
1569 | sizeof(ale->attribute->id)); | ||
1570 | |||
1571 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1572 | &adh->identity, | ||
1573 | label, | ||
1574 | 0, | ||
1575 | NULL, | ||
1576 | &offending_attr_delete_cont, | ||
1577 | adh); | ||
1578 | GNUNET_CONTAINER_DLL_remove (adh->existing_attributes->list_head, | ||
1579 | adh->existing_attributes->list_tail, | ||
1580 | ale); | ||
1581 | GNUNET_free (ale); | ||
1582 | GNUNET_free (label); | ||
1583 | } | ||
1441 | 1584 | ||
1442 | /** | 1585 | /** |
1443 | * Done collecting affected tickets, start updating. | 1586 | * Done collecting affected tickets, start updating. |
@@ -1445,11 +1588,11 @@ update_tickets (void *cls) | |||
1445 | * @param cls our attribute deletion handle | 1588 | * @param cls our attribute deletion handle |
1446 | */ | 1589 | */ |
1447 | static void | 1590 | static void |
1448 | ticket_iter_fin (void *cls) | 1591 | consistency_iter_fin (void *cls) |
1449 | { | 1592 | { |
1450 | struct AttributeDeleteHandle *adh = cls; | 1593 | struct AttributeDeleteHandle *adh = cls; |
1451 | adh->ns_it = NULL; | 1594 | adh->ns_it = NULL; |
1452 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | 1595 | GNUNET_SCHEDULER_add_now (&purge_attributes, adh); |
1453 | } | 1596 | } |
1454 | 1597 | ||
1455 | 1598 | ||
@@ -1459,14 +1602,13 @@ ticket_iter_fin (void *cls) | |||
1459 | * @param cls our attribute deletion handle | 1602 | * @param cls our attribute deletion handle |
1460 | */ | 1603 | */ |
1461 | static void | 1604 | static void |
1462 | ticket_iter_err (void *cls) | 1605 | consistency_iter_err (void *cls) |
1463 | { | 1606 | { |
1464 | struct AttributeDeleteHandle *adh = cls; | 1607 | struct AttributeDeleteHandle *adh = cls; |
1465 | 1608 | ||
1466 | adh->ns_it = NULL; | 1609 | adh->ns_it = NULL; |
1467 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1610 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1468 | "Namestore error on delete %s\n", | 1611 | "Namestore error on consistency check\n"); |
1469 | adh->label); | ||
1470 | send_delete_response (adh, GNUNET_SYSERR); | 1612 | send_delete_response (adh, GNUNET_SYSERR); |
1471 | cleanup_adh (adh); | 1613 | cleanup_adh (adh); |
1472 | } | 1614 | } |
@@ -1479,17 +1621,20 @@ ticket_iter_err (void *cls) | |||
1479 | * @param cls attribute deletion handle | 1621 | * @param cls attribute deletion handle |
1480 | */ | 1622 | */ |
1481 | static void | 1623 | static void |
1482 | start_ticket_update (void *cls) | 1624 | start_consistency_update (void *cls) |
1483 | { | 1625 | { |
1484 | struct AttributeDeleteHandle *adh = cls; | 1626 | struct AttributeDeleteHandle *adh = cls; |
1485 | 1627 | ||
1628 | adh->existing_attributes = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | ||
1629 | adh->existing_credentials = GNUNET_new (struct GNUNET_RECLAIM_CredentialList); | ||
1630 | |||
1486 | adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 1631 | adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
1487 | &adh->identity, | 1632 | &adh->identity, |
1488 | &ticket_iter_err, | 1633 | &consistency_iter_err, |
1489 | adh, | 1634 | adh, |
1490 | &ticket_iter, | 1635 | &consistency_iter, |
1491 | adh, | 1636 | adh, |
1492 | &ticket_iter_fin, | 1637 | &consistency_iter_fin, |
1493 | adh); | 1638 | adh); |
1494 | } | 1639 | } |
1495 | 1640 | ||
@@ -1517,7 +1662,7 @@ attr_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1517 | return; | 1662 | return; |
1518 | } | 1663 | } |
1519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | 1664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); |
1520 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | 1665 | GNUNET_SCHEDULER_add_now (&start_consistency_update, adh); |
1521 | } | 1666 | } |
1522 | 1667 | ||
1523 | 1668 | ||
@@ -1586,12 +1731,12 @@ handle_attribute_delete_message (void *cls, | |||
1586 | 1731 | ||
1587 | 1732 | ||
1588 | /** | 1733 | /** |
1589 | * Credential deleted callback | 1734 | * Credential deleted callback |
1590 | * | 1735 | * |
1591 | * @param cls our handle | 1736 | * @param cls our handle |
1592 | * @param success success status | 1737 | * @param success success status |
1593 | * @param emsg error message (NULL if success=GNUNET_OK) | 1738 | * @param emsg error message (NULL if success=GNUNET_OK) |
1594 | */ | 1739 | */ |
1595 | static void | 1740 | static void |
1596 | cred_delete_cont (void *cls, int32_t success, const char *emsg) | 1741 | cred_delete_cont (void *cls, int32_t success, const char *emsg) |
1597 | { | 1742 | { |
@@ -1608,7 +1753,7 @@ cred_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1608 | return; | 1753 | return; |
1609 | } | 1754 | } |
1610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | 1755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); |
1611 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | 1756 | GNUNET_SCHEDULER_add_now (&start_consistency_update, adh); |
1612 | } | 1757 | } |
1613 | 1758 | ||
1614 | 1759 | ||
@@ -1642,7 +1787,7 @@ check_credential_delete_message (void *cls, | |||
1642 | */ | 1787 | */ |
1643 | static void | 1788 | static void |
1644 | handle_credential_delete_message (void *cls, | 1789 | handle_credential_delete_message (void *cls, |
1645 | const struct AttributeDeleteMessage *dam) | 1790 | const struct AttributeDeleteMessage *dam) |
1646 | { | 1791 | { |
1647 | struct AttributeDeleteHandle *adh; | 1792 | struct AttributeDeleteHandle *adh; |
1648 | struct IdpClient *idp = cls; | 1793 | struct IdpClient *idp = cls; |
@@ -1676,8 +1821,8 @@ handle_credential_delete_message (void *cls, | |||
1676 | 1821 | ||
1677 | 1822 | ||
1678 | /************************************************* | 1823 | /************************************************* |
1679 | * Attrubute iteration | 1824 | * Attrubute iteration |
1680 | *************************************************/ | 1825 | *************************************************/ |
1681 | 1826 | ||
1682 | 1827 | ||
1683 | /** | 1828 | /** |
@@ -1860,8 +2005,8 @@ handle_iteration_next (void *cls, | |||
1860 | 2005 | ||
1861 | 2006 | ||
1862 | /************************************************* | 2007 | /************************************************* |
1863 | * Credential iteration | 2008 | * Credential iteration |
1864 | *************************************************/ | 2009 | *************************************************/ |
1865 | 2010 | ||
1866 | 2011 | ||
1867 | /** | 2012 | /** |
@@ -2050,8 +2195,8 @@ handle_credential_iteration_next (void *cls, | |||
2050 | 2195 | ||
2051 | 2196 | ||
2052 | /****************************************************** | 2197 | /****************************************************** |
2053 | * Ticket iteration | 2198 | * Ticket iteration |
2054 | ******************************************************/ | 2199 | ******************************************************/ |
2055 | 2200 | ||
2056 | /** | 2201 | /** |
2057 | * Got a ticket. Return to client | 2202 | * Got a ticket. Return to client |
@@ -2094,8 +2239,8 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2094 | */ | 2239 | */ |
2095 | static void | 2240 | static void |
2096 | handle_ticket_iteration_start ( | 2241 | handle_ticket_iteration_start ( |
2097 | void *cls, | 2242 | void *cls, |
2098 | const struct TicketIterationStartMessage *tis_msg) | 2243 | const struct TicketIterationStartMessage *tis_msg) |
2099 | { | 2244 | { |
2100 | struct IdpClient *client = cls; | 2245 | struct IdpClient *client = cls; |
2101 | struct TicketIteration *ti; | 2246 | struct TicketIteration *ti; |
@@ -2267,76 +2412,76 @@ client_connect_cb (void *cls, | |||
2267 | * Define "main" method using service macro. | 2412 | * Define "main" method using service macro. |
2268 | */ | 2413 | */ |
2269 | GNUNET_SERVICE_MAIN ( | 2414 | GNUNET_SERVICE_MAIN ( |
2270 | "reclaim", | 2415 | "reclaim", |
2271 | GNUNET_SERVICE_OPTION_NONE, | 2416 | GNUNET_SERVICE_OPTION_NONE, |
2272 | &run, | 2417 | &run, |
2273 | &client_connect_cb, | 2418 | &client_connect_cb, |
2274 | &client_disconnect_cb, | 2419 | &client_disconnect_cb, |
2275 | NULL, | 2420 | NULL, |
2276 | GNUNET_MQ_hd_var_size (attribute_store_message, | 2421 | GNUNET_MQ_hd_var_size (attribute_store_message, |
2277 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, | 2422 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, |
2278 | struct AttributeStoreMessage, | 2423 | struct AttributeStoreMessage, |
2279 | NULL), | 2424 | NULL), |
2280 | GNUNET_MQ_hd_var_size (credential_store_message, | 2425 | GNUNET_MQ_hd_var_size (credential_store_message, |
2281 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, | 2426 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE, |
2282 | struct AttributeStoreMessage, | 2427 | struct AttributeStoreMessage, |
2283 | NULL), | 2428 | NULL), |
2284 | GNUNET_MQ_hd_var_size (attribute_delete_message, | 2429 | GNUNET_MQ_hd_var_size (attribute_delete_message, |
2285 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, | 2430 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, |
2286 | struct AttributeDeleteMessage, | 2431 | struct AttributeDeleteMessage, |
2287 | NULL), | 2432 | NULL), |
2288 | GNUNET_MQ_hd_var_size (credential_delete_message, | 2433 | GNUNET_MQ_hd_var_size (credential_delete_message, |
2289 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, | 2434 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE, |
2290 | struct AttributeDeleteMessage, | 2435 | struct AttributeDeleteMessage, |
2291 | NULL), | 2436 | NULL), |
2292 | GNUNET_MQ_hd_fixed_size (iteration_start, | 2437 | GNUNET_MQ_hd_fixed_size (iteration_start, |
2293 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 2438 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
2294 | struct AttributeIterationStartMessage, | 2439 | struct AttributeIterationStartMessage, |
2295 | NULL), | 2440 | NULL), |
2296 | GNUNET_MQ_hd_fixed_size (iteration_next, | 2441 | GNUNET_MQ_hd_fixed_size (iteration_next, |
2297 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, | 2442 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, |
2298 | struct AttributeIterationNextMessage, | 2443 | struct AttributeIterationNextMessage, |
2299 | NULL), | 2444 | NULL), |
2300 | GNUNET_MQ_hd_fixed_size (iteration_stop, | 2445 | GNUNET_MQ_hd_fixed_size (iteration_stop, |
2301 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, | 2446 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, |
2302 | struct AttributeIterationStopMessage, | 2447 | struct AttributeIterationStopMessage, |
2303 | NULL), | 2448 | NULL), |
2304 | GNUNET_MQ_hd_fixed_size (credential_iteration_start, | 2449 | GNUNET_MQ_hd_fixed_size (credential_iteration_start, |
2305 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, | 2450 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START, |
2306 | struct CredentialIterationStartMessage, | 2451 | struct CredentialIterationStartMessage, |
2307 | NULL), | 2452 | NULL), |
2308 | GNUNET_MQ_hd_fixed_size (credential_iteration_next, | 2453 | GNUNET_MQ_hd_fixed_size (credential_iteration_next, |
2309 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, | 2454 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT, |
2310 | struct CredentialIterationNextMessage, | 2455 | struct CredentialIterationNextMessage, |
2311 | NULL), | 2456 | NULL), |
2312 | GNUNET_MQ_hd_fixed_size (credential_iteration_stop, | 2457 | GNUNET_MQ_hd_fixed_size (credential_iteration_stop, |
2313 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, | 2458 | GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP, |
2314 | struct CredentialIterationStopMessage, | 2459 | struct CredentialIterationStopMessage, |
2315 | NULL), | 2460 | NULL), |
2316 | 2461 | ||
2317 | GNUNET_MQ_hd_var_size (issue_ticket_message, | 2462 | GNUNET_MQ_hd_var_size (issue_ticket_message, |
2318 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, | 2463 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, |
2319 | struct IssueTicketMessage, | 2464 | struct IssueTicketMessage, |
2320 | NULL), | 2465 | NULL), |
2321 | GNUNET_MQ_hd_var_size (consume_ticket_message, | 2466 | GNUNET_MQ_hd_var_size (consume_ticket_message, |
2322 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, | 2467 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, |
2323 | struct ConsumeTicketMessage, | 2468 | struct ConsumeTicketMessage, |
2324 | NULL), | 2469 | NULL), |
2325 | GNUNET_MQ_hd_fixed_size (ticket_iteration_start, | 2470 | GNUNET_MQ_hd_fixed_size (ticket_iteration_start, |
2326 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, | 2471 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, |
2327 | struct TicketIterationStartMessage, | 2472 | struct TicketIterationStartMessage, |
2328 | NULL), | 2473 | NULL), |
2329 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, | 2474 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, |
2330 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, | 2475 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, |
2331 | struct TicketIterationNextMessage, | 2476 | struct TicketIterationNextMessage, |
2332 | NULL), | 2477 | NULL), |
2333 | GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, | 2478 | GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, |
2334 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, | 2479 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, |
2335 | struct TicketIterationStopMessage, | 2480 | struct TicketIterationStopMessage, |
2336 | NULL), | 2481 | NULL), |
2337 | GNUNET_MQ_hd_var_size (revoke_ticket_message, | 2482 | GNUNET_MQ_hd_var_size (revoke_ticket_message, |
2338 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, | 2483 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, |
2339 | struct RevokeTicketMessage, | 2484 | struct RevokeTicketMessage, |
2340 | NULL), | 2485 | NULL), |
2341 | GNUNET_MQ_handler_end ()); | 2486 | GNUNET_MQ_handler_end ()); |
2342 | /* end of gnunet-service-reclaim.c */ | 2487 | /* end of gnunet-service-reclaim.c */ |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index 0b1730bec..ef2303bd7 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -1542,6 +1542,7 @@ filter_tickets_cb (void *cls, | |||
1542 | tih->presentations->list_tail, | 1542 | tih->presentations->list_tail, |
1543 | ple); | 1543 | ple); |
1544 | GNUNET_free (cred); | 1544 | GNUNET_free (cred); |
1545 | break; | ||
1545 | } | 1546 | } |
1546 | } | 1547 | } |
1547 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type) | 1548 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type) |
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c index 8a3479b8a..4eeb22bee 100644 --- a/src/reclaim/json_reclaim.c +++ b/src/reclaim/json_reclaim.c | |||
@@ -95,6 +95,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | |||
95 | } | 95 | } |
96 | attr = GNUNET_RECLAIM_attribute_new (name_str, NULL, | 96 | attr = GNUNET_RECLAIM_attribute_new (name_str, NULL, |
97 | type, data, data_size); | 97 | type, data, data_size); |
98 | GNUNET_free (data); | ||
98 | if ((NULL != cred_str) && (0 != strlen (cred_str))) | 99 | if ((NULL != cred_str) && (0 != strlen (cred_str))) |
99 | { | 100 | { |
100 | GNUNET_STRINGS_string_to_data (cred_str, | 101 | GNUNET_STRINGS_string_to_data (cred_str, |
@@ -211,8 +212,7 @@ parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | |||
211 | GNUNET_STRINGS_string_to_data (id_str, | 212 | GNUNET_STRINGS_string_to_data (id_str, |
212 | strlen (id_str), | 213 | strlen (id_str), |
213 | &ticket->identity, | 214 | &ticket->identity, |
214 | sizeof( | 215 | sizeof(ticket->identity))) |
215 | struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
216 | { | 216 | { |
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n"); | 217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n"); |
218 | GNUNET_free (ticket); | 218 | GNUNET_free (ticket); |
@@ -223,8 +223,7 @@ parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) | |||
223 | GNUNET_STRINGS_string_to_data (aud_str, | 223 | GNUNET_STRINGS_string_to_data (aud_str, |
224 | strlen (aud_str), | 224 | strlen (aud_str), |
225 | &ticket->audience, | 225 | &ticket->audience, |
226 | sizeof(struct | 226 | sizeof(ticket->audience))) |
227 | GNUNET_CRYPTO_EcdsaPublicKey))) | ||
228 | { | 227 | { |
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n"); | 228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n"); |
230 | GNUNET_free (ticket); | 229 | GNUNET_free (ticket); |
@@ -336,6 +335,7 @@ parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spe | |||
336 | return GNUNET_SYSERR; | 335 | return GNUNET_SYSERR; |
337 | } | 336 | } |
338 | cred = GNUNET_RECLAIM_credential_new (name_str, type, data, data_size); | 337 | cred = GNUNET_RECLAIM_credential_new (name_str, type, data, data_size); |
338 | GNUNET_free (data); | ||
339 | if ((NULL == id_str) || (0 == strlen (id_str))) | 339 | if ((NULL == id_str) || (0 == strlen (id_str))) |
340 | memset (&cred->id, 0, sizeof (cred->id)); | 340 | memset (&cred->id, 0, sizeof (cred->id)); |
341 | else | 341 | else |
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index 1dde7b673..bd3a8ee05 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c | |||
@@ -193,6 +193,7 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
193 | json_object_set_new (body, "iss", json_string (SERVER_ADDRESS)); | 193 | json_object_set_new (body, "iss", json_string (SERVER_ADDRESS)); |
194 | // sub REQUIRED public key identity, not exceed 255 ASCII length | 194 | // sub REQUIRED public key identity, not exceed 255 ASCII length |
195 | json_object_set_new (body, "sub", json_string (subject)); | 195 | json_object_set_new (body, "sub", json_string (subject)); |
196 | GNUNET_free (subject); | ||
196 | pres_val_str = NULL; | 197 | pres_val_str = NULL; |
197 | source_name = NULL; | 198 | source_name = NULL; |
198 | int i = 0; | 199 | int i = 0; |
@@ -202,11 +203,15 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
202 | GNUNET_asprintf (&source_name, | 203 | GNUNET_asprintf (&source_name, |
203 | "src%d", | 204 | "src%d", |
204 | i); | 205 | i); |
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
207 | "Adding new presentation source #%d\n", i); | ||
205 | aggr_sources_jwt = json_object (); | 208 | aggr_sources_jwt = json_object (); |
206 | pres_val_str = | 209 | pres_val_str = |
207 | GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type, | 210 | GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type, |
208 | ple->presentation->data, | 211 | ple->presentation->data, |
209 | ple->presentation->data_size); | 212 | ple->presentation->data_size); |
213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
214 | "Presentation is: %s\n", pres_val_str); | ||
210 | json_object_set_new (aggr_sources_jwt, | 215 | json_object_set_new (aggr_sources_jwt, |
211 | GNUNET_RECLAIM_presentation_number_to_typename ( | 216 | GNUNET_RECLAIM_presentation_number_to_typename ( |
212 | ple->presentation->type), | 217 | ple->presentation->type), |
@@ -218,12 +223,15 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
218 | i++; | 223 | i++; |
219 | } | 224 | } |
220 | 225 | ||
226 | int addr_is_aggregated = GNUNET_NO; | ||
227 | int addr_is_normal = GNUNET_NO; | ||
221 | for (le = attrs->list_head; NULL != le; le = le->next) | 228 | for (le = attrs->list_head; NULL != le; le = le->next) |
222 | { | 229 | { |
223 | 230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
231 | "Processing %s for userinfo body\n", | ||
232 | le->attribute->name); | ||
224 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) | 233 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) |
225 | { | 234 | { |
226 | |||
227 | attr_val_str = | 235 | attr_val_str = |
228 | GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type, | 236 | GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type, |
229 | le->attribute->data, | 237 | le->attribute->data, |
@@ -231,13 +239,22 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
231 | /** | 239 | /** |
232 | * There is this wierd quirk that the individual address claim(s) must be | 240 | * There is this wierd quirk that the individual address claim(s) must be |
233 | * inside a JSON object of the "address" claim. | 241 | * inside a JSON object of the "address" claim. |
234 | * FIXME: Possibly include formatted claim here | ||
235 | */ | 242 | */ |
236 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) | 243 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) |
237 | { | 244 | { |
245 | if (GNUNET_YES == addr_is_aggregated) | ||
246 | { | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
248 | "Address is set as aggregated claim. Skipping self-issued value...\n"); | ||
249 | GNUNET_free (attr_val_str); | ||
250 | continue; | ||
251 | } | ||
252 | addr_is_normal = GNUNET_YES; | ||
253 | |||
238 | if (NULL == addr_claim) | 254 | if (NULL == addr_claim) |
239 | { | 255 | { |
240 | addr_claim = json_object (); | 256 | addr_claim = json_object (); |
257 | json_object_set_new (body, "address", addr_claim); | ||
241 | } | 258 | } |
242 | json_object_set_new (addr_claim, le->attribute->name, | 259 | json_object_set_new (addr_claim, le->attribute->name, |
243 | json_string (attr_val_str)); | 260 | json_string (attr_val_str)); |
@@ -269,17 +286,42 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
269 | le->attribute->name); | 286 | le->attribute->name); |
270 | continue; | 287 | continue; |
271 | } | 288 | } |
272 | // Presentation exists, hence take the respective source str | 289 | /** |
273 | GNUNET_asprintf (&source_name, | 290 | * There is this wierd quirk that the individual address claim(s) must be |
274 | "src%d", | 291 | * inside a JSON object of the "address" claim. |
275 | j); | 292 | */ |
276 | json_object_set_new (aggr_names, le->attribute->data, | 293 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) |
277 | json_string (source_name)); | 294 | { |
278 | GNUNET_free (source_name); | 295 | if (GNUNET_YES == addr_is_normal) |
296 | { | ||
297 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
298 | "Address is already set as normal claim. Skipping attested value...\n"); | ||
299 | continue; | ||
300 | } | ||
301 | addr_is_aggregated = GNUNET_YES; | ||
302 | /** This is/can only be set once! **/ | ||
303 | if (NULL != addr_claim) | ||
304 | continue; | ||
305 | addr_claim = json_object (); | ||
306 | GNUNET_asprintf (&source_name, | ||
307 | "src%d", | ||
308 | j); | ||
309 | json_object_set_new (aggr_names, "address", | ||
310 | json_string (source_name)); | ||
311 | GNUNET_free (source_name); | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | // Presentation exists, hence take the respective source str | ||
316 | GNUNET_asprintf (&source_name, | ||
317 | "src%d", | ||
318 | j); | ||
319 | json_object_set_new (aggr_names, le->attribute->name, | ||
320 | json_string (source_name)); | ||
321 | GNUNET_free (source_name); | ||
322 | } | ||
279 | } | 323 | } |
280 | } | 324 | } |
281 | if (NULL != addr_claim) | ||
282 | json_object_set_new (body, "address", addr_claim); | ||
283 | if (0 != i) | 325 | if (0 != i) |
284 | { | 326 | { |
285 | json_object_set_new (body, "_claim_names", aggr_names); | 327 | json_object_set_new (body, "_claim_names", aggr_names); |
@@ -498,6 +540,9 @@ OIDC_build_authz_code (const struct GNUNET_IDENTITY_PrivateKey *issuer, | |||
498 | if (NULL != presentations) | 540 | if (NULL != presentations) |
499 | { | 541 | { |
500 | // Get length | 542 | // Get length |
543 | // FIXME only add presentations relevant for attribute list!!! | ||
544 | // This is important because of the distinction between id_token and | ||
545 | // userinfo in OIDC | ||
501 | pres_list_len = | 546 | pres_list_len = |
502 | GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations); | 547 | GNUNET_RECLAIM_presentation_list_serialize_get_size (presentations); |
503 | params.pres_list_len = htonl (pres_list_len); | 548 | params.pres_list_len = htonl (pres_list_len); |
@@ -524,8 +569,10 @@ OIDC_build_authz_code (const struct GNUNET_IDENTITY_PrivateKey *issuer, | |||
524 | } | 569 | } |
525 | if (0 < attr_list_len) | 570 | if (0 < attr_list_len) |
526 | GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp); | 571 | GNUNET_RECLAIM_attribute_list_serialize (attrs, tmp); |
572 | tmp += attr_list_len; | ||
527 | if (0 < pres_list_len) | 573 | if (0 < pres_list_len) |
528 | GNUNET_RECLAIM_presentation_list_serialize (presentations, tmp); | 574 | GNUNET_RECLAIM_presentation_list_serialize (presentations, tmp); |
575 | tmp += pres_list_len; | ||
529 | 576 | ||
530 | /** END **/ | 577 | /** END **/ |
531 | 578 | ||
@@ -677,7 +724,7 @@ OIDC_parse_authz_code (const struct GNUNET_IDENTITY_PublicKey *audience, | |||
677 | // cmp code_challenge code_verifier | 724 | // cmp code_challenge code_verifier |
678 | code_challenge_len = ntohl (params->code_challenge_len); | 725 | code_challenge_len = ntohl (params->code_challenge_len); |
679 | code_challenge = ((char *) ¶ms[1]); | 726 | code_challenge = ((char *) ¶ms[1]); |
680 | if (!(opts & OIDC_VERIFICATION_NO_CODE_VERIFIER)) | 727 | if (! (opts & OIDC_VERIFICATION_NO_CODE_VERIFIER)) |
681 | { | 728 | { |
682 | if (GNUNET_OK != check_code_challenge (code_challenge, | 729 | if (GNUNET_OK != check_code_challenge (code_challenge, |
683 | code_challenge_len, | 730 | code_challenge_len, |
diff --git a/src/reclaim/plugin_reclaim_attribute_basic.c b/src/reclaim/plugin_reclaim_attribute_basic.c index 286186a93..c87922886 100644 --- a/src/reclaim/plugin_reclaim_attribute_basic.c +++ b/src/reclaim/plugin_reclaim_attribute_basic.c | |||
@@ -82,7 +82,7 @@ basic_string_to_value (void *cls, | |||
82 | { | 82 | { |
83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: | 83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
84 | *data = GNUNET_strdup (s); | 84 | *data = GNUNET_strdup (s); |
85 | *data_size = strlen (s); | 85 | *data_size = strlen (s) + 1; |
86 | return GNUNET_OK; | 86 | return GNUNET_OK; |
87 | 87 | ||
88 | default: | 88 | default: |
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c index 6f52f3a4e..aac0a6ea5 100644 --- a/src/reclaim/plugin_reclaim_credential_jwt.c +++ b/src/reclaim/plugin_reclaim_credential_jwt.c | |||
@@ -81,7 +81,7 @@ jwt_string_to_value (void *cls, | |||
81 | { | 81 | { |
82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: | 82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: |
83 | *data = GNUNET_strdup (s); | 83 | *data = GNUNET_strdup (s); |
84 | *data_size = strlen (s); | 84 | *data_size = strlen (s) + 1; |
85 | return GNUNET_OK; | 85 | return GNUNET_OK; |
86 | 86 | ||
87 | default: | 87 | default: |
@@ -151,7 +151,8 @@ jwt_number_to_typename (void *cls, uint32_t type) | |||
151 | */ | 151 | */ |
152 | struct GNUNET_RECLAIM_AttributeList * | 152 | struct GNUNET_RECLAIM_AttributeList * |
153 | jwt_parse_attributes (void *cls, | 153 | jwt_parse_attributes (void *cls, |
154 | const char *data) | 154 | const char *data, |
155 | size_t data_size) | ||
155 | { | 156 | { |
156 | char *jwt_string; | 157 | char *jwt_string; |
157 | struct GNUNET_RECLAIM_AttributeList *attrs; | 158 | struct GNUNET_RECLAIM_AttributeList *attrs; |
@@ -159,12 +160,13 @@ jwt_parse_attributes (void *cls, | |||
159 | char *val_str = NULL; | 160 | char *val_str = NULL; |
160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); | 161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); |
161 | char *decoded_jwt; | 162 | char *decoded_jwt; |
163 | char *tmp; | ||
162 | json_t *json_val; | 164 | json_t *json_val; |
163 | json_error_t *json_err = NULL; | 165 | json_error_t *json_err = NULL; |
164 | 166 | ||
165 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 167 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
166 | 168 | ||
167 | jwt_string = GNUNET_strdup (data); | 169 | jwt_string = GNUNET_strndup (data, data_size); |
168 | const char *jwt_body = strtok (jwt_string, delim); | 170 | const char *jwt_body = strtok (jwt_string, delim); |
169 | jwt_body = strtok (NULL, delim); | 171 | jwt_body = strtok (NULL, delim); |
170 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 172 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -172,8 +174,12 @@ jwt_parse_attributes (void *cls, | |||
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt); | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt); |
173 | GNUNET_assert (NULL != decoded_jwt); | 175 | GNUNET_assert (NULL != decoded_jwt); |
174 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); | 176 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); |
177 | GNUNET_free (decoded_jwt); | ||
175 | const char *key; | 178 | const char *key; |
179 | const char *addr_key; | ||
176 | json_t *value; | 180 | json_t *value; |
181 | json_t *addr_value; | ||
182 | |||
177 | json_object_foreach (json_val, key, value) { | 183 | json_object_foreach (json_val, key, value) { |
178 | if (0 == strcmp ("iss", key)) | 184 | if (0 == strcmp ("iss", key)) |
179 | continue; | 185 | continue; |
@@ -187,15 +193,49 @@ jwt_parse_attributes (void *cls, | |||
187 | continue; | 193 | continue; |
188 | if (0 == strcmp ("aud", key)) | 194 | if (0 == strcmp ("aud", key)) |
189 | continue; | 195 | continue; |
196 | if (0 == strcmp ("address", key)) | ||
197 | { | ||
198 | if (!json_is_object(value)) { | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
200 | "address claim in wrong format!"); | ||
201 | continue; | ||
202 | } | ||
203 | json_object_foreach (value, addr_key, addr_value) { | ||
204 | val_str = json_dumps (addr_value, JSON_ENCODE_ANY); | ||
205 | tmp = val_str; | ||
206 | //Remove leading " from jasson conversion | ||
207 | if (tmp[0] == '"') | ||
208 | tmp++; | ||
209 | //Remove trailing " from jansson conversion | ||
210 | if (tmp[strlen(tmp)-1] == '"') | ||
211 | tmp[strlen(tmp)-1] = '\0'; | ||
212 | GNUNET_RECLAIM_attribute_list_add (attrs, | ||
213 | addr_key, | ||
214 | NULL, | ||
215 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, | ||
216 | tmp, | ||
217 | strlen (val_str)); | ||
218 | GNUNET_free (val_str); | ||
219 | } | ||
220 | continue; | ||
221 | } | ||
190 | val_str = json_dumps (value, JSON_ENCODE_ANY); | 222 | val_str = json_dumps (value, JSON_ENCODE_ANY); |
223 | tmp = val_str; | ||
224 | //Remove leading " from jasson conversion | ||
225 | if (tmp[0] == '"') | ||
226 | tmp++; | ||
227 | //Remove trailing " from jansson conversion | ||
228 | if (tmp[strlen(tmp)-1] == '"') | ||
229 | tmp[strlen(tmp)-1] = '\0'; | ||
191 | GNUNET_RECLAIM_attribute_list_add (attrs, | 230 | GNUNET_RECLAIM_attribute_list_add (attrs, |
192 | key, | 231 | key, |
193 | NULL, | 232 | NULL, |
194 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,// FIXME | 233 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,// FIXME |
195 | val_str, | 234 | tmp, |
196 | strlen (val_str)); | 235 | strlen (val_str)); |
197 | GNUNET_free (val_str); | 236 | GNUNET_free (val_str); |
198 | } | 237 | } |
238 | json_decref (json_val); | ||
199 | GNUNET_free (jwt_string); | 239 | GNUNET_free (jwt_string); |
200 | return attrs; | 240 | return attrs; |
201 | } | 241 | } |
@@ -212,7 +252,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
212 | jwt_parse_attributes_c (void *cls, | 252 | jwt_parse_attributes_c (void *cls, |
213 | const struct GNUNET_RECLAIM_Credential *cred) | 253 | const struct GNUNET_RECLAIM_Credential *cred) |
214 | { | 254 | { |
215 | return jwt_parse_attributes (cls, cred->data); | 255 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
216 | } | 256 | } |
217 | 257 | ||
218 | 258 | ||
@@ -227,7 +267,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
227 | jwt_parse_attributes_p (void *cls, | 267 | jwt_parse_attributes_p (void *cls, |
228 | const struct GNUNET_RECLAIM_Presentation *cred) | 268 | const struct GNUNET_RECLAIM_Presentation *cred) |
229 | { | 269 | { |
230 | return jwt_parse_attributes (cls, cred->data); | 270 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
231 | } | 271 | } |
232 | 272 | ||
233 | 273 | ||
@@ -240,7 +280,8 @@ jwt_parse_attributes_p (void *cls, | |||
240 | */ | 280 | */ |
241 | char * | 281 | char * |
242 | jwt_get_issuer (void *cls, | 282 | jwt_get_issuer (void *cls, |
243 | const char *data) | 283 | const char *data, |
284 | size_t data_size) | ||
244 | { | 285 | { |
245 | const char *jwt_body; | 286 | const char *jwt_body; |
246 | char *jwt_string; | 287 | char *jwt_string; |
@@ -252,17 +293,23 @@ jwt_get_issuer (void *cls, | |||
252 | json_t *json_val; | 293 | json_t *json_val; |
253 | json_error_t *json_err = NULL; | 294 | json_error_t *json_err = NULL; |
254 | 295 | ||
255 | jwt_string = GNUNET_strdup (data); | 296 | jwt_string = GNUNET_strndup (data, data_size); |
256 | jwt_body = strtok (jwt_string, delim); | 297 | jwt_body = strtok (jwt_string, delim); |
257 | jwt_body = strtok (NULL, delim); | 298 | jwt_body = strtok (NULL, delim); |
258 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 299 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
259 | (void **) &decoded_jwt); | 300 | (void **) &decoded_jwt); |
260 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); | 301 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); |
302 | GNUNET_free (decoded_jwt); | ||
303 | GNUNET_free (jwt_string); | ||
304 | if (NULL == json_val) | ||
305 | return NULL; | ||
261 | issuer_json = json_object_get (json_val, "iss"); | 306 | issuer_json = json_object_get (json_val, "iss"); |
262 | if ((NULL == issuer_json) || (! json_is_string (issuer_json))) | 307 | if ((NULL == issuer_json) || (! json_is_string (issuer_json))) { |
308 | json_decref (json_val); | ||
263 | return NULL; | 309 | return NULL; |
310 | } | ||
264 | issuer = GNUNET_strdup (json_string_value (issuer_json)); | 311 | issuer = GNUNET_strdup (json_string_value (issuer_json)); |
265 | GNUNET_free (jwt_string); | 312 | json_decref (json_val); |
266 | return issuer; | 313 | return issuer; |
267 | } | 314 | } |
268 | 315 | ||
@@ -280,7 +327,7 @@ jwt_get_issuer_c (void *cls, | |||
280 | { | 327 | { |
281 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 328 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
282 | return NULL; | 329 | return NULL; |
283 | return jwt_get_issuer (cls, cred->data); | 330 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
284 | } | 331 | } |
285 | 332 | ||
286 | 333 | ||
@@ -297,7 +344,7 @@ jwt_get_issuer_p (void *cls, | |||
297 | { | 344 | { |
298 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 345 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
299 | return NULL; | 346 | return NULL; |
300 | return jwt_get_issuer (cls, cred->data); | 347 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
301 | } | 348 | } |
302 | 349 | ||
303 | 350 | ||
@@ -311,6 +358,7 @@ jwt_get_issuer_p (void *cls, | |||
311 | int | 358 | int |
312 | jwt_get_expiration (void *cls, | 359 | jwt_get_expiration (void *cls, |
313 | const char *data, | 360 | const char *data, |
361 | size_t data_size, | ||
314 | struct GNUNET_TIME_Absolute *exp) | 362 | struct GNUNET_TIME_Absolute *exp) |
315 | { | 363 | { |
316 | const char *jwt_body; | 364 | const char *jwt_body; |
@@ -322,17 +370,23 @@ jwt_get_expiration (void *cls, | |||
322 | json_t *json_val; | 370 | json_t *json_val; |
323 | json_error_t *json_err = NULL; | 371 | json_error_t *json_err = NULL; |
324 | 372 | ||
325 | jwt_string = GNUNET_strdup (data); | 373 | jwt_string = GNUNET_strndup (data, data_size); |
326 | jwt_body = strtok (jwt_string, delim); | 374 | jwt_body = strtok (jwt_string, delim); |
327 | jwt_body = strtok (NULL, delim); | 375 | jwt_body = strtok (NULL, delim); |
328 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 376 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
329 | (void **) &decoded_jwt); | 377 | (void **) &decoded_jwt); |
330 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); | 378 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); |
379 | GNUNET_free (decoded_jwt); | ||
380 | GNUNET_free (jwt_string); | ||
381 | if (NULL == json_val) | ||
382 | return GNUNET_SYSERR; | ||
331 | exp_json = json_object_get (json_val, "exp"); | 383 | exp_json = json_object_get (json_val, "exp"); |
332 | if ((NULL == exp_json) || (! json_is_integer (exp_json))) | 384 | if ((NULL == exp_json) || (! json_is_integer (exp_json))) { |
385 | json_decref (json_val); | ||
333 | return GNUNET_SYSERR; | 386 | return GNUNET_SYSERR; |
387 | } | ||
334 | exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000; | 388 | exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000; |
335 | GNUNET_free (jwt_string); | 389 | json_decref (json_val); |
336 | return GNUNET_OK; | 390 | return GNUNET_OK; |
337 | } | 391 | } |
338 | 392 | ||
@@ -349,7 +403,7 @@ jwt_get_expiration_c (void *cls, | |||
349 | const struct GNUNET_RECLAIM_Credential *cred, | 403 | const struct GNUNET_RECLAIM_Credential *cred, |
350 | struct GNUNET_TIME_Absolute *exp) | 404 | struct GNUNET_TIME_Absolute *exp) |
351 | { | 405 | { |
352 | return jwt_get_expiration (cls, cred->data, exp); | 406 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
353 | } | 407 | } |
354 | 408 | ||
355 | 409 | ||
@@ -365,7 +419,7 @@ jwt_get_expiration_p (void *cls, | |||
365 | const struct GNUNET_RECLAIM_Presentation *cred, | 419 | const struct GNUNET_RECLAIM_Presentation *cred, |
366 | struct GNUNET_TIME_Absolute *exp) | 420 | struct GNUNET_TIME_Absolute *exp) |
367 | { | 421 | { |
368 | return jwt_get_expiration (cls, cred->data, exp); | 422 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
369 | } | 423 | } |
370 | 424 | ||
371 | 425 | ||
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index 698dbfe18..0ee61755b 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -610,6 +610,10 @@ cleanup_handle (struct RequestHandle *handle) | |||
610 | GNUNET_free (handle->oidc->response_type); | 610 | GNUNET_free (handle->oidc->response_type); |
611 | GNUNET_free (handle->oidc->scope); | 611 | GNUNET_free (handle->oidc->scope); |
612 | GNUNET_free (handle->oidc->state); | 612 | GNUNET_free (handle->oidc->state); |
613 | if (NULL != handle->oidc->claims) | ||
614 | GNUNET_free (handle->oidc->claims); | ||
615 | if (NULL != handle->oidc->code_challenge) | ||
616 | GNUNET_free (handle->oidc->code_challenge); | ||
613 | GNUNET_free (handle->oidc); | 617 | GNUNET_free (handle->oidc); |
614 | } | 618 | } |
615 | if (NULL!=handle->attr_idtoken_list) | 619 | if (NULL!=handle->attr_idtoken_list) |
@@ -1193,8 +1197,7 @@ attr_in_claims_request (struct RequestHandle *handle, | |||
1193 | return GNUNET_YES; | 1197 | return GNUNET_YES; |
1194 | 1198 | ||
1195 | /** Try claims parameter if not in scope */ | 1199 | /** Try claims parameter if not in scope */ |
1196 | if ((NULL != handle->oidc->claims) && | 1200 | if (NULL != handle->oidc->claims) |
1197 | (GNUNET_YES != ret)) | ||
1198 | { | 1201 | { |
1199 | root = json_loads (handle->oidc->claims, JSON_DECODE_ANY, &error); | 1202 | root = json_loads (handle->oidc->claims, JSON_DECODE_ANY, &error); |
1200 | claims_j = json_object_get (root, claims_parameter); | 1203 | claims_j = json_object_get (root, claims_parameter); |
@@ -1708,8 +1711,6 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1708 | handle->ego_entry = ego_tail; | 1711 | handle->ego_entry = ego_tail; |
1709 | } | 1712 | } |
1710 | } | 1713 | } |
1711 | handle->oidc->scope = get_url_parameter_copy (handle, OIDC_SCOPE_KEY); | ||
1712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scope: %s\n", handle->oidc->scope); | ||
1713 | if (NULL == handle->tld) | 1714 | if (NULL == handle->tld) |
1714 | GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle); | 1715 | GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle); |
1715 | if (NULL == handle->tld) | 1716 | if (NULL == handle->tld) |
@@ -1872,11 +1873,18 @@ parse_credentials_post_body (struct RequestHandle *handle, | |||
1872 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle | 1873 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle |
1873 | ->url_param_map, | 1874 | ->url_param_map, |
1874 | &cache_key)) | 1875 | &cache_key)) |
1876 | { | ||
1877 | GNUNET_free (*client_id); | ||
1878 | *client_id = NULL; | ||
1875 | return GNUNET_SYSERR; | 1879 | return GNUNET_SYSERR; |
1880 | } | ||
1876 | pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, | 1881 | pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
1877 | &cache_key); | 1882 | &cache_key); |
1878 | if (NULL == pass) | 1883 | if (NULL == pass) { |
1884 | GNUNET_free (*client_id); | ||
1885 | *client_id = NULL; | ||
1879 | return GNUNET_SYSERR; | 1886 | return GNUNET_SYSERR; |
1887 | } | ||
1880 | *client_secret = strdup (pass); | 1888 | *client_secret = strdup (pass); |
1881 | return GNUNET_OK; | 1889 | return GNUNET_OK; |
1882 | } | 1890 | } |
@@ -1938,12 +1946,16 @@ check_authorization (struct RequestHandle *handle, | |||
1938 | GNUNET_free (expected_pass); | 1946 | GNUNET_free (expected_pass); |
1939 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_CLIENT); | 1947 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_CLIENT); |
1940 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1948 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1949 | GNUNET_free (received_cpw); | ||
1950 | GNUNET_free (received_cid); | ||
1941 | return GNUNET_SYSERR; | 1951 | return GNUNET_SYSERR; |
1942 | } | 1952 | } |
1943 | GNUNET_free (expected_pass); | 1953 | GNUNET_free (expected_pass); |
1944 | } | 1954 | } |
1945 | else | 1955 | else |
1946 | { | 1956 | { |
1957 | GNUNET_free (received_cpw); | ||
1958 | GNUNET_free (received_cid); | ||
1947 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_SERVER_ERROR); | 1959 | handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_SERVER_ERROR); |
1948 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); | 1960 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); |
1949 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 1961 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
@@ -2102,9 +2114,13 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2102 | handle->edesc = GNUNET_strdup ("invalid code"); | 2114 | handle->edesc = GNUNET_strdup ("invalid code"); |
2103 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 2115 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
2104 | GNUNET_free (code); | 2116 | GNUNET_free (code); |
2117 | if (NULL != code_verifier) | ||
2118 | GNUNET_free (code_verifier); | ||
2105 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2119 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2106 | return; | 2120 | return; |
2107 | } | 2121 | } |
2122 | if (NULL != code_verifier) | ||
2123 | GNUNET_free (code_verifier); | ||
2108 | 2124 | ||
2109 | // create jwt | 2125 | // create jwt |
2110 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, | 2126 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, |
@@ -2116,6 +2132,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2116 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); | 2132 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); |
2117 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 2133 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
2118 | GNUNET_free (code); | 2134 | GNUNET_free (code); |
2135 | if (NULL != nonce) | ||
2136 | GNUNET_free (nonce); | ||
2119 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2137 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2120 | return; | 2138 | return; |
2121 | } | 2139 | } |
@@ -2131,6 +2149,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2131 | handle->edesc = GNUNET_strdup ("No signing secret configured!"); | 2149 | handle->edesc = GNUNET_strdup ("No signing secret configured!"); |
2132 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 2150 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
2133 | GNUNET_free (code); | 2151 | GNUNET_free (code); |
2152 | if (NULL != nonce) | ||
2153 | GNUNET_free (nonce); | ||
2134 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2154 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2135 | return; | 2155 | return; |
2136 | } | 2156 | } |
@@ -2141,6 +2161,9 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2141 | &expiration_time, | 2161 | &expiration_time, |
2142 | (NULL != nonce) ? nonce : NULL, | 2162 | (NULL != nonce) ? nonce : NULL, |
2143 | jwt_secret); | 2163 | jwt_secret); |
2164 | GNUNET_free (jwt_secret); | ||
2165 | if (NULL != nonce) | ||
2166 | GNUNET_free (nonce); | ||
2144 | access_token = OIDC_access_token_new (&ticket); | 2167 | access_token = OIDC_access_token_new (&ticket); |
2145 | /* Store mapping from access token to code so we can later | 2168 | /* Store mapping from access token to code so we can later |
2146 | * fall back on the provided attributes in userinfo | 2169 | * fall back on the provided attributes in userinfo |
@@ -2243,6 +2266,7 @@ consume_ticket (void *cls, | |||
2243 | atle->presentation = GNUNET_RECLAIM_presentation_new (pres->type, | 2266 | atle->presentation = GNUNET_RECLAIM_presentation_new (pres->type, |
2244 | pres->data, | 2267 | pres->data, |
2245 | pres->data_size); | 2268 | pres->data_size); |
2269 | atle->presentation->credential_id = pres->credential_id; | ||
2246 | GNUNET_CONTAINER_DLL_insert (handle->presentations->list_head, | 2270 | GNUNET_CONTAINER_DLL_insert (handle->presentations->list_head, |
2247 | handle->presentations->list_tail, | 2271 | handle->presentations->list_tail, |
2248 | atle); | 2272 | atle); |
@@ -2292,6 +2316,8 @@ consume_timeout (void*cls) | |||
2292 | handle->edesc = GNUNET_strdup ("invalid code"); | 2316 | handle->edesc = GNUNET_strdup ("invalid code"); |
2293 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 2317 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
2294 | GNUNET_free (cached_code); | 2318 | GNUNET_free (cached_code); |
2319 | if (NULL != nonce) | ||
2320 | GNUNET_free (nonce); | ||
2295 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2321 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2296 | return; | 2322 | return; |
2297 | } | 2323 | } |
@@ -2336,7 +2362,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2336 | const struct EgoEntry *aud_ego; | 2362 | const struct EgoEntry *aud_ego; |
2337 | const struct GNUNET_IDENTITY_PrivateKey *privkey; | 2363 | const struct GNUNET_IDENTITY_PrivateKey *privkey; |
2338 | 2364 | ||
2339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Getting userinfo\n"); | 2365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting userinfo\n"); |
2340 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, | 2366 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, |
2341 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), | 2367 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), |
2342 | &cache_key); | 2368 | &cache_key); |
@@ -2402,7 +2428,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2402 | GNUNET_free (authorization); | 2428 | GNUNET_free (authorization); |
2403 | return; | 2429 | return; |
2404 | } | 2430 | } |
2405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Consuming ticket\n"); | 2431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Consuming ticket\n"); |
2406 | privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); | 2432 | privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); |
2407 | handle->attr_userinfo_list = | 2433 | handle->attr_userinfo_list = |
2408 | GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 2434 | GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
@@ -2616,6 +2642,7 @@ oidc_config_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2616 | oidc_config_str = json_dumps (oidc_config, JSON_INDENT (1)); | 2642 | oidc_config_str = json_dumps (oidc_config, JSON_INDENT (1)); |
2617 | resp = GNUNET_REST_create_response (oidc_config_str); | 2643 | resp = GNUNET_REST_create_response (oidc_config_str); |
2618 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 2644 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
2645 | json_decref (oidc_config); | ||
2619 | GNUNET_free (oidc_config_str); | 2646 | GNUNET_free (oidc_config_str); |
2620 | cleanup_handle (handle); | 2647 | cleanup_handle (handle); |
2621 | } | 2648 | } |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 022744c82..84456b386 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -974,9 +974,11 @@ attr_collect (void *cls, | |||
974 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, | 974 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, |
975 | sizeof(attr->id)); | 975 | sizeof(attr->id)); |
976 | json_object_set_new (attr_obj, "id", json_string (id_str)); | 976 | json_object_set_new (attr_obj, "id", json_string (id_str)); |
977 | GNUNET_free (id_str); | ||
977 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential, | 978 | id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential, |
978 | sizeof(attr->credential)); | 979 | sizeof(attr->credential)); |
979 | json_object_set_new (attr_obj, "credential", json_string (id_str)); | 980 | json_object_set_new (attr_obj, "credential", json_string (id_str)); |
981 | GNUNET_free (id_str); | ||
980 | json_array_append (handle->resp_object, attr_obj); | 982 | json_array_append (handle->resp_object, attr_obj); |
981 | json_decref (attr_obj); | 983 | json_decref (attr_obj); |
982 | GNUNET_free (tmp_value); | 984 | GNUNET_free (tmp_value); |
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c index 2217987ac..14690d7c9 100644 --- a/src/reclaim/reclaim_attribute.c +++ b/src/reclaim/reclaim_attribute.c | |||
@@ -102,6 +102,37 @@ init () | |||
102 | NULL); | 102 | NULL); |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | ||
106 | * Dual function to #init(). | ||
107 | */ | ||
108 | void __attribute__ ((destructor)) | ||
109 | RECLAIM_ATTRIBUTE_fini () | ||
110 | { | ||
111 | struct Plugin *plugin; | ||
112 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); | ||
113 | const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); | ||
114 | |||
115 | if (pd != dpd) | ||
116 | GNUNET_OS_init (dpd); | ||
117 | |||
118 | for (unsigned int i = 0; i < num_plugins; i++) | ||
119 | { | ||
120 | plugin = attr_plugins[i]; | ||
121 | GNUNET_break (NULL == | ||
122 | GNUNET_PLUGIN_unload (plugin->library_name, | ||
123 | plugin->api)); | ||
124 | GNUNET_free (plugin->library_name); | ||
125 | GNUNET_free (plugin); | ||
126 | } | ||
127 | GNUNET_free (attr_plugins); | ||
128 | |||
129 | if (pd != dpd) | ||
130 | GNUNET_OS_init (pd); | ||
131 | |||
132 | attr_plugins = NULL; | ||
133 | } | ||
134 | |||
135 | |||
105 | 136 | ||
106 | /** | 137 | /** |
107 | * Convert a type name to the corresponding number | 138 | * Convert a type name to the corresponding number |
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c index 5c8974400..05601c3d3 100644 --- a/src/reclaim/reclaim_credential.c +++ b/src/reclaim/reclaim_credential.c | |||
@@ -104,6 +104,38 @@ init () | |||
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Dual function to #init(). | ||
108 | */ | ||
109 | void __attribute__ ((destructor)) | ||
110 | RECLAIM_CREDENTIAL_fini () | ||
111 | { | ||
112 | struct Plugin *plugin; | ||
113 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); | ||
114 | const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); | ||
115 | |||
116 | if (pd != dpd) | ||
117 | GNUNET_OS_init (dpd); | ||
118 | |||
119 | for (unsigned int i = 0; i < num_plugins; i++) | ||
120 | { | ||
121 | plugin = credential_plugins[i]; | ||
122 | GNUNET_break (NULL == | ||
123 | GNUNET_PLUGIN_unload (plugin->library_name, | ||
124 | plugin->api)); | ||
125 | GNUNET_free (plugin->library_name); | ||
126 | GNUNET_free (plugin); | ||
127 | } | ||
128 | GNUNET_free (credential_plugins); | ||
129 | |||
130 | if (pd != dpd) | ||
131 | GNUNET_OS_init (pd); | ||
132 | |||
133 | credential_plugins = NULL; | ||
134 | } | ||
135 | |||
136 | |||
137 | |||
138 | /** | ||
107 | * Convert an credential type name to the corresponding number | 139 | * Convert an credential type name to the corresponding number |
108 | * | 140 | * |
109 | * @param typename name to convert | 141 | * @param typename name to convert |
@@ -721,7 +753,6 @@ GNUNET_RECLAIM_presentation_list_serialize_get_size ( | |||
721 | { | 753 | { |
722 | GNUNET_assert (NULL != le->presentation); | 754 | GNUNET_assert (NULL != le->presentation); |
723 | len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation); | 755 | len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation); |
724 | len += sizeof(struct GNUNET_RECLAIM_PresentationListEntry); | ||
725 | } | 756 | } |
726 | return len; | 757 | return len; |
727 | } | 758 | } |
@@ -774,8 +805,7 @@ GNUNET_RECLAIM_presentation_list_deserialize (const char *data, size_t | |||
774 | 805 | ||
775 | al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); | 806 | al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
776 | 807 | ||
777 | if ((data_size < sizeof(struct Presentation) | 808 | if (data_size < sizeof(struct Presentation)) |
778 | + sizeof(struct GNUNET_RECLAIM_PresentationListEntry))) | ||
779 | return al; | 809 | return al; |
780 | 810 | ||
781 | read_ptr = data; | 811 | read_ptr = data; |
diff --git a/src/reclaim/test_reclaim_consume.sh b/src/reclaim/test_reclaim_consume.sh index 55f6ff22c..9186d3cb1 100755 --- a/src/reclaim/test_reclaim_consume.sh +++ b/src/reclaim/test_reclaim_consume.sh | |||
@@ -6,7 +6,7 @@ if [ -z $LOCATION ] | |||
6 | then | 6 | then |
7 | LOCATION="gnunet-config" | 7 | LOCATION="gnunet-config" |
8 | fi | 8 | fi |
9 | $LOCATION --version 1> /dev/null | 9 | $LOCATION --version 1>/dev/null |
10 | if test $? != 0 | 10 | if test $? != 0 |
11 | then | 11 | then |
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | 12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" |
@@ -20,7 +20,7 @@ rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | |||
20 | # (3) PKEY3.user -> PKEY4 | 20 | # (3) PKEY3.user -> PKEY4 |
21 | 21 | ||
22 | 22 | ||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 23 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
24 | 24 | ||
25 | TEST_ATTR="test" | 25 | TEST_ATTR="test" |
26 | gnunet-arm -s -c test_reclaim.conf | 26 | gnunet-arm -s -c test_reclaim.conf |
@@ -32,7 +32,7 @@ TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf) | |||
32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | 32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf |
33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf | 33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf |
34 | TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}') | 34 | TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}') |
35 | gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf > /dev/null 2>&1 | 35 | gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf >/dev/null 2>&1 |
36 | 36 | ||
37 | if test $? != 0 | 37 | if test $? != 0 |
38 | then | 38 | then |
diff --git a/src/reclaim/test_reclaim_issue.sh b/src/reclaim/test_reclaim_issue.sh index 7ab8a6980..cfddc9407 100755 --- a/src/reclaim/test_reclaim_issue.sh +++ b/src/reclaim/test_reclaim_issue.sh | |||
@@ -20,7 +20,7 @@ rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | |||
20 | # (3) PKEY3.user -> PKEY4 | 20 | # (3) PKEY3.user -> PKEY4 |
21 | 21 | ||
22 | 22 | ||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 23 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
24 | 24 | ||
25 | TEST_ATTR="test" | 25 | TEST_ATTR="test" |
26 | gnunet-arm -s -c test_reclaim.conf | 26 | gnunet-arm -s -c test_reclaim.conf |
diff --git a/src/reclaim/test_reclaim_revoke.sh b/src/reclaim/test_reclaim_revoke.sh index ffbc7ef2b..da091a1ee 100755 --- a/src/reclaim/test_reclaim_revoke.sh +++ b/src/reclaim/test_reclaim_revoke.sh | |||
@@ -20,10 +20,10 @@ rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | |||
20 | # (3) PKEY3.user -> PKEY4 | 20 | # (3) PKEY3.user -> PKEY4 |
21 | 21 | ||
22 | 22 | ||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 23 | which timeout >/dev/null 2&>1 && DO_TIMEOUT="timeout 30" |
24 | 24 | ||
25 | TEST_ATTR="test" | 25 | TEST_ATTR="test" |
26 | gnunet-arm -s -c test_reclaim.conf 2&>1 > /dev/null | 26 | gnunet-arm -s -c test_reclaim.conf >/dev/null 2&>1 |
27 | gnunet-identity -C alice -c test_reclaim.conf | 27 | gnunet-identity -C alice -c test_reclaim.conf |
28 | gnunet-identity -C bob -c test_reclaim.conf | 28 | gnunet-identity -C bob -c test_reclaim.conf |
29 | gnunet-identity -C eve -c test_reclaim.conf | 29 | gnunet-identity -C eve -c test_reclaim.conf |
@@ -43,7 +43,7 @@ sleep 16 | |||
43 | echo "Consuming $TICKET" | 43 | echo "Consuming $TICKET" |
44 | 44 | ||
45 | gnunet-reclaim -e eve -C $TICKET_EVE -c test_reclaim.conf | 45 | gnunet-reclaim -e eve -C $TICKET_EVE -c test_reclaim.conf |
46 | if test $? == 0 | 46 | if test $? = 0 |
47 | then | 47 | then |
48 | echo "Eve can still resolve attributes..." | 48 | echo "Eve can still resolve attributes..." |
49 | gnunet-arm -e -c test_reclaim.conf | 49 | gnunet-arm -e -c test_reclaim.conf |
@@ -51,10 +51,10 @@ then | |||
51 | fi | 51 | fi |
52 | 52 | ||
53 | gnunet-arm -e -c test_reclaim.conf | 53 | gnunet-arm -e -c test_reclaim.conf |
54 | gnunet-arm -s -c test_reclaim.conf 2&>1 > /dev/null | 54 | gnunet-arm -s -c test_reclaim.conf >/dev/null 2&>1 |
55 | 55 | ||
56 | gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf | 56 | gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf |
57 | #gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf 2&>1 >/dev/null | 57 | #gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf >/dev/null 2&>1 |
58 | if test $? != 0 | 58 | if test $? != 0 |
59 | then | 59 | then |
60 | echo "Bob cannot resolve attributes..." | 60 | echo "Bob cannot resolve attributes..." |
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index d59ea7c81..b5737158b 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -230,7 +230,7 @@ sync_pow () | |||
230 | { | 230 | { |
231 | size_t psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); | 231 | size_t psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); |
232 | if ((NULL != filename) && | 232 | if ((NULL != filename) && |
233 | (psize != | 233 | (GNUNET_OK != |
234 | GNUNET_DISK_fn_write (filename, | 234 | GNUNET_DISK_fn_write (filename, |
235 | proof_of_work, | 235 | proof_of_work, |
236 | psize, | 236 | psize, |
@@ -280,14 +280,17 @@ calculate_pow (void *cls) | |||
280 | if (GNUNET_OK == GNUNET_REVOCATION_pow_round (ph)) | 280 | if (GNUNET_OK == GNUNET_REVOCATION_pow_round (ph)) |
281 | { | 281 | { |
282 | psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); | 282 | psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); |
283 | if ((NULL != filename) && | 283 | if (NULL != filename) |
284 | (psize != | 284 | { |
285 | GNUNET_DISK_fn_write (filename, | 285 | (void) GNUNET_DISK_directory_remove (filename); |
286 | proof_of_work, | 286 | if (GNUNET_OK != |
287 | psize, | 287 | GNUNET_DISK_fn_write (filename, |
288 | GNUNET_DISK_PERM_USER_READ | 288 | proof_of_work, |
289 | | GNUNET_DISK_PERM_USER_WRITE))) | 289 | psize, |
290 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename); | 290 | GNUNET_DISK_PERM_USER_READ |
291 | | GNUNET_DISK_PERM_USER_WRITE)) | ||
292 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename); | ||
293 | } | ||
291 | if (perform) | 294 | if (perform) |
292 | { | 295 | { |
293 | perform_revocation (); | 296 | perform_revocation (); |
diff --git a/src/scalarproduct/test_scalarproduct.sh b/src/scalarproduct/test_scalarproduct.sh index c0401beb7..ed91cd5c4 100755 --- a/src/scalarproduct/test_scalarproduct.sh +++ b/src/scalarproduct/test_scalarproduct.sh | |||
@@ -25,7 +25,7 @@ echo "Waiting for peers to start..." | |||
25 | sleep 5 | 25 | sleep 5 |
26 | echo "Running test..." | 26 | echo "Running test..." |
27 | 27 | ||
28 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 28 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
29 | 29 | ||
30 | # get bob's peer ID, necessary for alice | 30 | # get bob's peer ID, necessary for alice |
31 | PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB` | 31 | PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB` |
@@ -38,7 +38,7 @@ RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` | |||
38 | # terminate the testbed | 38 | # terminate the testbed |
39 | kill $PID | 39 | kill $PID |
40 | 40 | ||
41 | if [ "$RESULT" == "$EXPECTED" ] | 41 | if [ "$RESULT" = "$EXPECTED" ] |
42 | then | 42 | then |
43 | echo "OK" | 43 | echo "OK" |
44 | exit 0 | 44 | exit 0 |
diff --git a/src/scalarproduct/test_scalarproduct_negative.sh b/src/scalarproduct/test_scalarproduct_negative.sh index cbeb1b9fd..b08e4527f 100755 --- a/src/scalarproduct/test_scalarproduct_negative.sh +++ b/src/scalarproduct/test_scalarproduct_negative.sh | |||
@@ -11,7 +11,7 @@ PREFIX=/tmp/test-scalarproduct`date +%H%M%S` | |||
11 | CFGALICE="-c $PREFIX/0/config" | 11 | CFGALICE="-c $PREFIX/0/config" |
12 | CFGBOB="-c $PREFIX/1/config" | 12 | CFGBOB="-c $PREFIX/1/config" |
13 | 13 | ||
14 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 14 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
15 | 15 | ||
16 | # launch two peers in line topology non-interactively | 16 | # launch two peers in line topology non-interactively |
17 | # | 17 | # |
@@ -36,7 +36,7 @@ RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` | |||
36 | kill $PID | 36 | kill $PID |
37 | 37 | ||
38 | EXPECTED="-0CCC" | 38 | EXPECTED="-0CCC" |
39 | if [ "$RESULT" == "$EXPECTED" ] | 39 | if [ "$RESULT" = "$EXPECTED" ] |
40 | then | 40 | then |
41 | echo "OK" | 41 | echo "OK" |
42 | exit 0 | 42 | exit 0 |
diff --git a/src/scalarproduct/test_scalarproduct_negativezero.sh b/src/scalarproduct/test_scalarproduct_negativezero.sh index 1ab7157af..6f80b2ea2 100755 --- a/src/scalarproduct/test_scalarproduct_negativezero.sh +++ b/src/scalarproduct/test_scalarproduct_negativezero.sh | |||
@@ -22,7 +22,7 @@ PID=$! | |||
22 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe | 22 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe |
23 | sleep 5 | 23 | sleep 5 |
24 | 24 | ||
25 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 25 | which timeout >/dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
26 | 26 | ||
27 | # get bob's peer ID, necessary for alice | 27 | # get bob's peer ID, necessary for alice |
28 | PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB` | 28 | PEERIDBOB=`${DO_TIMEOUT} gnunet-peerinfo -qs $CFGBOB` |
@@ -36,7 +36,7 @@ RESULT=`${DO_TIMEOUT} gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` | |||
36 | kill $PID | 36 | kill $PID |
37 | 37 | ||
38 | EXPECTED="00" | 38 | EXPECTED="00" |
39 | if [ "$RESULT" == "$EXPECTED" ] | 39 | if [ "$RESULT" = "$EXPECTED" ] |
40 | then | 40 | then |
41 | echo "OK" | 41 | echo "OK" |
42 | exit 0 | 42 | exit 0 |
diff --git a/src/testbed/gnunet_mpi_test.c b/src/testbed/gnunet_mpi_test.c index e0caf9676..2ee707fe6 100644 --- a/src/testbed/gnunet_mpi_test.c +++ b/src/testbed/gnunet_mpi_test.c | |||
@@ -49,7 +49,8 @@ main (int argc, char *argv[]) | |||
49 | (void) GNUNET_asprintf (&filename, "%d-%d.mpiout", (int) pid, rank); | 49 | (void) GNUNET_asprintf (&filename, "%d-%d.mpiout", (int) pid, rank); |
50 | msg_size = GNUNET_asprintf (&msg, "My rank is: %d\n", rank); | 50 | msg_size = GNUNET_asprintf (&msg, "My rank is: %d\n", rank); |
51 | printf ("%s", msg); | 51 | printf ("%s", msg); |
52 | if (msg_size == | 52 | (void) GNUNET_DISK_directory_remove (filename); |
53 | if (GNUNET_OK == | ||
53 | GNUNET_DISK_fn_write (filename, msg, msg_size, | 54 | GNUNET_DISK_fn_write (filename, msg, msg_size, |
54 | GNUNET_DISK_PERM_USER_READ | 55 | GNUNET_DISK_PERM_USER_READ |
55 | | GNUNET_DISK_PERM_GROUP_READ | 56 | | GNUNET_DISK_PERM_GROUP_READ |
diff --git a/src/topology/friends.c b/src/topology/friends.c index a3b15d8f7..65c7e81d7 100644 --- a/src/topology/friends.c +++ b/src/topology/friends.c | |||
@@ -59,15 +59,6 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
59 | "FRIENDS"); | 59 | "FRIENDS"); |
60 | return GNUNET_SYSERR; | 60 | return GNUNET_SYSERR; |
61 | } | 61 | } |
62 | if (GNUNET_SYSERR == | ||
63 | GNUNET_DISK_directory_create_for_file (fn)) | ||
64 | { | ||
65 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
66 | "mkdir", | ||
67 | fn); | ||
68 | GNUNET_free (fn); | ||
69 | return GNUNET_SYSERR; | ||
70 | } | ||
71 | if ((GNUNET_OK != | 62 | if ((GNUNET_OK != |
72 | GNUNET_DISK_file_test (fn)) && | 63 | GNUNET_DISK_file_test (fn)) && |
73 | (GNUNET_OK != | 64 | (GNUNET_OK != |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0f9d40e13..a2fc3811e 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -131,8 +131,9 @@ noinst_PROGRAMS = \ | |||
131 | $(WLAN_BIN_RECEIVER) | 131 | $(WLAN_BIN_RECEIVER) |
132 | 132 | ||
133 | if HAVE_TESTING | 133 | if HAVE_TESTING |
134 | TESTING_LIBS = libgnunettransporttesting.la \ | 134 | TESTING_LIBS = \ |
135 | libgnunettransporttesting2.la | 135 | libgnunettransporttesting.la \ |
136 | libgnunettransporttesting2.la | ||
136 | endif | 137 | endif |
137 | 138 | ||
138 | lib_LTLIBRARIES = \ | 139 | lib_LTLIBRARIES = \ |
@@ -174,6 +175,7 @@ libgnunettransporttesting2_la_LIBADD = \ | |||
174 | libgnunettransport.la \ | 175 | libgnunettransport.la \ |
175 | libgnunettransportapplication.la \ | 176 | libgnunettransportapplication.la \ |
176 | libgnunettransportcore.la \ | 177 | libgnunettransportcore.la \ |
178 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
177 | $(top_builddir)/src/testing/libgnunettesting.la \ | 179 | $(top_builddir)/src/testing/libgnunettesting.la \ |
178 | $(top_builddir)/src/ats/libgnunetats.la \ | 180 | $(top_builddir)/src/ats/libgnunetats.la \ |
179 | $(top_builddir)/src/hello/libgnunethello.la \ | 181 | $(top_builddir)/src/hello/libgnunethello.la \ |
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 1f87ba6d4..018da8f0e 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1464,7 +1464,7 @@ destroy_all_secrets (struct SharedSecret *ss, int withoutKce) | |||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | pos = ss_start; | 1466 | pos = ss_start; |
1467 | while ( NULL != pos) | 1467 | while (NULL != pos) |
1468 | { | 1468 | { |
1469 | ss_to_destroy = pos; | 1469 | ss_to_destroy = pos; |
1470 | pos = pos->next; | 1470 | pos = pos->next; |
@@ -1484,6 +1484,7 @@ destroy_all_secrets (struct SharedSecret *ss, int withoutKce) | |||
1484 | "Finished destroy all.\n"); | 1484 | "Finished destroy all.\n"); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | |||
1487 | static void | 1488 | static void |
1488 | add_acks (struct SharedSecret *ss, int acks_to_add) | 1489 | add_acks (struct SharedSecret *ss, int acks_to_add) |
1489 | { | 1490 | { |
@@ -1520,6 +1521,7 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1520 | destroy_all_secrets (ss, GNUNET_YES); | 1521 | destroy_all_secrets (ss, GNUNET_YES); |
1521 | } | 1522 | } |
1522 | 1523 | ||
1524 | |||
1523 | static uint32_t | 1525 | static uint32_t |
1524 | reset_rekey_kces (struct ReceiverAddress *receiver, | 1526 | reset_rekey_kces (struct ReceiverAddress *receiver, |
1525 | uint32_t acks_to_add) | 1527 | uint32_t acks_to_add) |
@@ -1550,6 +1552,7 @@ reset_rekey_kces (struct ReceiverAddress *receiver, | |||
1550 | return acks_to_add; | 1552 | return acks_to_add; |
1551 | } | 1553 | } |
1552 | 1554 | ||
1555 | |||
1553 | static void | 1556 | static void |
1554 | add_acks_rekey (struct ReceiverAddress *receiver) | 1557 | add_acks_rekey (struct ReceiverAddress *receiver) |
1555 | { | 1558 | { |
@@ -1575,6 +1578,7 @@ add_acks_rekey (struct ReceiverAddress *receiver) | |||
1575 | GNUNET_NO); | 1578 | GNUNET_NO); |
1576 | } | 1579 | } |
1577 | 1580 | ||
1581 | |||
1578 | /** | 1582 | /** |
1579 | * We received an ACK for @a pid. Check if it is for | 1583 | * We received an ACK for @a pid. Check if it is for |
1580 | * the receiver in @a value and if so, handle it and | 1584 | * the receiver in @a value and if so, handle it and |
@@ -1736,7 +1740,6 @@ try_handle_plaintext (struct SenderAddress *sender, | |||
1736 | } | 1740 | } |
1737 | 1741 | ||
1738 | 1742 | ||
1739 | |||
1740 | static void | 1743 | static void |
1741 | kce_generate_cb (void *cls) | 1744 | kce_generate_cb (void *cls) |
1742 | { | 1745 | { |
@@ -1771,6 +1774,7 @@ kce_generate_cb (void *cls) | |||
1771 | 1774 | ||
1772 | } | 1775 | } |
1773 | 1776 | ||
1777 | |||
1774 | static void | 1778 | static void |
1775 | kce_generate_rekey_cb (void *cls) | 1779 | kce_generate_rekey_cb (void *cls) |
1776 | { | 1780 | { |
@@ -1870,7 +1874,8 @@ consider_ss_ack (struct SharedSecret *ss, int initial) | |||
1870 | kce_task_finished = GNUNET_NO; | 1874 | kce_task_finished = GNUNET_NO; |
1871 | } | 1875 | } |
1872 | } | 1876 | } |
1873 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > ss->sender->acks_available)|| | 1877 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > |
1878 | ss->sender->acks_available) || | ||
1874 | (GNUNET_YES == ss->sender->rekeying) || | 1879 | (GNUNET_YES == ss->sender->rekeying) || |
1875 | (ss->sender->num_secrets > MAX_SECRETS) )) | 1880 | (ss->sender->num_secrets > MAX_SECRETS) )) |
1876 | { | 1881 | { |
@@ -1945,13 +1950,15 @@ decrypt_box (const struct UDPBox *box, | |||
1945 | } | 1950 | } |
1946 | else if (GNUNET_NO == box->rekeying) | 1951 | else if (GNUNET_NO == box->rekeying) |
1947 | consider_ss_ack (ss, GNUNET_NO); | 1952 | consider_ss_ack (ss, GNUNET_NO); |
1948 | else{ | 1953 | else |
1954 | { | ||
1949 | ss->sender->rekeying = GNUNET_YES; | 1955 | ss->sender->rekeying = GNUNET_YES; |
1950 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1951 | "Got Box: Receiver doing rekeying.\n"); | 1957 | "Got Box: Receiver doing rekeying.\n"); |
1952 | } | 1958 | } |
1953 | } | 1959 | } |
1954 | 1960 | ||
1961 | |||
1955 | /** | 1962 | /** |
1956 | * We received a @a rekey with matching @a kce. Decrypt and process it. | 1963 | * We received a @a rekey with matching @a kce. Decrypt and process it. |
1957 | * | 1964 | * |
@@ -2039,6 +2046,7 @@ decrypt_rekey (const struct UDPRekey *rekey, | |||
2039 | 2046 | ||
2040 | } | 2047 | } |
2041 | 2048 | ||
2049 | |||
2042 | /** | 2050 | /** |
2043 | * Closure for #find_sender_by_address() | 2051 | * Closure for #find_sender_by_address() |
2044 | */ | 2052 | */ |
@@ -2249,15 +2257,16 @@ sock_read (void *cls) | |||
2249 | box = (const struct UDPBox *) buf; | 2257 | box = (const struct UDPBox *) buf; |
2250 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &rekey->kid); | 2258 | kce = GNUNET_CONTAINER_multishortmap_get (key_cache, &rekey->kid); |
2251 | 2259 | ||
2252 | if ((GNUNET_YES == box->rekeying)||(GNUNET_NO == box->rekeying)) | 2260 | if ((GNUNET_YES == box->rekeying) || (GNUNET_NO == box->rekeying)) |
2253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2254 | "UDPRekey has rekeying %u\n", | 2262 | "UDPRekey has rekeying %u\n", |
2255 | box->rekeying); | 2263 | box->rekeying); |
2256 | else | 2264 | else |
2257 | do_decrypt = GNUNET_YES; | 2265 | do_decrypt = GNUNET_YES; |
2258 | 2266 | ||
2259 | if ((GNUNET_YES == do_decrypt)&& (NULL != kce) && (GNUNET_YES == | 2267 | if ((GNUNET_YES == do_decrypt) && (NULL != kce) && (GNUNET_YES == |
2260 | kce->ss->sender->rekeying)) | 2268 | kce->ss->sender-> |
2269 | rekeying)) | ||
2261 | { | 2270 | { |
2262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2263 | "UDPRekey with kid %s\n", | 2272 | "UDPRekey with kid %s\n", |
@@ -2400,7 +2409,8 @@ sock_read (void *cls) | |||
2400 | } | 2409 | } |
2401 | else if (GNUNET_NO == kx->rekeying) | 2410 | else if (GNUNET_NO == kx->rekeying) |
2402 | consider_ss_ack (ss, GNUNET_YES); | 2411 | consider_ss_ack (ss, GNUNET_YES); |
2403 | else{ | 2412 | else |
2413 | { | ||
2404 | ss->sender->rekeying = GNUNET_YES; | 2414 | ss->sender->rekeying = GNUNET_YES; |
2405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2406 | "Got KX: Receiver doing rekeying.\n"); | 2416 | "Got KX: Receiver doing rekeying.\n"); |
@@ -2664,6 +2674,7 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2664 | GNUNET_MQ_impl_send_continue (mq); | 2674 | GNUNET_MQ_impl_send_continue (mq); |
2665 | } | 2675 | } |
2666 | 2676 | ||
2677 | |||
2667 | static void | 2678 | static void |
2668 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | 2679 | check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) |
2669 | { | 2680 | { |
@@ -2687,8 +2698,8 @@ check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | |||
2687 | rt.rel_value_us, | 2698 | rt.rel_value_us, |
2688 | receiver->rekey_timeout.abs_value_us); | 2699 | receiver->rekey_timeout.abs_value_us); |
2689 | 2700 | ||
2690 | if ((0 == rt.rel_value_us)||(receiver->rekey_send_bytes > | 2701 | if ((0 == rt.rel_value_us) || (receiver->rekey_send_bytes > |
2691 | rekey_max_bytes) ) | 2702 | rekey_max_bytes) ) |
2692 | { | 2703 | { |
2693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2694 | "Bytes send %lu greater than %llu max bytes\n.", | 2705 | "Bytes send %lu greater than %llu max bytes\n.", |
@@ -2716,6 +2727,7 @@ check_for_rekeying (struct ReceiverAddress *receiver, struct UDPBox *box) | |||
2716 | } | 2727 | } |
2717 | } | 2728 | } |
2718 | 2729 | ||
2730 | |||
2719 | static void | 2731 | static void |
2720 | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) | 2732 | send_UDPRekey (struct ReceiverAddress *receiver, struct SharedSecret *ss) |
2721 | { | 2733 | { |
@@ -3283,14 +3295,17 @@ do_shutdown (void *cls) | |||
3283 | } | 3295 | } |
3284 | if (NULL != udp_sock) | 3296 | if (NULL != udp_sock) |
3285 | { | 3297 | { |
3286 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (udp_sock)); | 3298 | GNUNET_break (GNUNET_OK == |
3299 | GNUNET_NETWORK_socket_close (udp_sock)); | ||
3287 | udp_sock = NULL; | 3300 | udp_sock = NULL; |
3288 | } | 3301 | } |
3289 | GNUNET_CONTAINER_multipeermap_iterate (receivers, | 3302 | GNUNET_CONTAINER_multipeermap_iterate (receivers, |
3290 | &get_receiver_delete_it, | 3303 | &get_receiver_delete_it, |
3291 | NULL); | 3304 | NULL); |
3292 | GNUNET_CONTAINER_multipeermap_destroy (receivers); | 3305 | GNUNET_CONTAINER_multipeermap_destroy (receivers); |
3293 | GNUNET_CONTAINER_multipeermap_iterate (senders, &get_sender_delete_it, NULL); | 3306 | GNUNET_CONTAINER_multipeermap_iterate (senders, |
3307 | &get_sender_delete_it, | ||
3308 | NULL); | ||
3294 | GNUNET_CONTAINER_multipeermap_destroy (senders); | 3309 | GNUNET_CONTAINER_multipeermap_destroy (senders); |
3295 | GNUNET_CONTAINER_multishortmap_destroy (key_cache); | 3310 | GNUNET_CONTAINER_multishortmap_destroy (key_cache); |
3296 | GNUNET_CONTAINER_heap_destroy (senders_heap); | 3311 | GNUNET_CONTAINER_heap_destroy (senders_heap); |
@@ -3438,25 +3453,29 @@ ifc_broadcast (void *cls) | |||
3438 | static int no = 0; | 3453 | static int no = 0; |
3439 | ssize_t sent; | 3454 | ssize_t sent; |
3440 | 3455 | ||
3441 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, | 3456 | if (GNUNET_OK != |
3442 | SOL_SOCKET, | 3457 | GNUNET_NETWORK_socket_setsockopt (udp_sock, |
3443 | SO_BROADCAST, | 3458 | SOL_SOCKET, |
3444 | &yes, | 3459 | SO_BROADCAST, |
3445 | sizeof(int))) | 3460 | &yes, |
3446 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 3461 | sizeof(int))) |
3462 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | ||
3463 | "setsockopt"); | ||
3447 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, | 3464 | sent = GNUNET_NETWORK_socket_sendto (udp_sock, |
3448 | &bi->bcm, | 3465 | &bi->bcm, |
3449 | sizeof(bi->bcm), | 3466 | sizeof(bi->bcm), |
3450 | bi->ba, | 3467 | bi->ba, |
3451 | bi->salen); | 3468 | bi->salen); |
3452 | if (-1 == sent) | 3469 | if (-1 == sent) |
3453 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto"); | 3470 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
3471 | "sendto"); | ||
3454 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, | 3472 | if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, |
3455 | SOL_SOCKET, | 3473 | SOL_SOCKET, |
3456 | SO_BROADCAST, | 3474 | SO_BROADCAST, |
3457 | &no, | 3475 | &no, |
3458 | sizeof(int))) | 3476 | sizeof(int))) |
3459 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 3477 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
3478 | "setsockopt"); | ||
3460 | break; | 3479 | break; |
3461 | } | 3480 | } |
3462 | 3481 | ||
@@ -3538,9 +3557,18 @@ iface_proc (void *cls, | |||
3538 | return GNUNET_OK; /* not using IPv6 */ | 3557 | return GNUNET_OK; /* not using IPv6 */ |
3539 | 3558 | ||
3540 | bi = GNUNET_new (struct BroadcastInterface); | 3559 | bi = GNUNET_new (struct BroadcastInterface); |
3541 | bi->sa = GNUNET_memdup (addr, addrlen); | 3560 | bi->sa = GNUNET_memdup (addr, |
3542 | if (NULL != broadcast_addr) | 3561 | addrlen); |
3543 | bi->ba = GNUNET_memdup (broadcast_addr, addrlen); | 3562 | if ( (NULL != broadcast_addr) && |
3563 | (addrlen == sizeof (struct sockaddr_in)) ) | ||
3564 | { | ||
3565 | struct sockaddr_in *ba; | ||
3566 | |||
3567 | ba = GNUNET_memdup (broadcast_addr, | ||
3568 | addrlen); | ||
3569 | ba->sin_port = htons (2086); /* always GNUnet port, ignore configuration! */ | ||
3570 | bi->ba = (struct sockaddr *) ba; | ||
3571 | } | ||
3544 | bi->salen = addrlen; | 3572 | bi->salen = addrlen; |
3545 | bi->found = GNUNET_YES; | 3573 | bi->found = GNUNET_YES; |
3546 | bi->bcm.sender = my_identity; | 3574 | bi->bcm.sender = my_identity; |
@@ -3551,7 +3579,7 @@ iface_proc (void *cls, | |||
3551 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 3579 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
3552 | &ubs, | 3580 | &ubs, |
3553 | &bi->bcm.sender_sig); | 3581 | &bi->bcm.sender_sig); |
3554 | if (NULL != broadcast_addr) | 3582 | if (NULL != bi->ba) |
3555 | { | 3583 | { |
3556 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); | 3584 | bi->broadcast_task = GNUNET_SCHEDULER_add_now (&ifc_broadcast, bi); |
3557 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); | 3585 | GNUNET_CONTAINER_DLL_insert (bi_head, bi_tail, bi); |
@@ -3675,7 +3703,9 @@ run (void *cls, | |||
3675 | return; | 3703 | return; |
3676 | } | 3704 | } |
3677 | udp_sock = | 3705 | udp_sock = |
3678 | GNUNET_NETWORK_socket_create (in->sa_family, SOCK_DGRAM, IPPROTO_UDP); | 3706 | GNUNET_NETWORK_socket_create (in->sa_family, |
3707 | SOCK_DGRAM, | ||
3708 | IPPROTO_UDP); | ||
3679 | if (NULL == udp_sock) | 3709 | if (NULL == udp_sock) |
3680 | { | 3710 | { |
3681 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 3711 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
@@ -3685,9 +3715,14 @@ run (void *cls, | |||
3685 | } | 3715 | } |
3686 | if (AF_INET6 == in->sa_family) | 3716 | if (AF_INET6 == in->sa_family) |
3687 | have_v6_socket = GNUNET_YES; | 3717 | have_v6_socket = GNUNET_YES; |
3688 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (udp_sock, in, in_len)) | 3718 | if (GNUNET_OK != |
3719 | GNUNET_NETWORK_socket_bind (udp_sock, | ||
3720 | in, | ||
3721 | in_len)) | ||
3689 | { | 3722 | { |
3690 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "bind", bindto); | 3723 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
3724 | "bind", | ||
3725 | bindto); | ||
3691 | GNUNET_NETWORK_socket_close (udp_sock); | 3726 | GNUNET_NETWORK_socket_close (udp_sock); |
3692 | udp_sock = NULL; | 3727 | udp_sock = NULL; |
3693 | GNUNET_free (in); | 3728 | GNUNET_free (in); |
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 0eeaecb6c..1f85a9895 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -137,12 +137,12 @@ static struct GNUNET_TIME_Relative duration; | |||
137 | 137 | ||
138 | 138 | ||
139 | static void | 139 | static void |
140 | communicator_available_cb (void *cls, | 140 | communicator_available_cb ( |
141 | struct | 141 | void *cls, |
142 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 142 | struct |
143 | *tc_h, | 143 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
144 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, | 144 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, |
145 | char *address_prefix) | 145 | char *address_prefix) |
146 | { | 146 | { |
147 | LOG (GNUNET_ERROR_TYPE_INFO, | 147 | LOG (GNUNET_ERROR_TYPE_INFO, |
148 | "Communicator available. (cc: %u, prefix: %s)\n", | 148 | "Communicator available. (cc: %u, prefix: %s)\n", |
@@ -150,10 +150,11 @@ communicator_available_cb (void *cls, | |||
150 | address_prefix); | 150 | address_prefix); |
151 | } | 151 | } |
152 | 152 | ||
153 | |||
153 | static void | 154 | static void |
154 | open_queue (void *cls) | 155 | open_queue (void *cls) |
155 | { | 156 | { |
156 | char *address = cls; | 157 | const char *address = cls; |
157 | 158 | ||
158 | if (NULL != tc_hs[PEER_A]->c_mq) | 159 | if (NULL != tc_hs[PEER_A]->c_mq) |
159 | { | 160 | { |
@@ -166,30 +167,32 @@ open_queue (void *cls) | |||
166 | { | 167 | { |
167 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 168 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
168 | &open_queue, | 169 | &open_queue, |
169 | address); | 170 | (void *) address); |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
174 | |||
173 | static void | 175 | static void |
174 | add_address_cb (void *cls, | 176 | add_address_cb ( |
175 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 177 | void *cls, |
176 | tc_h, | 178 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
177 | const char *address, | 179 | const char *address, |
178 | struct GNUNET_TIME_Relative expiration, | 180 | struct GNUNET_TIME_Relative expiration, |
179 | uint32_t aid, | 181 | uint32_t aid, |
180 | enum GNUNET_NetworkType nt) | 182 | enum GNUNET_NetworkType nt) |
181 | { | 183 | { |
182 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 184 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
183 | "New address. (addr: %s, expir: %" PRIu32 ", ID: %" PRIu32 ", nt: %u\n", | 185 | "New address. (addr: %s, expir: %s, ID: %" PRIu32 ", nt: %u\n", |
184 | address, | 186 | address, |
185 | expiration.rel_value_us, | 187 | GNUNET_STRINGS_relative_time_to_string (expiration, |
188 | GNUNET_NO), | ||
186 | aid, | 189 | aid, |
187 | nt); | 190 | (int) nt); |
188 | // addresses[1] = GNUNET_strdup (address); | 191 | // addresses[1] = GNUNET_strdup (address); |
189 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && | 192 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && |
190 | (GNUNET_NO == queue_est)) | 193 | (GNUNET_NO == queue_est)) |
191 | { | 194 | { |
192 | open_queue (address); | 195 | open_queue ((void *) address); |
193 | } | 196 | } |
194 | } | 197 | } |
195 | 198 | ||
@@ -206,12 +209,13 @@ add_address_cb (void *cls, | |||
206 | * #GNUNET_NO if queue will not be established (bogous address) | 209 | * #GNUNET_NO if queue will not be established (bogous address) |
207 | */ | 210 | */ |
208 | static void | 211 | static void |
209 | queue_create_reply_cb (void *cls, | 212 | queue_create_reply_cb ( |
210 | struct | 213 | void *cls, |
211 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 214 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
212 | tc_h, | 215 | int will_try) |
213 | int will_try) | ||
214 | { | 216 | { |
217 | (void) cls; | ||
218 | (void) tc_h; | ||
215 | if (GNUNET_YES == will_try) | 219 | if (GNUNET_YES == will_try) |
216 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
217 | "Queue will be established!\n"); | 221 | "Queue will be established!\n"); |
@@ -227,6 +231,9 @@ handle_backchannel_cb (void *cls, | |||
227 | struct GNUNET_PeerIdentity *pid) | 231 | struct GNUNET_PeerIdentity *pid) |
228 | { | 232 | { |
229 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 233 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
234 | |||
235 | (void) tc_h; | ||
236 | (void) msg; | ||
230 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); | 237 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); |
231 | if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) | 238 | if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) |
232 | return tc_hs[PEER_A]; | 239 | return tc_hs[PEER_A]; |
@@ -268,9 +275,11 @@ latency_timeout (void *cls) | |||
268 | NULL); | 275 | NULL); |
269 | return; | 276 | return; |
270 | } | 277 | } |
271 | |||
272 | switch (phase) | 278 | switch (phase) |
273 | { | 279 | { |
280 | case TP_INIT: | ||
281 | GNUNET_assert (0); | ||
282 | break; | ||
274 | case TP_BURST_SHORT: | 283 | case TP_BURST_SHORT: |
275 | num_sent = num_sent_short; | 284 | num_sent = num_sent_short; |
276 | num_received = num_received_short; | 285 | num_received = num_received_short; |
@@ -291,6 +300,7 @@ latency_timeout (void *cls) | |||
291 | GNUNET_SCHEDULER_shutdown (); | 300 | GNUNET_SCHEDULER_shutdown (); |
292 | } | 301 | } |
293 | 302 | ||
303 | |||
294 | /*static void | 304 | /*static void |
295 | size_test (void *cls);*/ | 305 | size_test (void *cls);*/ |
296 | 306 | ||
@@ -302,7 +312,7 @@ size_test (void *cls) | |||
302 | 312 | ||
303 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 313 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
304 | "size_test_cb %u\n", | 314 | "size_test_cb %u\n", |
305 | num_sent_size); | 315 | (unsigned int) num_sent_size); |
306 | GNUNET_assert (TP_SIZE_CHECK == phase); | 316 | GNUNET_assert (TP_SIZE_CHECK == phase); |
307 | if (LONG_MESSAGE_SIZE != long_message_size) | 317 | if (LONG_MESSAGE_SIZE != long_message_size) |
308 | max_size = long_message_size; | 318 | max_size = long_message_size; |
@@ -324,13 +334,6 @@ size_test (void *cls) | |||
324 | TIMEOUT_MULTIPLIER)); | 334 | TIMEOUT_MULTIPLIER)); |
325 | } | 335 | } |
326 | 336 | ||
327 | /*static void | ||
328 | size_test (void *cls) | ||
329 | { | ||
330 | GNUNET_SCHEDULER_add_delayed (DELAY, | ||
331 | &size_test_cb, | ||
332 | NULL); | ||
333 | }*/ | ||
334 | 337 | ||
335 | static void | 338 | static void |
336 | long_test (void *cls); | 339 | long_test (void *cls); |
@@ -342,8 +345,8 @@ long_test_cb (void *cls) | |||
342 | 345 | ||
343 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 346 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
344 | "long_test_cb %u/%u\n", | 347 | "long_test_cb %u/%u\n", |
345 | num_sent_long, | 348 | (unsigned int) num_sent_long, |
346 | num_received_long); | 349 | (unsigned int) num_received_long); |
347 | payload = make_payload (long_message_size); | 350 | payload = make_payload (long_message_size); |
348 | num_sent_long++; | 351 | num_sent_long++; |
349 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 352 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
@@ -355,11 +358,13 @@ long_test_cb (void *cls) | |||
355 | payload, | 358 | payload, |
356 | long_message_size); | 359 | long_message_size); |
357 | GNUNET_free (payload); | 360 | GNUNET_free (payload); |
358 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 361 | timeout = GNUNET_TIME_relative_to_absolute ( |
359 | GNUNET_TIME_UNIT_SECONDS, | 362 | GNUNET_TIME_relative_multiply ( |
360 | TIMEOUT_MULTIPLIER)); | 363 | GNUNET_TIME_UNIT_SECONDS, |
364 | TIMEOUT_MULTIPLIER)); | ||
361 | } | 365 | } |
362 | 366 | ||
367 | |||
363 | static void | 368 | static void |
364 | long_test (void *cls) | 369 | long_test (void *cls) |
365 | { | 370 | { |
@@ -371,9 +376,11 @@ long_test (void *cls) | |||
371 | NULL); | 376 | NULL); |
372 | } | 377 | } |
373 | 378 | ||
379 | |||
374 | static void | 380 | static void |
375 | short_test (void *cls); | 381 | short_test (void *cls); |
376 | 382 | ||
383 | |||
377 | static void | 384 | static void |
378 | short_test_cb (void *cls) | 385 | short_test_cb (void *cls) |
379 | { | 386 | { |
@@ -381,8 +388,8 @@ short_test_cb (void *cls) | |||
381 | 388 | ||
382 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 389 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
383 | "short_test_cb %u/%u\n", | 390 | "short_test_cb %u/%u\n", |
384 | num_sent_short, | 391 | (unsigned int) num_sent_short, |
385 | num_received_short); | 392 | (unsigned int) num_received_short); |
386 | payload = make_payload (SHORT_MESSAGE_SIZE); | 393 | payload = make_payload (SHORT_MESSAGE_SIZE); |
387 | num_sent_short++; | 394 | num_sent_short++; |
388 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 395 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
@@ -399,6 +406,7 @@ short_test_cb (void *cls) | |||
399 | TIMEOUT_MULTIPLIER)); | 406 | TIMEOUT_MULTIPLIER)); |
400 | } | 407 | } |
401 | 408 | ||
409 | |||
402 | static void | 410 | static void |
403 | short_test (void *cls) | 411 | short_test (void *cls) |
404 | { | 412 | { |
@@ -494,10 +502,14 @@ update_avg_latency (const char*payload) | |||
494 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); | 502 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); |
495 | latency = GNUNET_TIME_absolute_get_duration (ts); | 503 | latency = GNUNET_TIME_absolute_get_duration (ts); |
496 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 504 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
497 | "Latency of received packet: %u\n", | 505 | "Latency of received packet: %s\n", |
498 | latency); | 506 | GNUNET_STRINGS_relative_time_to_string (latency, |
507 | GNUNET_YES)); | ||
499 | switch (phase) | 508 | switch (phase) |
500 | { | 509 | { |
510 | case TP_INIT: | ||
511 | GNUNET_assert (0); | ||
512 | break; | ||
501 | case TP_BURST_SHORT: | 513 | case TP_BURST_SHORT: |
502 | num_received = num_received_short; | 514 | num_received = num_received_short; |
503 | break; | 515 | break; |
@@ -516,6 +528,8 @@ update_avg_latency (const char*payload) | |||
516 | 528 | ||
517 | } | 529 | } |
518 | 530 | ||
531 | |||
532 | static void | ||
519 | process_statistics_box_done (void *cls, int success) | 533 | process_statistics_box_done (void *cls, int success) |
520 | { | 534 | { |
521 | if (NULL != box_stats) | 535 | if (NULL != box_stats) |
@@ -528,6 +542,8 @@ process_statistics_box_done (void *cls, int success) | |||
528 | } | 542 | } |
529 | } | 543 | } |
530 | 544 | ||
545 | |||
546 | static void | ||
531 | process_statistics_rekey_done (void *cls, int success) | 547 | process_statistics_rekey_done (void *cls, int success) |
532 | { | 548 | { |
533 | if (NULL != rekey_stats) | 549 | if (NULL != rekey_stats) |
@@ -540,6 +556,7 @@ process_statistics_rekey_done (void *cls, int success) | |||
540 | } | 556 | } |
541 | } | 557 | } |
542 | 558 | ||
559 | |||
543 | static int | 560 | static int |
544 | process_statistics (void *cls, | 561 | process_statistics (void *cls, |
545 | const char *subsystem, | 562 | const char *subsystem, |
@@ -560,7 +577,7 @@ process_statistics (void *cls, | |||
560 | "No successful rekeying!\n"); | 577 | "No successful rekeying!\n"); |
561 | GNUNET_SCHEDULER_shutdown (); | 578 | GNUNET_SCHEDULER_shutdown (); |
562 | } | 579 | } |
563 | if ((0 == strcmp ("backchannel", test_name)) && | 580 | if ((0 == strcmp ("backchannel", test_name)) && |
564 | (0 == strcmp ( | 581 | (0 == strcmp ( |
565 | "# messages decrypted with BOX", | 582 | "# messages decrypted with BOX", |
566 | name)) | 583 | name)) |
@@ -571,7 +588,7 @@ process_statistics (void *cls, | |||
571 | "Not enough BOX messages!\n"); | 588 | "Not enough BOX messages!\n"); |
572 | GNUNET_SCHEDULER_shutdown (); | 589 | GNUNET_SCHEDULER_shutdown (); |
573 | } | 590 | } |
574 | if ((0 == strcmp ("rekey", test_name)) && | 591 | if ((0 == strcmp ("rekey", test_name)) && |
575 | (0 == strcmp ( | 592 | (0 == strcmp ( |
576 | "# messages decrypted with BOX", | 593 | "# messages decrypted with BOX", |
577 | name)) | 594 | name)) |
@@ -585,6 +602,7 @@ process_statistics (void *cls, | |||
585 | return GNUNET_OK; | 602 | return GNUNET_OK; |
586 | } | 603 | } |
587 | 604 | ||
605 | |||
588 | /** | 606 | /** |
589 | * @brief Handle an incoming message | 607 | * @brief Handle an incoming message |
590 | * | 608 | * |
@@ -595,14 +613,14 @@ process_statistics (void *cls, | |||
595 | * @param msg Received message | 613 | * @param msg Received message |
596 | */ | 614 | */ |
597 | static void | 615 | static void |
598 | incoming_message_cb (void *cls, | 616 | incoming_message_cb ( |
599 | struct | 617 | void *cls, |
600 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 618 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
601 | *tc_h, | 619 | const char *payload, |
602 | const char*payload, | 620 | size_t payload_len) |
603 | size_t payload_len) | ||
604 | { | 621 | { |
605 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) | 622 | if (0 != strcmp ((char*) cls, |
623 | cfg_peers_name[NUM_PEERS - 1])) | ||
606 | { | 624 | { |
607 | LOG (GNUNET_ERROR_TYPE_WARNING, | 625 | LOG (GNUNET_ERROR_TYPE_WARNING, |
608 | "unexpected receiver...\n"); | 626 | "unexpected receiver...\n"); |
@@ -628,11 +646,9 @@ incoming_message_cb (void *cls, | |||
628 | { | 646 | { |
629 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 647 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
630 | "Short size packet test done.\n"); | 648 | "Short size packet test done.\n"); |
631 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE | 649 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
632 | * num_received_short | 650 | (SHORT_MESSAGE_SIZE * num_received_short * 1000 * 1000) |
633 | * 1000 | 651 | / duration.rel_value_us); |
634 | * 1000) | ||
635 | / duration.rel_value_us); | ||
636 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 652 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
637 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 653 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
638 | (unsigned long) num_received_short, | 654 | (unsigned long) num_received_short, |
@@ -646,9 +662,6 @@ incoming_message_cb (void *cls, | |||
646 | // num_sent_short = 0; | 662 | // num_sent_short = 0; |
647 | avg_latency = 0; | 663 | avg_latency = 0; |
648 | // num_received = 0; | 664 | // num_received = 0; |
649 | /*LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
650 | "Finished\n"); | ||
651 | GNUNET_SCHEDULER_shutdown ();*/ | ||
652 | long_test (NULL); | 665 | long_test (NULL); |
653 | } | 666 | } |
654 | break; | 667 | break; |
@@ -669,12 +682,10 @@ incoming_message_cb (void *cls, | |||
669 | { | 682 | { |
670 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 683 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
671 | "Long size packet test done.\n"); | 684 | "Long size packet test done.\n"); |
672 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size | 685 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
673 | * num_received_long | 686 | (long_message_size * num_received_long * 1000 * 1000) |
674 | * 1000 | 687 | / duration. |
675 | * 1000) | 688 | rel_value_us); |
676 | / duration. | ||
677 | rel_value_us); | ||
678 | 689 | ||
679 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 690 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
680 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 691 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
@@ -749,7 +760,8 @@ incoming_message_cb (void *cls, | |||
749 | &process_statistics, | 760 | &process_statistics, |
750 | NULL); | 761 | NULL); |
751 | } | 762 | } |
752 | else{ | 763 | else |
764 | { | ||
753 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 765 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
754 | "Finished\n"); | 766 | "Finished\n"); |
755 | GNUNET_SCHEDULER_shutdown (); | 767 | GNUNET_SCHEDULER_shutdown (); |
@@ -765,7 +777,7 @@ static void | |||
765 | do_shutdown (void *cls) | 777 | do_shutdown (void *cls) |
766 | { | 778 | { |
767 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 779 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
768 | "shuting down test.\”"); | 780 | "shuting down test.\n"); |
769 | 781 | ||
770 | if (NULL != box_stats) | 782 | if (NULL != box_stats) |
771 | { | 783 | { |
@@ -919,15 +931,12 @@ main (int argc, | |||
919 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 931 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
920 | "test_name: %s\n", | 932 | "test_name: %s\n", |
921 | test_name); | 933 | test_name); |
922 | |||
923 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 934 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
924 | "communicator_name: %s\n", | 935 | "communicator_name: %s\n", |
925 | communicator_name); | 936 | communicator_name); |
926 | |||
927 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 937 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
928 | "communicator_binary: %s\n", | 938 | "communicator_binary: %s\n", |
929 | communicator_binary); | 939 | communicator_binary); |
930 | |||
931 | GNUNET_SCHEDULER_run (&run, | 940 | GNUNET_SCHEDULER_run (&run, |
932 | NULL); | 941 | NULL); |
933 | return ret; | 942 | return ret; |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index d2e4b4d1a..33fe26e34 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -138,7 +138,7 @@ libgnunetutil_la_LIBADD = \ | |||
138 | 138 | ||
139 | libgnunetutil_la_LDFLAGS = \ | 139 | libgnunetutil_la_LDFLAGS = \ |
140 | $(GN_LIB_LDFLAGS) \ | 140 | $(GN_LIB_LDFLAGS) \ |
141 | -version-info 13:2:1 | 141 | -version-info 14:0:0 |
142 | 142 | ||
143 | if HAVE_TESTING | 143 | if HAVE_TESTING |
144 | GNUNET_ECC = gnunet-ecc | 144 | GNUNET_ECC = gnunet-ecc |
diff --git a/src/util/configuration.c b/src/util/configuration.c index e5c01f81f..bda643b83 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -93,7 +93,7 @@ struct GNUNET_CONFIGURATION_Handle | |||
93 | * #GNUNET_NO if clean, #GNUNET_YES if dirty, | 93 | * #GNUNET_NO if clean, #GNUNET_YES if dirty, |
94 | * #GNUNET_SYSERR on error (i.e. last save failed) | 94 | * #GNUNET_SYSERR on error (i.e. last save failed) |
95 | */ | 95 | */ |
96 | int dirty; | 96 | enum GNUNET_GenericReturnValue dirty; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
@@ -109,11 +109,6 @@ struct DiffHandle | |||
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
112 | /** | ||
113 | * Create a GNUNET_CONFIGURATION_Handle. | ||
114 | * | ||
115 | * @return fresh configuration object | ||
116 | */ | ||
117 | struct GNUNET_CONFIGURATION_Handle * | 112 | struct GNUNET_CONFIGURATION_Handle * |
118 | GNUNET_CONFIGURATION_create () | 113 | GNUNET_CONFIGURATION_create () |
119 | { | 114 | { |
@@ -199,11 +194,6 @@ GNUNET_CONFIGURATION_create () | |||
199 | } | 194 | } |
200 | 195 | ||
201 | 196 | ||
202 | /** | ||
203 | * Destroy configuration object. | ||
204 | * | ||
205 | * @param cfg configuration to destroy | ||
206 | */ | ||
207 | void | 197 | void |
208 | GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg) | 198 | GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg) |
209 | { | 199 | { |
@@ -215,24 +205,13 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
215 | } | 205 | } |
216 | 206 | ||
217 | 207 | ||
218 | /** | 208 | enum GNUNET_GenericReturnValue |
219 | * Parse a configuration file @a filename and run the function | ||
220 | * @a cb with the resulting configuration object. Then free the | ||
221 | * configuration object and return the status value from @a cb. | ||
222 | * | ||
223 | * @param filename configuration to parse, NULL for "default" | ||
224 | * @param cb function to run | ||
225 | * @param cb_cls closure for @a cb | ||
226 | * @return #GNUNET_SYSERR if parsing the configuration failed, | ||
227 | * otherwise return value from @a cb. | ||
228 | */ | ||
229 | int | ||
230 | GNUNET_CONFIGURATION_parse_and_run (const char *filename, | 209 | GNUNET_CONFIGURATION_parse_and_run (const char *filename, |
231 | GNUNET_CONFIGURATION_Callback cb, | 210 | GNUNET_CONFIGURATION_Callback cb, |
232 | void *cb_cls) | 211 | void *cb_cls) |
233 | { | 212 | { |
234 | struct GNUNET_CONFIGURATION_Handle *cfg; | 213 | struct GNUNET_CONFIGURATION_Handle *cfg; |
235 | int ret; | 214 | enum GNUNET_GenericReturnValue ret; |
236 | 215 | ||
237 | cfg = GNUNET_CONFIGURATION_create (); | 216 | cfg = GNUNET_CONFIGURATION_create (); |
238 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, filename)) | 217 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, filename)) |
@@ -247,18 +226,7 @@ GNUNET_CONFIGURATION_parse_and_run (const char *filename, | |||
247 | } | 226 | } |
248 | 227 | ||
249 | 228 | ||
250 | /** | 229 | enum GNUNET_GenericReturnValue |
251 | * De-serializes configuration | ||
252 | * | ||
253 | * @param cfg configuration to update | ||
254 | * @param mem the memory block of serialized configuration | ||
255 | * @param size the size of the memory block | ||
256 | * @param basedir set to path from which we recursively load configuration | ||
257 | * from inlined configurations; NULL if not and raise warnings | ||
258 | * when we come across them | ||
259 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
260 | */ | ||
261 | int | ||
262 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | 230 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, |
263 | const char *mem, | 231 | const char *mem, |
264 | size_t size, | 232 | size_t size, |
@@ -273,7 +241,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
273 | size_t to_read; | 241 | size_t to_read; |
274 | size_t i; | 242 | size_t i; |
275 | int emptyline; | 243 | int emptyline; |
276 | int ret; | 244 | enum GNUNET_GenericReturnValue ret; |
277 | char *section; | 245 | char *section; |
278 | char *eq; | 246 | char *eq; |
279 | char *tag; | 247 | char *tag; |
@@ -411,15 +379,7 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
411 | } | 379 | } |
412 | 380 | ||
413 | 381 | ||
414 | /** | 382 | enum GNUNET_GenericReturnValue |
415 | * Parse a configuration file, add all of the options in the | ||
416 | * file to the configuration environment. | ||
417 | * | ||
418 | * @param cfg configuration to update | ||
419 | * @param filename name of the configuration file | ||
420 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
421 | */ | ||
422 | int | ||
423 | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | 383 | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, |
424 | const char *filename) | 384 | const char *filename) |
425 | { | 385 | { |
@@ -429,7 +389,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
429 | char *mem; | 389 | char *mem; |
430 | char *endsep; | 390 | char *endsep; |
431 | int dirty; | 391 | int dirty; |
432 | int ret; | 392 | enum GNUNET_GenericReturnValue ret; |
433 | ssize_t sret; | 393 | ssize_t sret; |
434 | 394 | ||
435 | fn = GNUNET_STRINGS_filename_expand (filename); | 395 | fn = GNUNET_STRINGS_filename_expand (filename); |
@@ -476,14 +436,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
476 | } | 436 | } |
477 | 437 | ||
478 | 438 | ||
479 | /** | 439 | enum GNUNET_GenericReturnValue |
480 | * Test if there are configuration options that were | ||
481 | * changed since the last save. | ||
482 | * | ||
483 | * @param cfg configuration to inspect | ||
484 | * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on error (i.e. last save failed) | ||
485 | */ | ||
486 | int | ||
487 | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg) | 440 | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg) |
488 | { | 441 | { |
489 | return cfg->dirty; | 442 | return cfg->dirty; |
@@ -491,19 +444,44 @@ GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
491 | 444 | ||
492 | 445 | ||
493 | /** | 446 | /** |
494 | * Serializes the given configuration. | 447 | * Should we skip this configuration entry when serializing? |
495 | * | 448 | * |
496 | * @param cfg configuration to serialize | 449 | * @param sec section name |
497 | * @param size will be set to the size of the serialized memory block | 450 | * @param key key |
498 | * @return the memory block where the serialized configuration is | 451 | * @return true if we should skip it |
499 | * present. This memory should be freed by the caller | ||
500 | */ | 452 | */ |
453 | static bool | ||
454 | do_skip (const char *sec, | ||
455 | const char *key) | ||
456 | { | ||
457 | if (0 != strcasecmp ("PATHS", | ||
458 | sec)) | ||
459 | return false; | ||
460 | return ( (0 == strcasecmp ("DATADIR", | ||
461 | key)) || | ||
462 | (0 == strcasecmp ("LIBDIR", | ||
463 | key)) || | ||
464 | (0 == strcasecmp ("BINDIR", | ||
465 | key)) || | ||
466 | (0 == strcasecmp ("PREFIX", | ||
467 | key)) || | ||
468 | (0 == strcasecmp ("LOCALEDIR", | ||
469 | key)) || | ||
470 | (0 == strcasecmp ("ICONDIR", | ||
471 | key)) || | ||
472 | (0 == strcasecmp ("DOCDIR", | ||
473 | key)) || | ||
474 | (0 == strcasecmp ("DEFAULTCONFIG", | ||
475 | key)) || | ||
476 | (0 == strcasecmp ("LIBEXECDIR", | ||
477 | key)) ); | ||
478 | } | ||
479 | |||
480 | |||
501 | char * | 481 | char * |
502 | GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | 482 | GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, |
503 | size_t *size) | 483 | size_t *size) |
504 | { | 484 | { |
505 | struct ConfigSection *sec; | ||
506 | struct ConfigEntry *ent; | ||
507 | char *mem; | 485 | char *mem; |
508 | char *cbuf; | 486 | char *cbuf; |
509 | char *val; | 487 | char *val; |
@@ -513,12 +491,19 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
513 | 491 | ||
514 | /* Pass1 : calculate the buffer size required */ | 492 | /* Pass1 : calculate the buffer size required */ |
515 | m_size = 0; | 493 | m_size = 0; |
516 | for (sec = cfg->sections; NULL != sec; sec = sec->next) | 494 | for (struct ConfigSection *sec = cfg->sections; |
495 | NULL != sec; | ||
496 | sec = sec->next) | ||
517 | { | 497 | { |
518 | /* For each section we need to add 3 characters: {'[',']','\n'} */ | 498 | /* For each section we need to add 3 characters: {'[',']','\n'} */ |
519 | m_size += strlen (sec->name) + 3; | 499 | m_size += strlen (sec->name) + 3; |
520 | for (ent = sec->entries; NULL != ent; ent = ent->next) | 500 | for (struct ConfigEntry *ent = sec->entries; |
501 | NULL != ent; | ||
502 | ent = ent->next) | ||
521 | { | 503 | { |
504 | if (do_skip (sec->name, | ||
505 | ent->key)) | ||
506 | continue; | ||
522 | if (NULL != ent->val) | 507 | if (NULL != ent->val) |
523 | { | 508 | { |
524 | /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */ | 509 | /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */ |
@@ -539,20 +524,30 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
539 | 524 | ||
540 | /* Pass2: Allocate memory and write the configuration to it */ | 525 | /* Pass2: Allocate memory and write the configuration to it */ |
541 | mem = GNUNET_malloc (m_size); | 526 | mem = GNUNET_malloc (m_size); |
542 | sec = cfg->sections; | ||
543 | c_size = 0; | 527 | c_size = 0; |
544 | *size = c_size; | 528 | *size = c_size; |
545 | while (NULL != sec) | 529 | for (struct ConfigSection *sec = cfg->sections; |
530 | NULL != sec; | ||
531 | sec = sec->next) | ||
546 | { | 532 | { |
547 | int len; | 533 | int len; |
548 | 534 | ||
549 | len = GNUNET_asprintf (&cbuf, "[%s]\n", sec->name); | 535 | len = GNUNET_asprintf (&cbuf, |
536 | "[%s]\n", | ||
537 | sec->name); | ||
550 | GNUNET_assert (0 < len); | 538 | GNUNET_assert (0 < len); |
551 | GNUNET_memcpy (mem + c_size, cbuf, len); | 539 | GNUNET_memcpy (mem + c_size, |
540 | cbuf, | ||
541 | len); | ||
552 | c_size += len; | 542 | c_size += len; |
553 | GNUNET_free (cbuf); | 543 | GNUNET_free (cbuf); |
554 | for (ent = sec->entries; NULL != ent; ent = ent->next) | 544 | for (struct ConfigEntry *ent = sec->entries; |
545 | NULL != ent; | ||
546 | ent = ent->next) | ||
555 | { | 547 | { |
548 | if (do_skip (sec->name, | ||
549 | ent->key)) | ||
550 | continue; | ||
556 | if (NULL != ent->val) | 551 | if (NULL != ent->val) |
557 | { | 552 | { |
558 | val = GNUNET_malloc (strlen (ent->val) * 2 + 1); | 553 | val = GNUNET_malloc (strlen (ent->val) * 2 + 1); |
@@ -572,7 +567,6 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
572 | } | 567 | } |
573 | GNUNET_memcpy (mem + c_size, "\n", 1); | 568 | GNUNET_memcpy (mem + c_size, "\n", 1); |
574 | c_size++; | 569 | c_size++; |
575 | sec = sec->next; | ||
576 | } | 570 | } |
577 | GNUNET_assert (c_size == m_size); | 571 | GNUNET_assert (c_size == m_size); |
578 | *size = c_size; | 572 | *size = c_size; |
@@ -580,21 +574,13 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
580 | } | 574 | } |
581 | 575 | ||
582 | 576 | ||
583 | /** | 577 | enum GNUNET_GenericReturnValue |
584 | * Write configuration file. | ||
585 | * | ||
586 | * @param cfg configuration to write | ||
587 | * @param filename where to write the configuration | ||
588 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
589 | */ | ||
590 | int | ||
591 | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | 578 | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, |
592 | const char *filename) | 579 | const char *filename) |
593 | { | 580 | { |
594 | char *fn; | 581 | char *fn; |
595 | char *cfg_buf; | 582 | char *cfg_buf; |
596 | size_t size; | 583 | size_t size; |
597 | ssize_t sret; | ||
598 | 584 | ||
599 | fn = GNUNET_STRINGS_filename_expand (filename); | 585 | fn = GNUNET_STRINGS_filename_expand (filename); |
600 | if (fn == NULL) | 586 | if (fn == NULL) |
@@ -604,23 +590,41 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
604 | GNUNET_free (fn); | 590 | GNUNET_free (fn); |
605 | return GNUNET_SYSERR; | 591 | return GNUNET_SYSERR; |
606 | } | 592 | } |
607 | cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size); | 593 | cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, |
608 | sret = GNUNET_DISK_fn_write (fn, | 594 | &size); |
609 | cfg_buf, | 595 | { |
610 | size, | 596 | struct GNUNET_DISK_FileHandle *h; |
597 | |||
598 | h = GNUNET_DISK_file_open (fn, | ||
599 | GNUNET_DISK_OPEN_WRITE | ||
600 | | GNUNET_DISK_OPEN_TRUNCATE | ||
601 | | GNUNET_DISK_OPEN_CREATE, | ||
611 | GNUNET_DISK_PERM_USER_READ | 602 | GNUNET_DISK_PERM_USER_READ |
612 | | GNUNET_DISK_PERM_USER_WRITE | 603 | | GNUNET_DISK_PERM_USER_WRITE |
613 | | GNUNET_DISK_PERM_GROUP_READ | 604 | | GNUNET_DISK_PERM_GROUP_READ |
614 | | GNUNET_DISK_PERM_GROUP_WRITE); | 605 | | GNUNET_DISK_PERM_GROUP_WRITE); |
615 | if ((sret < 0) || (size != (size_t) sret)) | 606 | if (NULL == h) |
616 | { | 607 | { |
617 | GNUNET_free (fn); | 608 | GNUNET_free (fn); |
618 | GNUNET_free (cfg_buf); | 609 | return GNUNET_SYSERR; |
619 | LOG (GNUNET_ERROR_TYPE_WARNING, | 610 | } |
620 | "Writing configuration to file `%s' failed\n", | 611 | if (((ssize_t) size) != |
621 | filename); | 612 | GNUNET_DISK_file_write (h, |
622 | cfg->dirty = GNUNET_SYSERR; /* last write failed */ | 613 | cfg_buf, |
623 | return GNUNET_SYSERR; | 614 | size)) |
615 | { | ||
616 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
617 | "write", | ||
618 | fn); | ||
619 | GNUNET_DISK_file_close (h); | ||
620 | (void) GNUNET_DISK_directory_remove (fn); | ||
621 | GNUNET_free (fn); | ||
622 | GNUNET_free (cfg_buf); | ||
623 | cfg->dirty = GNUNET_SYSERR; /* last write failed */ | ||
624 | return GNUNET_SYSERR; | ||
625 | } | ||
626 | GNUNET_assert (GNUNET_OK == | ||
627 | GNUNET_DISK_file_close (h)); | ||
624 | } | 628 | } |
625 | GNUNET_free (fn); | 629 | GNUNET_free (fn); |
626 | GNUNET_free (cfg_buf); | 630 | GNUNET_free (cfg_buf); |
@@ -629,36 +633,25 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
629 | } | 633 | } |
630 | 634 | ||
631 | 635 | ||
632 | /** | ||
633 | * Iterate over all options in the configuration. | ||
634 | * | ||
635 | * @param cfg configuration to inspect | ||
636 | * @param iter function to call on each option | ||
637 | * @param iter_cls closure for @a iter | ||
638 | */ | ||
639 | void | 636 | void |
640 | GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, | 637 | GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, |
641 | GNUNET_CONFIGURATION_Iterator iter, | 638 | GNUNET_CONFIGURATION_Iterator iter, |
642 | void *iter_cls) | 639 | void *iter_cls) |
643 | { | 640 | { |
644 | struct ConfigSection *spos; | 641 | for (struct ConfigSection *spos = cfg->sections; |
645 | struct ConfigEntry *epos; | 642 | NULL != spos; |
646 | 643 | spos = spos->next) | |
647 | for (spos = cfg->sections; NULL != spos; spos = spos->next) | 644 | for (struct ConfigEntry *epos = spos->entries; |
648 | for (epos = spos->entries; NULL != epos; epos = epos->next) | 645 | NULL != epos; |
646 | epos = epos->next) | ||
649 | if (NULL != epos->val) | 647 | if (NULL != epos->val) |
650 | iter (iter_cls, spos->name, epos->key, epos->val); | 648 | iter (iter_cls, |
649 | spos->name, | ||
650 | epos->key, | ||
651 | epos->val); | ||
651 | } | 652 | } |
652 | 653 | ||
653 | 654 | ||
654 | /** | ||
655 | * Iterate over values of a section in the configuration. | ||
656 | * | ||
657 | * @param cfg configuration to inspect | ||
658 | * @param section the section | ||
659 | * @param iter function to call on each option | ||
660 | * @param iter_cls closure for @a iter | ||
661 | */ | ||
662 | void | 655 | void |
663 | GNUNET_CONFIGURATION_iterate_section_values ( | 656 | GNUNET_CONFIGURATION_iterate_section_values ( |
664 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 657 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -680,13 +673,6 @@ GNUNET_CONFIGURATION_iterate_section_values ( | |||
680 | } | 673 | } |
681 | 674 | ||
682 | 675 | ||
683 | /** | ||
684 | * Iterate over all sections in the configuration. | ||
685 | * | ||
686 | * @param cfg configuration to inspect | ||
687 | * @param iter function to call on each section | ||
688 | * @param iter_cls closure for @a iter | ||
689 | */ | ||
690 | void | 676 | void |
691 | GNUNET_CONFIGURATION_iterate_sections ( | 677 | GNUNET_CONFIGURATION_iterate_sections ( |
692 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 678 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -706,12 +692,6 @@ GNUNET_CONFIGURATION_iterate_sections ( | |||
706 | } | 692 | } |
707 | 693 | ||
708 | 694 | ||
709 | /** | ||
710 | * Remove the given section and all options in it. | ||
711 | * | ||
712 | * @param cfg configuration to inspect | ||
713 | * @param section name of the section to remove | ||
714 | */ | ||
715 | void | 695 | void |
716 | GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, | 696 | GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, |
717 | const char *section) | 697 | const char *section) |
@@ -769,12 +749,6 @@ copy_entry (void *cls, | |||
769 | } | 749 | } |
770 | 750 | ||
771 | 751 | ||
772 | /** | ||
773 | * Duplicate an existing configuration object. | ||
774 | * | ||
775 | * @param cfg configuration to duplicate | ||
776 | * @return duplicate configuration | ||
777 | */ | ||
778 | struct GNUNET_CONFIGURATION_Handle * | 752 | struct GNUNET_CONFIGURATION_Handle * |
779 | GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg) | 753 | GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg) |
780 | { | 754 | { |
@@ -858,13 +832,6 @@ compare_entries (void *cls, | |||
858 | } | 832 | } |
859 | 833 | ||
860 | 834 | ||
861 | /** | ||
862 | * Compute configuration with only entries that have been changed | ||
863 | * | ||
864 | * @param cfg_default original configuration | ||
865 | * @param cfg_new new configuration | ||
866 | * @return configuration with only the differences, never NULL | ||
867 | */ | ||
868 | struct GNUNET_CONFIGURATION_Handle * | 835 | struct GNUNET_CONFIGURATION_Handle * |
869 | GNUNET_CONFIGURATION_get_diff ( | 836 | GNUNET_CONFIGURATION_get_diff ( |
870 | const struct GNUNET_CONFIGURATION_Handle *cfg_default, | 837 | const struct GNUNET_CONFIGURATION_Handle *cfg_default, |
@@ -879,15 +846,7 @@ GNUNET_CONFIGURATION_get_diff ( | |||
879 | } | 846 | } |
880 | 847 | ||
881 | 848 | ||
882 | /** | 849 | enum GNUNET_GenericReturnValue |
883 | * Write only configuration entries that have been changed to configuration file | ||
884 | * | ||
885 | * @param cfg_default default configuration | ||
886 | * @param cfg_new new configuration | ||
887 | * @param filename where to write the configuration diff between default and new | ||
888 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
889 | */ | ||
890 | int | ||
891 | GNUNET_CONFIGURATION_write_diffs ( | 850 | GNUNET_CONFIGURATION_write_diffs ( |
892 | const struct GNUNET_CONFIGURATION_Handle *cfg_default, | 851 | const struct GNUNET_CONFIGURATION_Handle *cfg_default, |
893 | const struct GNUNET_CONFIGURATION_Handle *cfg_new, | 852 | const struct GNUNET_CONFIGURATION_Handle *cfg_new, |
@@ -903,14 +862,6 @@ GNUNET_CONFIGURATION_write_diffs ( | |||
903 | } | 862 | } |
904 | 863 | ||
905 | 864 | ||
906 | /** | ||
907 | * Set a configuration value that should be a string. | ||
908 | * | ||
909 | * @param cfg configuration to update | ||
910 | * @param section section of interest | ||
911 | * @param option option of interest | ||
912 | * @param value value to set | ||
913 | */ | ||
914 | void | 865 | void |
915 | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, | 866 | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, |
916 | const char *section, | 867 | const char *section, |
@@ -953,14 +904,6 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
953 | } | 904 | } |
954 | 905 | ||
955 | 906 | ||
956 | /** | ||
957 | * Set a configuration value that should be a number. | ||
958 | * | ||
959 | * @param cfg configuration to update | ||
960 | * @param section section of interest | ||
961 | * @param option option of interest | ||
962 | * @param number value to set | ||
963 | */ | ||
964 | void | 907 | void |
965 | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, | 908 | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, |
966 | const char *section, | 909 | const char *section, |
@@ -974,16 +917,7 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
974 | } | 917 | } |
975 | 918 | ||
976 | 919 | ||
977 | /** | 920 | enum GNUNET_GenericReturnValue |
978 | * Get a configuration value that should be a number. | ||
979 | * | ||
980 | * @param cfg configuration to inspect | ||
981 | * @param section section of interest | ||
982 | * @param option option of interest | ||
983 | * @param number where to store the numeric value of the option | ||
984 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
985 | */ | ||
986 | int | ||
987 | GNUNET_CONFIGURATION_get_value_number ( | 921 | GNUNET_CONFIGURATION_get_value_number ( |
988 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 922 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
989 | const char *section, | 923 | const char *section, |
@@ -1003,16 +937,7 @@ GNUNET_CONFIGURATION_get_value_number ( | |||
1003 | } | 937 | } |
1004 | 938 | ||
1005 | 939 | ||
1006 | /** | 940 | enum GNUNET_GenericReturnValue |
1007 | * Get a configuration value that should be a floating point number. | ||
1008 | * | ||
1009 | * @param cfg configuration to inspect | ||
1010 | * @param section section of interest | ||
1011 | * @param option option of interest | ||
1012 | * @param number where to store the floating value of the option | ||
1013 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1014 | */ | ||
1015 | int | ||
1016 | GNUNET_CONFIGURATION_get_value_float ( | 941 | GNUNET_CONFIGURATION_get_value_float ( |
1017 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 942 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1018 | const char *section, | 943 | const char *section, |
@@ -1032,16 +957,7 @@ GNUNET_CONFIGURATION_get_value_float ( | |||
1032 | } | 957 | } |
1033 | 958 | ||
1034 | 959 | ||
1035 | /** | 960 | enum GNUNET_GenericReturnValue |
1036 | * Get a configuration value that should be a relative time. | ||
1037 | * | ||
1038 | * @param cfg configuration to inspect | ||
1039 | * @param section section of interest | ||
1040 | * @param option option of interest | ||
1041 | * @param time set to the time value stored in the configuration | ||
1042 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1043 | */ | ||
1044 | int | ||
1045 | GNUNET_CONFIGURATION_get_value_time ( | 961 | GNUNET_CONFIGURATION_get_value_time ( |
1046 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 962 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1047 | const char *section, | 963 | const char *section, |
@@ -1065,16 +981,7 @@ GNUNET_CONFIGURATION_get_value_time ( | |||
1065 | } | 981 | } |
1066 | 982 | ||
1067 | 983 | ||
1068 | /** | 984 | enum GNUNET_GenericReturnValue |
1069 | * Get a configuration value that should be a size in bytes. | ||
1070 | * | ||
1071 | * @param cfg configuration to inspect | ||
1072 | * @param section section of interest | ||
1073 | * @param option option of interest | ||
1074 | * @param size set to the size in bytes as stored in the configuration | ||
1075 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1076 | */ | ||
1077 | int | ||
1078 | GNUNET_CONFIGURATION_get_value_size ( | 985 | GNUNET_CONFIGURATION_get_value_size ( |
1079 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 986 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1080 | const char *section, | 987 | const char *section, |
@@ -1101,7 +1008,7 @@ GNUNET_CONFIGURATION_get_value_size ( | |||
1101 | * value, or NULL if option is not specified | 1008 | * value, or NULL if option is not specified |
1102 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1009 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1103 | */ | 1010 | */ |
1104 | int | 1011 | enum GNUNET_GenericReturnValue |
1105 | GNUNET_CONFIGURATION_get_value_string ( | 1012 | GNUNET_CONFIGURATION_get_value_string ( |
1106 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1013 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1107 | const char *section, | 1014 | const char *section, |
@@ -1120,19 +1027,7 @@ GNUNET_CONFIGURATION_get_value_string ( | |||
1120 | } | 1027 | } |
1121 | 1028 | ||
1122 | 1029 | ||
1123 | /** | 1030 | enum GNUNET_GenericReturnValue |
1124 | * Get a configuration value that should be in a set of | ||
1125 | * predefined strings | ||
1126 | * | ||
1127 | * @param cfg configuration to inspect | ||
1128 | * @param section section of interest | ||
1129 | * @param option option of interest | ||
1130 | * @param choices NULL-terminated list of legal values | ||
1131 | * @param value will be set to an entry in the legal list, | ||
1132 | * or NULL if option is not specified and no default given | ||
1133 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1134 | */ | ||
1135 | int | ||
1136 | GNUNET_CONFIGURATION_get_value_choice ( | 1031 | GNUNET_CONFIGURATION_get_value_choice ( |
1137 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1032 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1138 | const char *section, | 1033 | const char *section, |
@@ -1163,19 +1058,7 @@ GNUNET_CONFIGURATION_get_value_choice ( | |||
1163 | } | 1058 | } |
1164 | 1059 | ||
1165 | 1060 | ||
1166 | /** | 1061 | enum GNUNET_GenericReturnValue |
1167 | * Get crockford32-encoded fixed-size binary data from a configuration. | ||
1168 | * | ||
1169 | * @param cfg configuration to access | ||
1170 | * @param section section to access | ||
1171 | * @param option option to access | ||
1172 | * @param buf where to store the decoded binary result | ||
1173 | * @param buf_size exact number of bytes to store in @a buf | ||
1174 | * @return #GNUNET_OK on success | ||
1175 | * #GNUNET_NO is the value does not exist | ||
1176 | * #GNUNET_SYSERR on decoding error | ||
1177 | */ | ||
1178 | int | ||
1179 | GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1062 | GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1180 | const char *section, | 1063 | const char *section, |
1181 | const char *option, | 1064 | const char *option, |
@@ -1207,15 +1090,7 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1207 | } | 1090 | } |
1208 | 1091 | ||
1209 | 1092 | ||
1210 | /** | 1093 | enum GNUNET_GenericReturnValue |
1211 | * Test if we have a value for a particular option | ||
1212 | * | ||
1213 | * @param cfg configuration to inspect | ||
1214 | * @param section section of interest | ||
1215 | * @param option option of interest | ||
1216 | * @return #GNUNET_YES if so, #GNUNET_NO if not. | ||
1217 | */ | ||
1218 | int | ||
1219 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1094 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1220 | const char *section, | 1095 | const char *section, |
1221 | const char *option) | 1096 | const char *option) |
@@ -1390,22 +1265,6 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1390 | } | 1265 | } |
1391 | 1266 | ||
1392 | 1267 | ||
1393 | /** | ||
1394 | * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" | ||
1395 | * where either in the "PATHS" section or the environment "FOO" is | ||
1396 | * set to "DIRECTORY". We also support default expansion, | ||
1397 | * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is | ||
1398 | * set in PATHS or the environment, and otherwise to "default". Note | ||
1399 | * that "default" itself can also be a $-expression, thus | ||
1400 | * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined | ||
1401 | * to VAR2. | ||
1402 | * | ||
1403 | * @param cfg configuration to use for path expansion | ||
1404 | * @param orig string to $-expand (will be freed!). Note that multiple | ||
1405 | * $-expressions can be present in this string. They will all be | ||
1406 | * $-expanded. | ||
1407 | * @return $-expanded string | ||
1408 | */ | ||
1409 | char * | 1268 | char * |
1410 | GNUNET_CONFIGURATION_expand_dollar ( | 1269 | GNUNET_CONFIGURATION_expand_dollar ( |
1411 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1270 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -1431,17 +1290,7 @@ GNUNET_CONFIGURATION_expand_dollar ( | |||
1431 | } | 1290 | } |
1432 | 1291 | ||
1433 | 1292 | ||
1434 | /** | 1293 | enum GNUNET_GenericReturnValue |
1435 | * Get a configuration value that should be a string. | ||
1436 | * | ||
1437 | * @param cfg configuration to inspect | ||
1438 | * @param section section of interest | ||
1439 | * @param option option of interest | ||
1440 | * @param value will be set to a freshly allocated configuration | ||
1441 | * value, or NULL if option is not specified | ||
1442 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1443 | */ | ||
1444 | int | ||
1445 | GNUNET_CONFIGURATION_get_value_filename ( | 1294 | GNUNET_CONFIGURATION_get_value_filename ( |
1446 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1295 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1447 | const char *section, | 1296 | const char *section, |
@@ -1466,16 +1315,7 @@ GNUNET_CONFIGURATION_get_value_filename ( | |||
1466 | } | 1315 | } |
1467 | 1316 | ||
1468 | 1317 | ||
1469 | /** | 1318 | enum GNUNET_GenericReturnValue |
1470 | * Get a configuration value that should be in a set of | ||
1471 | * "YES" or "NO". | ||
1472 | * | ||
1473 | * @param cfg configuration to inspect | ||
1474 | * @param section section of interest | ||
1475 | * @param option option of interest | ||
1476 | * @return #GNUNET_YES, #GNUNET_NO or #GNUNET_SYSERR | ||
1477 | */ | ||
1478 | int | ||
1479 | GNUNET_CONFIGURATION_get_value_yesno ( | 1319 | GNUNET_CONFIGURATION_get_value_yesno ( |
1480 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1320 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1481 | const char *section, | 1321 | const char *section, |
@@ -1495,16 +1335,6 @@ GNUNET_CONFIGURATION_get_value_yesno ( | |||
1495 | } | 1335 | } |
1496 | 1336 | ||
1497 | 1337 | ||
1498 | /** | ||
1499 | * Iterate over the set of filenames stored in a configuration value. | ||
1500 | * | ||
1501 | * @param cfg configuration to inspect | ||
1502 | * @param section section of interest | ||
1503 | * @param option option of interest | ||
1504 | * @param cb function to call on each filename | ||
1505 | * @param cb_cls closure for @a cb | ||
1506 | * @return number of filenames iterated over, -1 on error | ||
1507 | */ | ||
1508 | int | 1338 | int |
1509 | GNUNET_CONFIGURATION_iterate_value_filenames ( | 1339 | GNUNET_CONFIGURATION_iterate_value_filenames ( |
1510 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1340 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -1618,7 +1448,7 @@ escape_name (const char *value) | |||
1618 | * @param fn filename we are currently looking at | 1448 | * @param fn filename we are currently looking at |
1619 | * @return #GNUNET_OK if the names do not match, #GNUNET_SYSERR if they do | 1449 | * @return #GNUNET_OK if the names do not match, #GNUNET_SYSERR if they do |
1620 | */ | 1450 | */ |
1621 | static int | 1451 | static enum GNUNET_GenericReturnValue |
1622 | test_match (void *cls, const char *fn) | 1452 | test_match (void *cls, const char *fn) |
1623 | { | 1453 | { |
1624 | const char *of = cls; | 1454 | const char *of = cls; |
@@ -1627,19 +1457,7 @@ test_match (void *cls, const char *fn) | |||
1627 | } | 1457 | } |
1628 | 1458 | ||
1629 | 1459 | ||
1630 | /** | 1460 | enum GNUNET_GenericReturnValue |
1631 | * Append a filename to a configuration value that | ||
1632 | * represents a list of filenames | ||
1633 | * | ||
1634 | * @param cfg configuration to update | ||
1635 | * @param section section of interest | ||
1636 | * @param option option of interest | ||
1637 | * @param value filename to append | ||
1638 | * @return #GNUNET_OK on success, | ||
1639 | * #GNUNET_NO if the filename already in the list | ||
1640 | * #GNUNET_SYSERR on error | ||
1641 | */ | ||
1642 | int | ||
1643 | GNUNET_CONFIGURATION_append_value_filename ( | 1461 | GNUNET_CONFIGURATION_append_value_filename ( |
1644 | struct GNUNET_CONFIGURATION_Handle *cfg, | 1462 | struct GNUNET_CONFIGURATION_Handle *cfg, |
1645 | const char *section, | 1463 | const char *section, |
@@ -1674,19 +1492,7 @@ GNUNET_CONFIGURATION_append_value_filename ( | |||
1674 | } | 1492 | } |
1675 | 1493 | ||
1676 | 1494 | ||
1677 | /** | 1495 | enum GNUNET_GenericReturnValue |
1678 | * Remove a filename from a configuration value that | ||
1679 | * represents a list of filenames | ||
1680 | * | ||
1681 | * @param cfg configuration to update | ||
1682 | * @param section section of interest | ||
1683 | * @param option option of interest | ||
1684 | * @param value filename to remove | ||
1685 | * @return #GNUNET_OK on success, | ||
1686 | * #GNUNET_NO if the filename is not in the list, | ||
1687 | * #GNUNET_SYSERR on error | ||
1688 | */ | ||
1689 | int | ||
1690 | GNUNET_CONFIGURATION_remove_value_filename ( | 1496 | GNUNET_CONFIGURATION_remove_value_filename ( |
1691 | struct GNUNET_CONFIGURATION_Handle *cfg, | 1497 | struct GNUNET_CONFIGURATION_Handle *cfg, |
1692 | const char *section, | 1498 | const char *section, |
@@ -1771,12 +1577,11 @@ GNUNET_CONFIGURATION_remove_value_filename ( | |||
1771 | * @param filename file to parse | 1577 | * @param filename file to parse |
1772 | * @return #GNUNET_OK on success | 1578 | * @return #GNUNET_OK on success |
1773 | */ | 1579 | */ |
1774 | static int | 1580 | static enum GNUNET_GenericReturnValue |
1775 | parse_configuration_file (void *cls, const char *filename) | 1581 | parse_configuration_file (void *cls, const char *filename) |
1776 | { | 1582 | { |
1777 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1583 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1778 | char *ext; | 1584 | char *ext; |
1779 | int ret; | ||
1780 | 1585 | ||
1781 | /* Examine file extension */ | 1586 | /* Examine file extension */ |
1782 | ext = strrchr (filename, '.'); | 1587 | ext = strrchr (filename, '.'); |
@@ -1786,20 +1591,11 @@ parse_configuration_file (void *cls, const char *filename) | |||
1786 | return GNUNET_OK; | 1591 | return GNUNET_OK; |
1787 | } | 1592 | } |
1788 | 1593 | ||
1789 | ret = GNUNET_CONFIGURATION_parse (cfg, filename); | 1594 | return GNUNET_CONFIGURATION_parse (cfg, filename); |
1790 | return ret; | ||
1791 | } | 1595 | } |
1792 | 1596 | ||
1793 | 1597 | ||
1794 | /** | 1598 | enum GNUNET_GenericReturnValue |
1795 | * Load default configuration. This function will parse the | ||
1796 | * defaults from the given defaults_d directory. | ||
1797 | * | ||
1798 | * @param cfg configuration to update | ||
1799 | * @param defaults_d directory with the defaults | ||
1800 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1801 | */ | ||
1802 | int | ||
1803 | GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, | 1599 | GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, |
1804 | const char *defaults_d) | 1600 | const char *defaults_d) |
1805 | { | 1601 | { |
@@ -1810,43 +1606,31 @@ GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1810 | } | 1606 | } |
1811 | 1607 | ||
1812 | 1608 | ||
1813 | /** | ||
1814 | * Return GNUnet's default configuration. A new configuration is allocated | ||
1815 | * each time and it's up to the caller to destroy it when done. This function | ||
1816 | * returns GNUnet's configuration even when #GNUNET_OS_init has been called | ||
1817 | * with a value different from #GNUNET_OS_project_data_default. | ||
1818 | * | ||
1819 | * @return a freshly allocated configuration | ||
1820 | */ | ||
1821 | struct GNUNET_CONFIGURATION_Handle * | 1609 | struct GNUNET_CONFIGURATION_Handle * |
1822 | GNUNET_CONFIGURATION_default (void) | 1610 | GNUNET_CONFIGURATION_default (void) |
1823 | { | 1611 | { |
1824 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); | 1612 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); |
1825 | const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); | 1613 | const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); |
1826 | |||
1827 | GNUNET_OS_init (dpd); | ||
1828 | |||
1829 | struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create (); | ||
1830 | const char *xdg = getenv ("XDG_CONFIG_HOME"); | 1614 | const char *xdg = getenv ("XDG_CONFIG_HOME"); |
1831 | char *cfgname = NULL; | 1615 | char *cfgname = NULL; |
1616 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
1832 | 1617 | ||
1618 | GNUNET_OS_init (dpd); | ||
1619 | cfg = GNUNET_CONFIGURATION_create (); | ||
1833 | if (NULL != xdg) | 1620 | if (NULL != xdg) |
1834 | GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file); | 1621 | GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file); |
1835 | else | 1622 | else |
1836 | cfgname = GNUNET_strdup (pd->user_config_file); | 1623 | cfgname = GNUNET_strdup (pd->user_config_file); |
1837 | 1624 | if (GNUNET_OK != | |
1838 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgname)) | 1625 | GNUNET_CONFIGURATION_load (cfg, cfgname)) |
1839 | { | 1626 | { |
1840 | GNUNET_OS_init (pd); | 1627 | GNUNET_OS_init (pd); |
1841 | GNUNET_CONFIGURATION_destroy (cfg); | 1628 | GNUNET_CONFIGURATION_destroy (cfg); |
1842 | GNUNET_free (cfgname); | 1629 | GNUNET_free (cfgname); |
1843 | return NULL; | 1630 | return NULL; |
1844 | } | 1631 | } |
1845 | |||
1846 | GNUNET_free (cfgname); | 1632 | GNUNET_free (cfgname); |
1847 | |||
1848 | GNUNET_OS_init (pd); | 1633 | GNUNET_OS_init (pd); |
1849 | |||
1850 | return cfg; | 1634 | return cfg; |
1851 | } | 1635 | } |
1852 | 1636 | ||
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 019dbe94e..bc58142c2 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -166,12 +166,6 @@ decode_private_ecdsa_key (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | /** | ||
170 | * Extract the public key for the given private key. | ||
171 | * | ||
172 | * @param priv the private key | ||
173 | * @param pub where to write the public key | ||
174 | */ | ||
175 | void | 169 | void |
176 | GNUNET_CRYPTO_ecdsa_key_get_public ( | 170 | GNUNET_CRYPTO_ecdsa_key_get_public ( |
177 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 171 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -183,12 +177,6 @@ GNUNET_CRYPTO_ecdsa_key_get_public ( | |||
183 | } | 177 | } |
184 | 178 | ||
185 | 179 | ||
186 | /** | ||
187 | * Extract the public key for the given private key. | ||
188 | * | ||
189 | * @param priv the private key | ||
190 | * @param pub where to write the public key | ||
191 | */ | ||
192 | void | 180 | void |
193 | GNUNET_CRYPTO_eddsa_key_get_public ( | 181 | GNUNET_CRYPTO_eddsa_key_get_public ( |
194 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 182 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
@@ -205,12 +193,6 @@ GNUNET_CRYPTO_eddsa_key_get_public ( | |||
205 | } | 193 | } |
206 | 194 | ||
207 | 195 | ||
208 | /** | ||
209 | * Extract the public key for the given private key. | ||
210 | * | ||
211 | * @param priv the private key | ||
212 | * @param pub where to write the public key | ||
213 | */ | ||
214 | void | 196 | void |
215 | GNUNET_CRYPTO_ecdhe_key_get_public ( | 197 | GNUNET_CRYPTO_ecdhe_key_get_public ( |
216 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 198 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
@@ -222,12 +204,6 @@ GNUNET_CRYPTO_ecdhe_key_get_public ( | |||
222 | } | 204 | } |
223 | 205 | ||
224 | 206 | ||
225 | /** | ||
226 | * Convert a public key to a string. | ||
227 | * | ||
228 | * @param pub key to convert | ||
229 | * @return string representing @a pub | ||
230 | */ | ||
231 | char * | 207 | char * |
232 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( | 208 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( |
233 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) | 209 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
@@ -255,12 +231,6 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string ( | |||
255 | } | 231 | } |
256 | 232 | ||
257 | 233 | ||
258 | /** | ||
259 | * Convert a public key to a string. | ||
260 | * | ||
261 | * @param pub key to convert | ||
262 | * @return string representing @a pub | ||
263 | */ | ||
264 | char * | 234 | char * |
265 | GNUNET_CRYPTO_eddsa_public_key_to_string ( | 235 | GNUNET_CRYPTO_eddsa_public_key_to_string ( |
266 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) | 236 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
@@ -288,12 +258,6 @@ GNUNET_CRYPTO_eddsa_public_key_to_string ( | |||
288 | } | 258 | } |
289 | 259 | ||
290 | 260 | ||
291 | /** | ||
292 | * Convert a private key to a string. | ||
293 | * | ||
294 | * @param priv key to convert | ||
295 | * @return string representing @a pub | ||
296 | */ | ||
297 | char * | 261 | char * |
298 | GNUNET_CRYPTO_eddsa_private_key_to_string ( | 262 | GNUNET_CRYPTO_eddsa_private_key_to_string ( |
299 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | 263 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) |
@@ -321,12 +285,6 @@ GNUNET_CRYPTO_eddsa_private_key_to_string ( | |||
321 | } | 285 | } |
322 | 286 | ||
323 | 287 | ||
324 | /** | ||
325 | * Convert a private key to a string. | ||
326 | * | ||
327 | * @param priv key to convert | ||
328 | * @return string representing @a priv | ||
329 | */ | ||
330 | char * | 288 | char * |
331 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( | 289 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( |
332 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | 290 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) |
@@ -354,15 +312,7 @@ GNUNET_CRYPTO_ecdsa_private_key_to_string ( | |||
354 | } | 312 | } |
355 | 313 | ||
356 | 314 | ||
357 | /** | 315 | enum GNUNET_GenericReturnValue |
358 | * Convert a string representing a public key to a public key. | ||
359 | * | ||
360 | * @param enc encoded public key | ||
361 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
362 | * @param pub where to store the public key | ||
363 | * @return #GNUNET_OK on success | ||
364 | */ | ||
365 | int | ||
366 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( | 316 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( |
367 | const char *enc, | 317 | const char *enc, |
368 | size_t enclen, | 318 | size_t enclen, |
@@ -387,15 +337,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string ( | |||
387 | } | 337 | } |
388 | 338 | ||
389 | 339 | ||
390 | /** | 340 | enum GNUNET_GenericReturnValue |
391 | * Convert a string representing a public key to a public key. | ||
392 | * | ||
393 | * @param enc encoded public key | ||
394 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
395 | * @param pub where to store the public key | ||
396 | * @return #GNUNET_OK on success | ||
397 | */ | ||
398 | int | ||
399 | GNUNET_CRYPTO_eddsa_public_key_from_string ( | 341 | GNUNET_CRYPTO_eddsa_public_key_from_string ( |
400 | const char *enc, | 342 | const char *enc, |
401 | size_t enclen, | 343 | size_t enclen, |
@@ -420,15 +362,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string ( | |||
420 | } | 362 | } |
421 | 363 | ||
422 | 364 | ||
423 | /** | 365 | enum GNUNET_GenericReturnValue |
424 | * Convert a string representing a private key to a private key. | ||
425 | * | ||
426 | * @param enc encoded public key | ||
427 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
428 | * @param priv where to store the private key | ||
429 | * @return #GNUNET_OK on success | ||
430 | */ | ||
431 | int | ||
432 | GNUNET_CRYPTO_eddsa_private_key_from_string ( | 366 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
433 | const char *enc, | 367 | const char *enc, |
434 | size_t enclen, | 368 | size_t enclen, |
@@ -460,12 +394,6 @@ GNUNET_CRYPTO_eddsa_private_key_from_string ( | |||
460 | } | 394 | } |
461 | 395 | ||
462 | 396 | ||
463 | /** | ||
464 | * @ingroup crypto | ||
465 | * Clear memory that was used to store a private key. | ||
466 | * | ||
467 | * @param pk location of the key | ||
468 | */ | ||
469 | void | 397 | void |
470 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 398 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
471 | { | 399 | { |
@@ -473,12 +401,6 @@ GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
473 | } | 401 | } |
474 | 402 | ||
475 | 403 | ||
476 | /** | ||
477 | * @ingroup crypto | ||
478 | * Clear memory that was used to store a private key. | ||
479 | * | ||
480 | * @param pk location of the key | ||
481 | */ | ||
482 | void | 404 | void |
483 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 405 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) |
484 | { | 406 | { |
@@ -486,12 +408,6 @@ GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | |||
486 | } | 408 | } |
487 | 409 | ||
488 | 410 | ||
489 | /** | ||
490 | * @ingroup crypto | ||
491 | * Clear memory that was used to store a private key. | ||
492 | * | ||
493 | * @param pk location of the key | ||
494 | */ | ||
495 | void | 411 | void |
496 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 412 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) |
497 | { | 413 | { |
@@ -499,11 +415,6 @@ GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | |||
499 | } | 415 | } |
500 | 416 | ||
501 | 417 | ||
502 | /** | ||
503 | * Create a new private key. | ||
504 | * | ||
505 | * @param[out] pk fresh private key | ||
506 | */ | ||
507 | void | 418 | void |
508 | GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 419 | GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
509 | { | 420 | { |
@@ -515,11 +426,6 @@ GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
515 | } | 426 | } |
516 | 427 | ||
517 | 428 | ||
518 | /** | ||
519 | * Create a new private key. | ||
520 | * | ||
521 | * @param[out] pk private key to initialize | ||
522 | */ | ||
523 | void | 429 | void |
524 | GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 430 | GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) |
525 | { | 431 | { |
@@ -535,11 +441,6 @@ GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | |||
535 | } | 441 | } |
536 | 442 | ||
537 | 443 | ||
538 | /** | ||
539 | * Create a new private key. | ||
540 | * | ||
541 | * @param[out] pk set to fresh private key | ||
542 | */ | ||
543 | void | 444 | void |
544 | GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 445 | GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) |
545 | { | 446 | { |
@@ -560,11 +461,6 @@ GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | |||
560 | } | 461 | } |
561 | 462 | ||
562 | 463 | ||
563 | /** | ||
564 | * Get the shared private key we use for anonymous users. | ||
565 | * | ||
566 | * @return "anonymous" private key | ||
567 | */ | ||
568 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 464 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * |
569 | GNUNET_CRYPTO_ecdsa_key_get_anonymous () | 465 | GNUNET_CRYPTO_ecdsa_key_get_anonymous () |
570 | { | 466 | { |
@@ -629,19 +525,7 @@ data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
629 | } | 525 | } |
630 | 526 | ||
631 | 527 | ||
632 | /** | 528 | enum GNUNET_GenericReturnValue |
633 | * Sign a given block. The @a purpose data is the | ||
634 | * beginning of the data of which the signature is to be | ||
635 | * created. The `size` field in @a purpose must correctly | ||
636 | * indicate the number of bytes of the data structure, including | ||
637 | * its header. | ||
638 | * | ||
639 | * @param priv private key to use for the signing | ||
640 | * @param purpose what to sign (size, purpose) | ||
641 | * @param sig where to write the signature | ||
642 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
643 | */ | ||
644 | int | ||
645 | GNUNET_CRYPTO_ecdsa_sign_ ( | 529 | GNUNET_CRYPTO_ecdsa_sign_ ( |
646 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 530 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
647 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 531 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -691,19 +575,7 @@ GNUNET_CRYPTO_ecdsa_sign_ ( | |||
691 | } | 575 | } |
692 | 576 | ||
693 | 577 | ||
694 | /** | 578 | enum GNUNET_GenericReturnValue |
695 | * Sign a given block. The @a purpose data is the | ||
696 | * beginning of the data of which the signature is to be | ||
697 | * created. The `size` field in @a purpose must correctly | ||
698 | * indicate the number of bytes of the data structure, including | ||
699 | * its header. | ||
700 | * | ||
701 | * @param priv private key to use for the signing | ||
702 | * @param purpose what to sign (size, purpose) | ||
703 | * @param sig where to write the signature | ||
704 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
705 | */ | ||
706 | int | ||
707 | GNUNET_CRYPTO_eddsa_sign_ ( | 579 | GNUNET_CRYPTO_eddsa_sign_ ( |
708 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 580 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
709 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 581 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -727,21 +599,7 @@ GNUNET_CRYPTO_eddsa_sign_ ( | |||
727 | } | 599 | } |
728 | 600 | ||
729 | 601 | ||
730 | /** | 602 | enum GNUNET_GenericReturnValue |
731 | * Verify signature. The @a validate data is the | ||
732 | * beginning of the data of which the signature is to be | ||
733 | * verified. The `size` field in @a validate must correctly | ||
734 | * indicate the number of bytes of the data structure, including | ||
735 | * its header. If @a purpose does not match the purpose given | ||
736 | * in @a validate (the latter | ||
737 | * | ||
738 | * @param purpose what is the purpose that the signature should have? | ||
739 | * @param validate block to validate (size, purpose, data) | ||
740 | * @param sig signature that is being validated | ||
741 | * @param pub public key of the signer | ||
742 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
743 | */ | ||
744 | int | ||
745 | GNUNET_CRYPTO_ecdsa_verify_ ( | 603 | GNUNET_CRYPTO_ecdsa_verify_ ( |
746 | uint32_t purpose, | 604 | uint32_t purpose, |
747 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 605 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -800,22 +658,7 @@ GNUNET_CRYPTO_ecdsa_verify_ ( | |||
800 | } | 658 | } |
801 | 659 | ||
802 | 660 | ||
803 | /** | 661 | enum GNUNET_GenericReturnValue |
804 | * Verify signature. The @a validate data is the | ||
805 | * beginning of the data of which the signature is to be | ||
806 | * verified. The `size` field in @a validate must correctly | ||
807 | * indicate the number of bytes of the data structure, including | ||
808 | * its header. If @a purpose does not match the purpose given | ||
809 | * in @a validate (the latter must be in big endian), signature | ||
810 | * verification fails. | ||
811 | * | ||
812 | * @param purpose what is the purpose that the signature should have? | ||
813 | * @param validate block to validate (size, purpose, data) | ||
814 | * @param sig signature that is being validated | ||
815 | * @param pub public key of the signer | ||
816 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
817 | */ | ||
818 | int | ||
819 | GNUNET_CRYPTO_eddsa_verify_ ( | 662 | GNUNET_CRYPTO_eddsa_verify_ ( |
820 | uint32_t purpose, | 663 | uint32_t purpose, |
821 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 664 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -838,15 +681,7 @@ GNUNET_CRYPTO_eddsa_verify_ ( | |||
838 | } | 681 | } |
839 | 682 | ||
840 | 683 | ||
841 | /** | 684 | enum GNUNET_GenericReturnValue |
842 | * Derive key material from a public and a private ECDHE key. | ||
843 | * | ||
844 | * @param priv private key to use for the ECDH (x) | ||
845 | * @param pub public key to use for the ECDH (yG) | ||
846 | * @param key_material where to write the key material (xyG) | ||
847 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
848 | */ | ||
849 | int | ||
850 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 685 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
851 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 686 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
852 | struct GNUNET_HashCode *key_material) | 687 | struct GNUNET_HashCode *key_material) |
@@ -895,18 +730,6 @@ derive_h (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | |||
895 | } | 730 | } |
896 | 731 | ||
897 | 732 | ||
898 | /** | ||
899 | * Derive a private key from a given private key and a label. | ||
900 | * Essentially calculates a private key 'd = H(l,P) * x mod n' | ||
901 | * where n is the size of the ECC group and P is the public | ||
902 | * key associated with the private key 'd'. | ||
903 | * | ||
904 | * @param priv original private key | ||
905 | * @param label label to use for key deriviation | ||
906 | * @param context additional context to use for HKDF of 'h'; | ||
907 | * typically the name of the subsystem/application | ||
908 | * @return derived private key | ||
909 | */ | ||
910 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 733 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
911 | GNUNET_CRYPTO_ecdsa_private_key_derive ( | 734 | GNUNET_CRYPTO_ecdsa_private_key_derive ( |
912 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 735 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -949,16 +772,6 @@ GNUNET_CRYPTO_ecdsa_private_key_derive ( | |||
949 | } | 772 | } |
950 | 773 | ||
951 | 774 | ||
952 | /** | ||
953 | * Derive a public key from a given public key and a label. | ||
954 | * Essentially calculates a public key 'V = H(l,P) * P'. | ||
955 | * | ||
956 | * @param pub original public key | ||
957 | * @param label label to use for key derivation | ||
958 | * @param context additional context to use for HKDF of 'h'; | ||
959 | * typically the name of the subsystem/application | ||
960 | * @param result where to write the derived public key | ||
961 | */ | ||
962 | void | 775 | void |
963 | GNUNET_CRYPTO_ecdsa_public_key_derive ( | 776 | GNUNET_CRYPTO_ecdsa_public_key_derive ( |
964 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 777 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
@@ -1010,17 +823,7 @@ GNUNET_CRYPTO_ecdsa_public_key_derive ( | |||
1010 | } | 823 | } |
1011 | 824 | ||
1012 | 825 | ||
1013 | /** | 826 | enum GNUNET_GenericReturnValue |
1014 | * @ingroup crypto | ||
1015 | * Derive key material from a ECDH public key and a private EdDSA key. | ||
1016 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. | ||
1017 | * | ||
1018 | * @param priv private key from EdDSA to use for the ECDH (x) | ||
1019 | * @param pub public key to use for the ECDH (yG) | ||
1020 | * @param key_material where to write the key material H(h(x)yG) | ||
1021 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1022 | */ | ||
1023 | int | ||
1024 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 827 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1025 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 828 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1026 | struct GNUNET_HashCode *key_material) | 829 | struct GNUNET_HashCode *key_material) |
@@ -1042,17 +845,7 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1042 | } | 845 | } |
1043 | 846 | ||
1044 | 847 | ||
1045 | /** | 848 | enum GNUNET_GenericReturnValue |
1046 | * @ingroup crypto | ||
1047 | * Derive key material from a ECDH public key and a private ECDSA key. | ||
1048 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. | ||
1049 | * | ||
1050 | * @param priv private key from ECDSA to use for the ECDH (x) | ||
1051 | * @param pub public key to use for the ECDH (yG) | ||
1052 | * @param key_material where to write the key material H(h(x)yG) | ||
1053 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1054 | */ | ||
1055 | int | ||
1056 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 849 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1057 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 850 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1058 | struct GNUNET_HashCode *key_material) | 851 | struct GNUNET_HashCode *key_material) |
@@ -1070,17 +863,7 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1070 | } | 863 | } |
1071 | 864 | ||
1072 | 865 | ||
1073 | /** | 866 | enum GNUNET_GenericReturnValue |
1074 | * @ingroup crypto | ||
1075 | * Derive key material from a EdDSA public key and a private ECDH key. | ||
1076 | * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. | ||
1077 | * | ||
1078 | * @param priv private key to use for the ECDH (y) | ||
1079 | * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) | ||
1080 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1081 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1082 | */ | ||
1083 | int | ||
1084 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 867 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1085 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 868 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1086 | struct GNUNET_HashCode *key_material) | 869 | struct GNUNET_HashCode *key_material) |
@@ -1097,17 +880,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1097 | } | 880 | } |
1098 | 881 | ||
1099 | 882 | ||
1100 | /** | 883 | enum GNUNET_GenericReturnValue |
1101 | * @ingroup crypto | ||
1102 | * Derive key material from a ECDSA public key and a private ECDH key. | ||
1103 | * Dual to #GNUNET_CRYPTO_ecdsa_ecdh. | ||
1104 | * | ||
1105 | * @param priv private key to use for the ECDH (y) | ||
1106 | * @param pub public key from ECDSA to use for the ECDH (X=h(x)G) | ||
1107 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1108 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1109 | */ | ||
1110 | int | ||
1111 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 884 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1112 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 885 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1113 | struct GNUNET_HashCode *key_material) | 886 | struct GNUNET_HashCode *key_material) |
diff --git a/src/util/crypto_ecc_setup.c b/src/util/crypto_ecc_setup.c index 6c71030b2..f7cd8c6d9 100644 --- a/src/util/crypto_ecc_setup.c +++ b/src/util/crypto_ecc_setup.c | |||
@@ -61,7 +61,7 @@ | |||
61 | * @param buf_size number of bytes in @a buf | 61 | * @param buf_size number of bytes in @a buf |
62 | * @return #GNUNET_OK on success | 62 | * @return #GNUNET_OK on success |
63 | */ | 63 | */ |
64 | static int | 64 | static enum GNUNET_GenericReturnValue |
65 | read_from_file (const char *filename, | 65 | read_from_file (const char *filename, |
66 | void *buf, | 66 | void *buf, |
67 | size_t buf_size) | 67 | size_t buf_size) |
@@ -123,104 +123,6 @@ read_from_file (const char *filename, | |||
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Write contents of @a buf atomically to @a filename. | ||
127 | * Fail if @a filename already exists or if not exactly | ||
128 | * @a buf with @a buf_size bytes could be written to | ||
129 | * @a filename. | ||
130 | * | ||
131 | * @param filename where to write | ||
132 | * @param buf buffer to write | ||
133 | * @param buf_size number of bytes in @a buf to write | ||
134 | * @return #GNUNET_OK on success, | ||
135 | * #GNUNET_NO if a file existed under @a filename | ||
136 | * #GNUNET_SYSERR on failure | ||
137 | */ | ||
138 | static int | ||
139 | atomic_write_to_file (const char *filename, | ||
140 | const void *buf, | ||
141 | size_t buf_size) | ||
142 | { | ||
143 | char *tmpl; | ||
144 | int fd; | ||
145 | |||
146 | if (GNUNET_OK != | ||
147 | GNUNET_DISK_directory_create_for_file (filename)) | ||
148 | { | ||
149 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
150 | "mkstemp", | ||
151 | filename); | ||
152 | return GNUNET_SYSERR; | ||
153 | } | ||
154 | { | ||
155 | char *dname; | ||
156 | |||
157 | dname = GNUNET_strdup (filename); | ||
158 | GNUNET_asprintf (&tmpl, | ||
159 | "%s/XXXXXX", | ||
160 | dirname (dname)); | ||
161 | GNUNET_free (dname); | ||
162 | } | ||
163 | fd = mkstemp (tmpl); | ||
164 | if (-1 == fd) | ||
165 | { | ||
166 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
167 | "mkstemp", | ||
168 | tmpl); | ||
169 | GNUNET_free (tmpl); | ||
170 | return GNUNET_SYSERR; | ||
171 | } | ||
172 | if (0 != fchmod (fd, | ||
173 | S_IRUSR)) | ||
174 | { | ||
175 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
176 | "chmod", | ||
177 | tmpl); | ||
178 | GNUNET_assert (0 == close (fd)); | ||
179 | if (0 != unlink (tmpl)) | ||
180 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
181 | "unlink", | ||
182 | tmpl); | ||
183 | GNUNET_free (tmpl); | ||
184 | return GNUNET_SYSERR; | ||
185 | } | ||
186 | if (buf_size != | ||
187 | write (fd, | ||
188 | buf, | ||
189 | buf_size)) | ||
190 | { | ||
191 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
192 | "write", | ||
193 | tmpl); | ||
194 | GNUNET_assert (0 == close (fd)); | ||
195 | if (0 != unlink (tmpl)) | ||
196 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
197 | "unlink", | ||
198 | tmpl); | ||
199 | GNUNET_free (tmpl); | ||
200 | return GNUNET_SYSERR; | ||
201 | } | ||
202 | GNUNET_assert (0 == close (fd)); | ||
203 | |||
204 | if (0 != link (tmpl, | ||
205 | filename)) | ||
206 | { | ||
207 | if (0 != unlink (tmpl)) | ||
208 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
209 | "unlink", | ||
210 | tmpl); | ||
211 | GNUNET_free (tmpl); | ||
212 | return GNUNET_NO; | ||
213 | } | ||
214 | if (0 != unlink (tmpl)) | ||
215 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
216 | "unlink", | ||
217 | tmpl); | ||
218 | GNUNET_free (tmpl); | ||
219 | return GNUNET_OK; | ||
220 | } | ||
221 | |||
222 | |||
223 | /** | ||
224 | * @ingroup crypto | 126 | * @ingroup crypto |
225 | * @brief Create a new private key by reading it from a file. | 127 | * @brief Create a new private key by reading it from a file. |
226 | * | 128 | * |
@@ -235,12 +137,12 @@ atomic_write_to_file (const char *filename, | |||
235 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but | 137 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but |
236 | * we found an existing file, #GNUNET_SYSERR on failure | 138 | * we found an existing file, #GNUNET_SYSERR on failure |
237 | */ | 139 | */ |
238 | int | 140 | enum GNUNET_GenericReturnValue |
239 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | 141 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, |
240 | int do_create, | 142 | int do_create, |
241 | struct GNUNET_CRYPTO_EddsaPrivateKey *pkey) | 143 | struct GNUNET_CRYPTO_EddsaPrivateKey *pkey) |
242 | { | 144 | { |
243 | int ret; | 145 | enum GNUNET_GenericReturnValue ret; |
244 | 146 | ||
245 | if (GNUNET_OK == | 147 | if (GNUNET_OK == |
246 | read_from_file (filename, | 148 | read_from_file (filename, |
@@ -251,9 +153,10 @@ GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | |||
251 | return (do_create) ? GNUNET_NO : GNUNET_OK; | 153 | return (do_create) ? GNUNET_NO : GNUNET_OK; |
252 | } | 154 | } |
253 | GNUNET_CRYPTO_eddsa_key_create (pkey); | 155 | GNUNET_CRYPTO_eddsa_key_create (pkey); |
254 | ret = atomic_write_to_file (filename, | 156 | ret = GNUNET_DISK_fn_write (filename, |
255 | pkey, | 157 | pkey, |
256 | sizeof (*pkey)); | 158 | sizeof (*pkey), |
159 | GNUNET_DISK_PERM_USER_READ); | ||
257 | if ( (GNUNET_OK == ret) || | 160 | if ( (GNUNET_OK == ret) || |
258 | (GNUNET_SYSERR == ret) ) | 161 | (GNUNET_SYSERR == ret) ) |
259 | return ret; | 162 | return ret; |
@@ -286,7 +189,7 @@ GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | |||
286 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but | 189 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but |
287 | * we found an existing file, #GNUNET_SYSERR on failure | 190 | * we found an existing file, #GNUNET_SYSERR on failure |
288 | */ | 191 | */ |
289 | int | 192 | enum GNUNET_GenericReturnValue |
290 | GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, | 193 | GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, |
291 | int do_create, | 194 | int do_create, |
292 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey) | 195 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey) |
@@ -301,9 +204,10 @@ GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, | |||
301 | } | 204 | } |
302 | GNUNET_CRYPTO_ecdsa_key_create (pkey); | 205 | GNUNET_CRYPTO_ecdsa_key_create (pkey); |
303 | if (GNUNET_OK == | 206 | if (GNUNET_OK == |
304 | atomic_write_to_file (filename, | 207 | GNUNET_DISK_fn_write (filename, |
305 | pkey, | 208 | pkey, |
306 | sizeof (*pkey))) | 209 | sizeof (*pkey), |
210 | GNUNET_DISK_PERM_USER_READ)) | ||
307 | return GNUNET_OK; | 211 | return GNUNET_OK; |
308 | /* maybe another process succeeded in the meantime, try reading one more time */ | 212 | /* maybe another process succeeded in the meantime, try reading one more time */ |
309 | if (GNUNET_OK == | 213 | if (GNUNET_OK == |
@@ -357,7 +261,7 @@ GNUNET_CRYPTO_eddsa_key_create_from_configuration ( | |||
357 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity | 261 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity |
358 | * could not be retrieved | 262 | * could not be retrieved |
359 | */ | 263 | */ |
360 | int | 264 | enum GNUNET_GenericReturnValue |
361 | GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, | 265 | GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, |
362 | struct GNUNET_PeerIdentity *dst) | 266 | struct GNUNET_PeerIdentity *dst) |
363 | { | 267 | { |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index fec4d13db..63232cab6 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -139,12 +139,6 @@ key_from_sexp (gcry_mpi_t *array, | |||
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | /** | ||
143 | * Create a new private key. Caller must free return value. | ||
144 | * | ||
145 | * @param len length of the key in bits (i.e. 2048) | ||
146 | * @return fresh private key | ||
147 | */ | ||
148 | struct GNUNET_CRYPTO_RsaPrivateKey * | 142 | struct GNUNET_CRYPTO_RsaPrivateKey * |
149 | GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) | 143 | GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) |
150 | { | 144 | { |
@@ -174,11 +168,6 @@ GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) | |||
174 | } | 168 | } |
175 | 169 | ||
176 | 170 | ||
177 | /** | ||
178 | * Free memory occupied by the private key. | ||
179 | * | ||
180 | * @param key pointer to the memory to free | ||
181 | */ | ||
182 | void | 171 | void |
183 | GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key) | 172 | GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key) |
184 | { | 173 | { |
@@ -187,14 +176,6 @@ GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key) | |||
187 | } | 176 | } |
188 | 177 | ||
189 | 178 | ||
190 | /** | ||
191 | * Encode the private key in a format suitable for | ||
192 | * storing it into a file. | ||
193 | * | ||
194 | * @param key the private key | ||
195 | * @param[out] buffer set to a buffer with the encoded key | ||
196 | * @return size of memory allocated in @a buffer | ||
197 | */ | ||
198 | size_t | 179 | size_t |
199 | GNUNET_CRYPTO_rsa_private_key_encode (const struct | 180 | GNUNET_CRYPTO_rsa_private_key_encode (const struct |
200 | GNUNET_CRYPTO_RsaPrivateKey *key, | 181 | GNUNET_CRYPTO_RsaPrivateKey *key, |
@@ -218,14 +199,6 @@ GNUNET_CRYPTO_rsa_private_key_encode (const struct | |||
218 | } | 199 | } |
219 | 200 | ||
220 | 201 | ||
221 | /** | ||
222 | * Decode the private key from the data-format back | ||
223 | * to the "normal", internal format. | ||
224 | * | ||
225 | * @param buf the buffer where the private key data is stored | ||
226 | * @param buf_size the size of the data in @a buf | ||
227 | * @return NULL on error | ||
228 | */ | ||
229 | struct GNUNET_CRYPTO_RsaPrivateKey * | 202 | struct GNUNET_CRYPTO_RsaPrivateKey * |
230 | GNUNET_CRYPTO_rsa_private_key_decode (const void *buf, | 203 | GNUNET_CRYPTO_rsa_private_key_decode (const void *buf, |
231 | size_t buf_size) | 204 | size_t buf_size) |
@@ -255,12 +228,6 @@ GNUNET_CRYPTO_rsa_private_key_decode (const void *buf, | |||
255 | } | 228 | } |
256 | 229 | ||
257 | 230 | ||
258 | /** | ||
259 | * Extract the public key of the given private key. | ||
260 | * | ||
261 | * @param priv the private key | ||
262 | * @return NULL on error, otherwise the public key | ||
263 | */ | ||
264 | struct GNUNET_CRYPTO_RsaPublicKey * | 231 | struct GNUNET_CRYPTO_RsaPublicKey * |
265 | GNUNET_CRYPTO_rsa_private_key_get_public ( | 232 | GNUNET_CRYPTO_rsa_private_key_get_public ( |
266 | const struct GNUNET_CRYPTO_RsaPrivateKey *priv) | 233 | const struct GNUNET_CRYPTO_RsaPrivateKey *priv) |
@@ -296,11 +263,6 @@ GNUNET_CRYPTO_rsa_private_key_get_public ( | |||
296 | } | 263 | } |
297 | 264 | ||
298 | 265 | ||
299 | /** | ||
300 | * Free memory occupied by the public key. | ||
301 | * | ||
302 | * @param key pointer to the memory to free | ||
303 | */ | ||
304 | void | 266 | void |
305 | GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key) | 267 | GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key) |
306 | { | 268 | { |
@@ -334,14 +296,6 @@ struct GNUNET_CRYPTO_RsaPublicKeyHeaderP | |||
334 | GNUNET_NETWORK_STRUCT_END | 296 | GNUNET_NETWORK_STRUCT_END |
335 | 297 | ||
336 | 298 | ||
337 | /** | ||
338 | * Encode the public key in a format suitable for | ||
339 | * storing it into a file. | ||
340 | * | ||
341 | * @param key the private key | ||
342 | * @param[out] buffer set to a buffer with the encoded key | ||
343 | * @return size of memory allocated in @a buffer | ||
344 | */ | ||
345 | size_t | 299 | size_t |
346 | GNUNET_CRYPTO_rsa_public_key_encode ( | 300 | GNUNET_CRYPTO_rsa_public_key_encode ( |
347 | const struct GNUNET_CRYPTO_RsaPublicKey *key, | 301 | const struct GNUNET_CRYPTO_RsaPublicKey *key, |
@@ -409,12 +363,6 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
409 | } | 363 | } |
410 | 364 | ||
411 | 365 | ||
412 | /** | ||
413 | * Compute hash over the public key. | ||
414 | * | ||
415 | * @param key public key to hash | ||
416 | * @param hc where to store the hash code | ||
417 | */ | ||
418 | void | 366 | void |
419 | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | 367 | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, |
420 | struct GNUNET_HashCode *hc) | 368 | struct GNUNET_HashCode *hc) |
@@ -431,14 +379,6 @@ GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | |||
431 | } | 379 | } |
432 | 380 | ||
433 | 381 | ||
434 | /** | ||
435 | * Decode the public key from the data-format back | ||
436 | * to the "normal", internal format. | ||
437 | * | ||
438 | * @param buf the buffer where the public key data is stored | ||
439 | * @param len the length of the data in @a buf | ||
440 | * @return NULL on error | ||
441 | */ | ||
442 | struct GNUNET_CRYPTO_RsaPublicKey * | 382 | struct GNUNET_CRYPTO_RsaPublicKey * |
443 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, | 383 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, |
444 | size_t len) | 384 | size_t len) |
@@ -612,13 +552,6 @@ rsa_blinding_key_derive (const struct GNUNET_CRYPTO_RsaPublicKey *pkey, | |||
612 | */ | 552 | */ |
613 | 553 | ||
614 | 554 | ||
615 | /** | ||
616 | * Compare the values of two signatures. | ||
617 | * | ||
618 | * @param s1 one signature | ||
619 | * @param s2 the other signature | ||
620 | * @return 0 if the two are equal | ||
621 | */ | ||
622 | int | 555 | int |
623 | GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, | 556 | GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, |
624 | const struct GNUNET_CRYPTO_RsaSignature *s2) | 557 | const struct GNUNET_CRYPTO_RsaSignature *s2) |
@@ -645,13 +578,6 @@ GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, | |||
645 | } | 578 | } |
646 | 579 | ||
647 | 580 | ||
648 | /** | ||
649 | * Compare the values of two public keys. | ||
650 | * | ||
651 | * @param p1 one public key | ||
652 | * @param p2 the other public key | ||
653 | * @return 0 if the two are equal | ||
654 | */ | ||
655 | int | 581 | int |
656 | GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, | 582 | GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, |
657 | const struct GNUNET_CRYPTO_RsaPublicKey *p2) | 583 | const struct GNUNET_CRYPTO_RsaPublicKey *p2) |
@@ -678,13 +604,6 @@ GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, | |||
678 | } | 604 | } |
679 | 605 | ||
680 | 606 | ||
681 | /** | ||
682 | * Compare the values of two private keys. | ||
683 | * | ||
684 | * @param p1 one private key | ||
685 | * @param p2 the other private key | ||
686 | * @return 0 if the two are equal | ||
687 | */ | ||
688 | int | 607 | int |
689 | GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1, | 608 | GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1, |
690 | const struct GNUNET_CRYPTO_RsaPrivateKey *p2) | 609 | const struct GNUNET_CRYPTO_RsaPrivateKey *p2) |
@@ -711,12 +630,6 @@ GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1, | |||
711 | } | 630 | } |
712 | 631 | ||
713 | 632 | ||
714 | /** | ||
715 | * Obtain the length of the RSA key in bits. | ||
716 | * | ||
717 | * @param key the public key to introspect | ||
718 | * @return length of the key in bits | ||
719 | */ | ||
720 | unsigned int | 633 | unsigned int |
721 | GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key) | 634 | GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key) |
722 | { | 635 | { |
@@ -827,17 +740,7 @@ rsa_full_domain_hash (const struct GNUNET_CRYPTO_RsaPublicKey *pkey, | |||
827 | } | 740 | } |
828 | 741 | ||
829 | 742 | ||
830 | /** | 743 | enum GNUNET_GenericReturnValue |
831 | * Blinds the given message with the given blinding key | ||
832 | * | ||
833 | * @param hash hash of the message to sign | ||
834 | * @param bkey the blinding key | ||
835 | * @param pkey the public key of the signer | ||
836 | * @param[out] buf set to a buffer with the blinded message to be signed | ||
837 | * @param[out] buf_size number of bytes stored in @a buf | ||
838 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious | ||
839 | */ | ||
840 | int | ||
841 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | 744 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, |
842 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 745 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
843 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, | 746 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, |
@@ -863,7 +766,7 @@ GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | |||
863 | GNUNET_break (0); | 766 | GNUNET_break (0); |
864 | *buf = NULL; | 767 | *buf = NULL; |
865 | *buf_size = 0; | 768 | *buf_size = 0; |
866 | return 0; | 769 | return GNUNET_NO; |
867 | } | 770 | } |
868 | 771 | ||
869 | data = rsa_full_domain_hash (pkey, hash); | 772 | data = rsa_full_domain_hash (pkey, hash); |
@@ -993,14 +896,6 @@ rsa_sign_mpi (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
993 | } | 896 | } |
994 | 897 | ||
995 | 898 | ||
996 | /** | ||
997 | * Sign a blinded value, which must be a full domain hash of a message. | ||
998 | * | ||
999 | * @param key private key to use for the signing | ||
1000 | * @param msg the message to sign | ||
1001 | * @param msg_len number of bytes in @a msg to sign | ||
1002 | * @return NULL on error, signature on success | ||
1003 | */ | ||
1004 | struct GNUNET_CRYPTO_RsaSignature * | 899 | struct GNUNET_CRYPTO_RsaSignature * |
1005 | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 900 | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
1006 | const void *msg, | 901 | const void *msg, |
@@ -1025,13 +920,6 @@ GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
1025 | } | 920 | } |
1026 | 921 | ||
1027 | 922 | ||
1028 | /** | ||
1029 | * Create and sign a full domain hash of a message. | ||
1030 | * | ||
1031 | * @param key private key to use for the signing | ||
1032 | * @param hash the hash of the message to sign | ||
1033 | * @return NULL on error, including a malicious RSA key, signature on success | ||
1034 | */ | ||
1035 | struct GNUNET_CRYPTO_RsaSignature * | 923 | struct GNUNET_CRYPTO_RsaSignature * |
1036 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 924 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
1037 | const struct GNUNET_HashCode *hash) | 925 | const struct GNUNET_HashCode *hash) |
@@ -1052,11 +940,6 @@ GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
1052 | } | 940 | } |
1053 | 941 | ||
1054 | 942 | ||
1055 | /** | ||
1056 | * Free memory occupied by signature. | ||
1057 | * | ||
1058 | * @param sig memory to free | ||
1059 | */ | ||
1060 | void | 943 | void |
1061 | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig) | 944 | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig) |
1062 | { | 945 | { |
@@ -1065,13 +948,6 @@ GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig) | |||
1065 | } | 948 | } |
1066 | 949 | ||
1067 | 950 | ||
1068 | /** | ||
1069 | * Encode the given signature in a format suitable for storing it into a file. | ||
1070 | * | ||
1071 | * @param sig the signature | ||
1072 | * @param[out] buffer set to a buffer with the encoded key | ||
1073 | * @return size of memory allocated in @a buffer | ||
1074 | */ | ||
1075 | size_t | 951 | size_t |
1076 | GNUNET_CRYPTO_rsa_signature_encode ( | 952 | GNUNET_CRYPTO_rsa_signature_encode ( |
1077 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 953 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
@@ -1112,14 +988,6 @@ GNUNET_CRYPTO_rsa_signature_encode ( | |||
1112 | } | 988 | } |
1113 | 989 | ||
1114 | 990 | ||
1115 | /** | ||
1116 | * Decode the signature from the data-format back to the "normal", internal | ||
1117 | * format. | ||
1118 | * | ||
1119 | * @param buf the buffer where the public key data is stored | ||
1120 | * @param buf_size the size of the data in @a buf | ||
1121 | * @return NULL on error | ||
1122 | */ | ||
1123 | struct GNUNET_CRYPTO_RsaSignature * | 991 | struct GNUNET_CRYPTO_RsaSignature * |
1124 | GNUNET_CRYPTO_rsa_signature_decode (const void *buf, | 992 | GNUNET_CRYPTO_rsa_signature_decode (const void *buf, |
1125 | size_t buf_size) | 993 | size_t buf_size) |
@@ -1156,12 +1024,6 @@ GNUNET_CRYPTO_rsa_signature_decode (const void *buf, | |||
1156 | } | 1024 | } |
1157 | 1025 | ||
1158 | 1026 | ||
1159 | /** | ||
1160 | * Duplicate the given public key | ||
1161 | * | ||
1162 | * @param key the public key to duplicate | ||
1163 | * @return the duplicate key; NULL upon error | ||
1164 | */ | ||
1165 | struct GNUNET_CRYPTO_RsaPublicKey * | 1027 | struct GNUNET_CRYPTO_RsaPublicKey * |
1166 | GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key) | 1028 | GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key) |
1167 | { | 1029 | { |
@@ -1181,16 +1043,6 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key) | |||
1181 | } | 1043 | } |
1182 | 1044 | ||
1183 | 1045 | ||
1184 | /** | ||
1185 | * Unblind a blind-signed signature. The signature should have been generated | ||
1186 | * with #GNUNET_CRYPTO_rsa_sign() using a hash that was blinded with | ||
1187 | * #GNUNET_CRYPTO_rsa_blind(). | ||
1188 | * | ||
1189 | * @param sig the signature made on the blinded signature purpose | ||
1190 | * @param bks the blinding key secret used to blind the signature purpose | ||
1191 | * @param pkey the public key of the signer | ||
1192 | * @return unblinded signature on success, NULL if RSA key is bad or malicious. | ||
1193 | */ | ||
1194 | struct GNUNET_CRYPTO_RsaSignature * | 1046 | struct GNUNET_CRYPTO_RsaSignature * |
1195 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | 1047 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, |
1196 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 1048 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
@@ -1272,16 +1124,7 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
1272 | } | 1124 | } |
1273 | 1125 | ||
1274 | 1126 | ||
1275 | /** | 1127 | enum GNUNET_GenericReturnValue |
1276 | * Verify whether the given hash corresponds to the given signature and | ||
1277 | * the signature is valid with respect to the given public key. | ||
1278 | * | ||
1279 | * @param hash hash of the message to verify to match the @a sig | ||
1280 | * @param sig signature that is being validated | ||
1281 | * @param pkey public key of the signer | ||
1282 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature is invalid | ||
1283 | */ | ||
1284 | int | ||
1285 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | 1128 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, |
1286 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 1129 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
1287 | const struct GNUNET_CRYPTO_RsaPublicKey *pkey) | 1130 | const struct GNUNET_CRYPTO_RsaPublicKey *pkey) |
@@ -1319,23 +1162,17 @@ GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | |||
1319 | __FILE__, | 1162 | __FILE__, |
1320 | __LINE__, | 1163 | __LINE__, |
1321 | gcry_strerror (rc)); | 1164 | gcry_strerror (rc)); |
1322 | return GNUNET_SYSERR; | ||
1323 | BENCHMARK_END (rsa_verify); | 1165 | BENCHMARK_END (rsa_verify); |
1166 | return GNUNET_SYSERR; | ||
1324 | } | 1167 | } |
1325 | BENCHMARK_END (rsa_verify); | 1168 | BENCHMARK_END (rsa_verify); |
1326 | return GNUNET_OK; | 1169 | return GNUNET_OK; |
1327 | } | 1170 | } |
1328 | 1171 | ||
1329 | 1172 | ||
1330 | /** | ||
1331 | * Duplicate the given private key | ||
1332 | * | ||
1333 | * @param key the private key to duplicate | ||
1334 | * @return the duplicate key; NULL upon error | ||
1335 | */ | ||
1336 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1173 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1337 | GNUNET_CRYPTO_rsa_private_key_dup (const struct | 1174 | GNUNET_CRYPTO_rsa_private_key_dup ( |
1338 | GNUNET_CRYPTO_RsaPrivateKey *key) | 1175 | const struct GNUNET_CRYPTO_RsaPrivateKey *key) |
1339 | { | 1176 | { |
1340 | struct GNUNET_CRYPTO_RsaPrivateKey *dup; | 1177 | struct GNUNET_CRYPTO_RsaPrivateKey *dup; |
1341 | gcry_sexp_t dup_sexp; | 1178 | gcry_sexp_t dup_sexp; |
@@ -1353,12 +1190,6 @@ GNUNET_CRYPTO_rsa_private_key_dup (const struct | |||
1353 | } | 1190 | } |
1354 | 1191 | ||
1355 | 1192 | ||
1356 | /** | ||
1357 | * Duplicate the given private key | ||
1358 | * | ||
1359 | * @param key the private key to duplicate | ||
1360 | * @return the duplicate key; NULL upon error | ||
1361 | */ | ||
1362 | struct GNUNET_CRYPTO_RsaSignature * | 1193 | struct GNUNET_CRYPTO_RsaSignature * |
1363 | GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig) | 1194 | GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig) |
1364 | { | 1195 | { |
diff --git a/src/util/disk.c b/src/util/disk.c index c95e9753c..3bafe311d 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -92,7 +92,7 @@ struct GetFileSizeData | |||
92 | int include_sym_links; | 92 | int include_sym_links; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * GNUNET_YES if mode is file-only (return total == -1 for directories). | 95 | * #GNUNET_YES if mode is file-only (return total == -1 for directories). |
96 | */ | 96 | */ |
97 | int single_file_mode; | 97 | int single_file_mode; |
98 | }; | 98 | }; |
@@ -142,8 +142,8 @@ translate_unix_perms (enum GNUNET_DISK_AccessPermissions perm) | |||
142 | * @param fn current filename we are looking at | 142 | * @param fn current filename we are looking at |
143 | * @return #GNUNET_SYSERR on serious errors, otherwise #GNUNET_OK | 143 | * @return #GNUNET_SYSERR on serious errors, otherwise #GNUNET_OK |
144 | */ | 144 | */ |
145 | static int | 145 | static enum GNUNET_GenericReturnValue |
146 | getSizeRec (void *cls, const char *fn) | 146 | get_size_rec (void *cls, const char *fn) |
147 | { | 147 | { |
148 | struct GetFileSizeData *gfsd = cls; | 148 | struct GetFileSizeData *gfsd = cls; |
149 | 149 | ||
@@ -175,35 +175,23 @@ getSizeRec (void *cls, const char *fn) | |||
175 | if ((S_ISDIR (buf.st_mode)) && (0 == access (fn, X_OK)) && | 175 | if ((S_ISDIR (buf.st_mode)) && (0 == access (fn, X_OK)) && |
176 | ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))) | 176 | ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))) |
177 | { | 177 | { |
178 | if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &getSizeRec, gfsd)) | 178 | if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &get_size_rec, gfsd)) |
179 | return GNUNET_SYSERR; | 179 | return GNUNET_SYSERR; |
180 | } | 180 | } |
181 | return GNUNET_OK; | 181 | return GNUNET_OK; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /** | 185 | enum GNUNET_GenericReturnValue |
186 | * Checks whether a handle is invalid | ||
187 | * | ||
188 | * @param h handle to check | ||
189 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid | ||
190 | */ | ||
191 | int | ||
192 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h) | 186 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h) |
193 | { | 187 | { |
194 | return ((! h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO; | 188 | return ((! h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO; |
195 | } | 189 | } |
196 | 190 | ||
197 | 191 | ||
198 | /** | 192 | enum GNUNET_GenericReturnValue |
199 | * Get the size of an open file. | 193 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
200 | * | 194 | off_t *size) |
201 | * @param fh open file handle | ||
202 | * @param size where to write size of the file | ||
203 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
204 | */ | ||
205 | int | ||
206 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, off_t *size) | ||
207 | { | 195 | { |
208 | struct stat sbuf; | 196 | struct stat sbuf; |
209 | 197 | ||
@@ -214,80 +202,42 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, off_t *size) | |||
214 | } | 202 | } |
215 | 203 | ||
216 | 204 | ||
217 | /** | ||
218 | * Move the read/write pointer in a file | ||
219 | * | ||
220 | * @param h handle of an open file | ||
221 | * @param offset position to move to | ||
222 | * @param whence specification to which position the offset parameter relates to | ||
223 | * @return the new position on success, #GNUNET_SYSERR otherwise | ||
224 | */ | ||
225 | off_t | 205 | off_t |
226 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, | 206 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, |
227 | off_t offset, | 207 | off_t offset, |
228 | enum GNUNET_DISK_Seek whence) | 208 | enum GNUNET_DISK_Seek whence) |
229 | { | 209 | { |
210 | static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END }; | ||
211 | |||
230 | if (h == NULL) | 212 | if (h == NULL) |
231 | { | 213 | { |
232 | errno = EINVAL; | 214 | errno = EINVAL; |
233 | return GNUNET_SYSERR; | 215 | return GNUNET_SYSERR; |
234 | } | 216 | } |
235 | |||
236 | static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END }; | ||
237 | |||
238 | return lseek (h->fd, offset, t[whence]); | 217 | return lseek (h->fd, offset, t[whence]); |
239 | } | 218 | } |
240 | 219 | ||
241 | 220 | ||
242 | /** | 221 | enum GNUNET_GenericReturnValue |
243 | * Get the size of the file (or directory) of the given file (in | ||
244 | * bytes). | ||
245 | * | ||
246 | * @param filename name of the file or directory | ||
247 | * @param size set to the size of the file (or, | ||
248 | * in the case of directories, the sum | ||
249 | * of all sizes of files in the directory) | ||
250 | * @param include_symbolic_links should symbolic links be | ||
251 | * included? | ||
252 | * @param single_file_mode #GNUNET_YES to only get size of one file | ||
253 | * and return #GNUNET_SYSERR for directories. | ||
254 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
255 | */ | ||
256 | int | ||
257 | GNUNET_DISK_file_size (const char *filename, | 222 | GNUNET_DISK_file_size (const char *filename, |
258 | uint64_t *size, | 223 | uint64_t *size, |
259 | int include_symbolic_links, | 224 | int include_symbolic_links, |
260 | int single_file_mode) | 225 | int single_file_mode) |
261 | { | 226 | { |
262 | struct GetFileSizeData gfsd; | 227 | struct GetFileSizeData gfsd; |
263 | int ret; | 228 | enum GNUNET_GenericReturnValue ret; |
264 | 229 | ||
265 | GNUNET_assert (size != NULL); | 230 | GNUNET_assert (size != NULL); |
266 | gfsd.total = 0; | 231 | gfsd.total = 0; |
267 | gfsd.include_sym_links = include_symbolic_links; | 232 | gfsd.include_sym_links = include_symbolic_links; |
268 | gfsd.single_file_mode = single_file_mode; | 233 | gfsd.single_file_mode = single_file_mode; |
269 | ret = getSizeRec (&gfsd, filename); | 234 | ret = get_size_rec (&gfsd, filename); |
270 | *size = gfsd.total; | 235 | *size = gfsd.total; |
271 | return ret; | 236 | return ret; |
272 | } | 237 | } |
273 | 238 | ||
274 | 239 | ||
275 | /** | 240 | enum GNUNET_GenericReturnValue |
276 | * Obtain some unique identifiers for the given file | ||
277 | * that can be used to identify it in the local system. | ||
278 | * This function is used between GNUnet processes to | ||
279 | * quickly check if two files with the same absolute path | ||
280 | * are actually identical. The two processes represent | ||
281 | * the same peer but may communicate over the network | ||
282 | * (and the file may be on an NFS volume). This function | ||
283 | * may not be supported on all operating systems. | ||
284 | * | ||
285 | * @param filename name of the file | ||
286 | * @param dev set to the device ID | ||
287 | * @param ino set to the inode ID | ||
288 | * @return #GNUNET_OK on success | ||
289 | */ | ||
290 | int | ||
291 | GNUNET_DISK_file_get_identifiers (const char *filename, | 241 | GNUNET_DISK_file_get_identifiers (const char *filename, |
292 | uint64_t *dev, | 242 | uint64_t *dev, |
293 | uint64_t *ino) | 243 | uint64_t *ino) |
@@ -367,14 +317,6 @@ mktemp_name (const char *t) | |||
367 | } | 317 | } |
368 | 318 | ||
369 | 319 | ||
370 | /** | ||
371 | * Update POSIX permissions mask of a file on disk. If both argumets | ||
372 | * are #GNUNET_NO, the file is made world-read-write-executable (777). | ||
373 | * | ||
374 | * @param fn name of the file to update | ||
375 | * @param require_uid_match #GNUNET_YES means 700 | ||
376 | * @param require_gid_match #GNUNET_YES means 770 unless @a require_uid_match is set | ||
377 | */ | ||
378 | void | 320 | void |
379 | GNUNET_DISK_fix_permissions (const char *fn, | 321 | GNUNET_DISK_fix_permissions (const char *fn, |
380 | int require_uid_match, | 322 | int require_uid_match, |
@@ -394,17 +336,6 @@ GNUNET_DISK_fix_permissions (const char *fn, | |||
394 | } | 336 | } |
395 | 337 | ||
396 | 338 | ||
397 | /** | ||
398 | * Create an (empty) temporary directory on disk. If the given name is not | ||
399 | * an absolute path, the current 'TMPDIR' will be prepended. In any case, | ||
400 | * 6 random characters will be appended to the name to create a unique | ||
401 | * filename. | ||
402 | * | ||
403 | * @param t component to use for the name; | ||
404 | * does NOT contain "XXXXXX" or "/tmp/". | ||
405 | * @return NULL on error, otherwise name of fresh | ||
406 | * file on disk in directory for temporary files | ||
407 | */ | ||
408 | char * | 339 | char * |
409 | GNUNET_DISK_mkdtemp (const char *t) | 340 | GNUNET_DISK_mkdtemp (const char *t) |
410 | { | 341 | { |
@@ -425,13 +356,6 @@ GNUNET_DISK_mkdtemp (const char *t) | |||
425 | } | 356 | } |
426 | 357 | ||
427 | 358 | ||
428 | /** | ||
429 | * Move a file out of the way (create a backup) by | ||
430 | * renaming it to "orig.NUM~" where NUM is the smallest | ||
431 | * number that is not used yet. | ||
432 | * | ||
433 | * @param fil name of the file to back up | ||
434 | */ | ||
435 | void | 359 | void |
436 | GNUNET_DISK_file_backup (const char *fil) | 360 | GNUNET_DISK_file_backup (const char *fil) |
437 | { | 361 | { |
@@ -453,17 +377,6 @@ GNUNET_DISK_file_backup (const char *fil) | |||
453 | } | 377 | } |
454 | 378 | ||
455 | 379 | ||
456 | /** | ||
457 | * Create an (empty) temporary file on disk. If the given name is not | ||
458 | * an absolute path, the current 'TMPDIR' will be prepended. In any case, | ||
459 | * 6 random characters will be appended to the name to create a unique | ||
460 | * filename. | ||
461 | * | ||
462 | * @param t component to use for the name; | ||
463 | * does NOT contain "XXXXXX" or "/tmp/". | ||
464 | * @return NULL on error, otherwise name of fresh | ||
465 | * file on disk in directory for temporary files | ||
466 | */ | ||
467 | char * | 380 | char * |
468 | GNUNET_DISK_mktemp (const char *t) | 381 | GNUNET_DISK_mktemp (const char *t) |
469 | { | 382 | { |
@@ -487,19 +400,7 @@ GNUNET_DISK_mktemp (const char *t) | |||
487 | } | 400 | } |
488 | 401 | ||
489 | 402 | ||
490 | /** | 403 | enum GNUNET_GenericReturnValue |
491 | * Test if @a fil is a directory and listable. Optionally, also check if the | ||
492 | * directory is readable. Will not print an error message if the directory does | ||
493 | * not exist. Will log errors if #GNUNET_SYSERR is returned (i.e., a file exists | ||
494 | * with the same name). | ||
495 | * | ||
496 | * @param fil filename to test | ||
497 | * @param is_readable #GNUNET_YES to additionally check if @a fil is readable; | ||
498 | * #GNUNET_NO to disable this check | ||
499 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it | ||
500 | * does not exist or stat'ed | ||
501 | */ | ||
502 | int | ||
503 | GNUNET_DISK_directory_test (const char *fil, int is_readable) | 404 | GNUNET_DISK_directory_test (const char *fil, int is_readable) |
504 | { | 405 | { |
505 | struct stat filestat; | 406 | struct stat filestat; |
@@ -532,15 +433,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable) | |||
532 | } | 433 | } |
533 | 434 | ||
534 | 435 | ||
535 | /** | 436 | enum GNUNET_GenericReturnValue |
536 | * Check that fil corresponds to a filename | ||
537 | * (of a file that exists and that is not a directory). | ||
538 | * | ||
539 | * @param fil filename to check | ||
540 | * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something | ||
541 | * else (will print an error message in that case, too). | ||
542 | */ | ||
543 | int | ||
544 | GNUNET_DISK_file_test (const char *fil) | 437 | GNUNET_DISK_file_test (const char *fil) |
545 | { | 438 | { |
546 | struct stat filestat; | 439 | struct stat filestat; |
@@ -552,7 +445,7 @@ GNUNET_DISK_file_test (const char *fil) | |||
552 | return GNUNET_SYSERR; | 445 | return GNUNET_SYSERR; |
553 | 446 | ||
554 | ret = stat (rdir, &filestat); | 447 | ret = stat (rdir, &filestat); |
555 | if (ret != 0) | 448 | if (0 != ret) |
556 | { | 449 | { |
557 | if (errno != ENOENT) | 450 | if (errno != ENOENT) |
558 | { | 451 | { |
@@ -579,13 +472,7 @@ GNUNET_DISK_file_test (const char *fil) | |||
579 | } | 472 | } |
580 | 473 | ||
581 | 474 | ||
582 | /** | 475 | enum GNUNET_GenericReturnValue |
583 | * Implementation of "mkdir -p" | ||
584 | * | ||
585 | * @param dir the directory to create | ||
586 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
587 | */ | ||
588 | int | ||
589 | GNUNET_DISK_directory_create (const char *dir) | 476 | GNUNET_DISK_directory_create (const char *dir) |
590 | { | 477 | { |
591 | char *rdir; | 478 | char *rdir; |
@@ -671,22 +558,13 @@ GNUNET_DISK_directory_create (const char *dir) | |||
671 | } | 558 | } |
672 | 559 | ||
673 | 560 | ||
674 | /** | 561 | enum GNUNET_GenericReturnValue |
675 | * Create the directory structure for storing a file. | ||
676 | * | ||
677 | * @param filename name of a file in the directory | ||
678 | * @returns #GNUNET_OK on success, | ||
679 | * #GNUNET_SYSERR on failure, | ||
680 | * #GNUNET_NO if the directory | ||
681 | * exists but is not writeable for us | ||
682 | */ | ||
683 | int | ||
684 | GNUNET_DISK_directory_create_for_file (const char *filename) | 562 | GNUNET_DISK_directory_create_for_file (const char *filename) |
685 | { | 563 | { |
686 | char *rdir; | 564 | char *rdir; |
687 | size_t len; | 565 | size_t len; |
688 | int ret; | ||
689 | int eno; | 566 | int eno; |
567 | enum GNUNET_GenericReturnValue res; | ||
690 | 568 | ||
691 | rdir = GNUNET_STRINGS_filename_expand (filename); | 569 | rdir = GNUNET_STRINGS_filename_expand (filename); |
692 | if (NULL == rdir) | 570 | if (NULL == rdir) |
@@ -699,7 +577,6 @@ GNUNET_DISK_directory_create_for_file (const char *filename) | |||
699 | GNUNET_free (rdir); | 577 | GNUNET_free (rdir); |
700 | return GNUNET_OK; | 578 | return GNUNET_OK; |
701 | } | 579 | } |
702 | |||
703 | len = strlen (rdir); | 580 | len = strlen (rdir); |
704 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) | 581 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) |
705 | len--; | 582 | len--; |
@@ -710,24 +587,17 @@ GNUNET_DISK_directory_create_for_file (const char *filename) | |||
710 | GNUNET_free (rdir); | 587 | GNUNET_free (rdir); |
711 | rdir = GNUNET_strdup ("/"); | 588 | rdir = GNUNET_strdup ("/"); |
712 | } | 589 | } |
713 | ret = GNUNET_DISK_directory_create (rdir); | 590 | res = GNUNET_DISK_directory_create (rdir); |
714 | if ((GNUNET_OK == ret) && (0 != access (rdir, W_OK))) | 591 | if ( (GNUNET_OK == res) && |
715 | ret = GNUNET_NO; | 592 | (0 != access (rdir, W_OK)) ) |
593 | res = GNUNET_NO; | ||
716 | eno = errno; | 594 | eno = errno; |
717 | GNUNET_free (rdir); | 595 | GNUNET_free (rdir); |
718 | errno = eno; | 596 | errno = eno; |
719 | return ret; | 597 | return res; |
720 | } | 598 | } |
721 | 599 | ||
722 | 600 | ||
723 | /** | ||
724 | * Read the contents of a binary file into a buffer. | ||
725 | * | ||
726 | * @param h handle to an open file | ||
727 | * @param result the buffer to write the result to | ||
728 | * @param len the maximum number of bytes to read | ||
729 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure | ||
730 | */ | ||
731 | ssize_t | 601 | ssize_t |
732 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, | 602 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, |
733 | void *result, | 603 | void *result, |
@@ -738,35 +608,23 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, | |||
738 | errno = EINVAL; | 608 | errno = EINVAL; |
739 | return GNUNET_SYSERR; | 609 | return GNUNET_SYSERR; |
740 | } | 610 | } |
741 | |||
742 | return read (h->fd, result, len); | 611 | return read (h->fd, result, len); |
743 | } | 612 | } |
744 | 613 | ||
745 | 614 | ||
746 | /** | ||
747 | * Read the contents of a binary file into a buffer. | ||
748 | * Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN | ||
749 | * when no data can be read). | ||
750 | * | ||
751 | * @param h handle to an open file | ||
752 | * @param result the buffer to write the result to | ||
753 | * @param len the maximum number of bytes to read | ||
754 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure | ||
755 | */ | ||
756 | ssize_t | 615 | ssize_t |
757 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, | 616 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, |
758 | void *result, | 617 | void *result, |
759 | size_t len) | 618 | size_t len) |
760 | { | 619 | { |
620 | int flags; | ||
621 | ssize_t ret; | ||
622 | |||
761 | if (NULL == h) | 623 | if (NULL == h) |
762 | { | 624 | { |
763 | errno = EINVAL; | 625 | errno = EINVAL; |
764 | return GNUNET_SYSERR; | 626 | return GNUNET_SYSERR; |
765 | } | 627 | } |
766 | |||
767 | int flags; | ||
768 | ssize_t ret; | ||
769 | |||
770 | /* set to non-blocking, read, then set back */ | 628 | /* set to non-blocking, read, then set back */ |
771 | flags = fcntl (h->fd, F_GETFL); | 629 | flags = fcntl (h->fd, F_GETFL); |
772 | if (0 == (flags & O_NONBLOCK)) | 630 | if (0 == (flags & O_NONBLOCK)) |
@@ -782,22 +640,18 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, | |||
782 | } | 640 | } |
783 | 641 | ||
784 | 642 | ||
785 | /** | ||
786 | * Read the contents of a binary file into a buffer. | ||
787 | * | ||
788 | * @param fn file name | ||
789 | * @param result the buffer to write the result to | ||
790 | * @param len the maximum number of bytes to read | ||
791 | * @return number of bytes read, #GNUNET_SYSERR on failure | ||
792 | */ | ||
793 | ssize_t | 643 | ssize_t |
794 | GNUNET_DISK_fn_read (const char *fn, void *result, size_t len) | 644 | GNUNET_DISK_fn_read (const char *fn, |
645 | void *result, | ||
646 | size_t len) | ||
795 | { | 647 | { |
796 | struct GNUNET_DISK_FileHandle *fh; | 648 | struct GNUNET_DISK_FileHandle *fh; |
797 | ssize_t ret; | 649 | ssize_t ret; |
798 | int eno; | 650 | int eno; |
799 | 651 | ||
800 | fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); | 652 | fh = GNUNET_DISK_file_open (fn, |
653 | GNUNET_DISK_OPEN_READ, | ||
654 | GNUNET_DISK_PERM_NONE); | ||
801 | if (NULL == fh) | 655 | if (NULL == fh) |
802 | return GNUNET_SYSERR; | 656 | return GNUNET_SYSERR; |
803 | ret = GNUNET_DISK_file_read (fh, result, len); | 657 | ret = GNUNET_DISK_file_read (fh, result, len); |
@@ -808,14 +662,6 @@ GNUNET_DISK_fn_read (const char *fn, void *result, size_t len) | |||
808 | } | 662 | } |
809 | 663 | ||
810 | 664 | ||
811 | /** | ||
812 | * Write a buffer to a file. | ||
813 | * | ||
814 | * @param h handle to open file | ||
815 | * @param buffer the data to write | ||
816 | * @param n number of bytes to write | ||
817 | * @return number of bytes written on success, #GNUNET_SYSERR on error | ||
818 | */ | ||
819 | ssize_t | 665 | ssize_t |
820 | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | 666 | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, |
821 | const void *buffer, | 667 | const void *buffer, |
@@ -831,29 +677,19 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | |||
831 | } | 677 | } |
832 | 678 | ||
833 | 679 | ||
834 | /** | ||
835 | * Write a buffer to a file, blocking, if necessary. | ||
836 | * | ||
837 | * @param h handle to open file | ||
838 | * @param buffer the data to write | ||
839 | * @param n number of bytes to write | ||
840 | * @return number of bytes written on success, #GNUNET_SYSERR on error | ||
841 | */ | ||
842 | ssize_t | 680 | ssize_t |
843 | GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, | 681 | GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, |
844 | const void *buffer, | 682 | const void *buffer, |
845 | size_t n) | 683 | size_t n) |
846 | { | 684 | { |
685 | int flags; | ||
686 | ssize_t ret; | ||
687 | |||
847 | if (NULL == h) | 688 | if (NULL == h) |
848 | { | 689 | { |
849 | errno = EINVAL; | 690 | errno = EINVAL; |
850 | return GNUNET_SYSERR; | 691 | return GNUNET_SYSERR; |
851 | } | 692 | } |
852 | |||
853 | |||
854 | int flags; | ||
855 | ssize_t ret; | ||
856 | |||
857 | /* set to blocking, write, then set back */ | 693 | /* set to blocking, write, then set back */ |
858 | flags = fcntl (h->fd, F_GETFL); | 694 | flags = fcntl (h->fd, F_GETFL); |
859 | if (0 != (flags & O_NONBLOCK)) | 695 | if (0 != (flags & O_NONBLOCK)) |
@@ -865,48 +701,95 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, | |||
865 | } | 701 | } |
866 | 702 | ||
867 | 703 | ||
868 | /** | 704 | enum GNUNET_GenericReturnValue |
869 | * Write a buffer to a file. If the file is longer than the | ||
870 | * number of bytes that will be written, it will be truncated. | ||
871 | * | ||
872 | * @param fn file name | ||
873 | * @param buffer the data to write | ||
874 | * @param n number of bytes to write | ||
875 | * @param mode file permissions | ||
876 | * @return number of bytes written on success, #GNUNET_SYSERR on error | ||
877 | */ | ||
878 | ssize_t | ||
879 | GNUNET_DISK_fn_write (const char *fn, | 705 | GNUNET_DISK_fn_write (const char *fn, |
880 | const void *buffer, | 706 | const void *buf, |
881 | size_t n, | 707 | size_t buf_size, |
882 | enum GNUNET_DISK_AccessPermissions mode) | 708 | enum GNUNET_DISK_AccessPermissions mode) |
883 | { | 709 | { |
884 | struct GNUNET_DISK_FileHandle *fh; | 710 | char *tmpl; |
885 | ssize_t ret; | 711 | int fd; |
886 | 712 | ||
887 | fh = | 713 | if (GNUNET_OK != |
888 | GNUNET_DISK_file_open (fn, | 714 | GNUNET_DISK_directory_create_for_file (fn)) |
889 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE | 715 | { |
890 | | GNUNET_DISK_OPEN_CREATE, | 716 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
891 | mode); | 717 | "mkstemp", |
892 | if (! fh) | 718 | fn); |
893 | return GNUNET_SYSERR; | 719 | return GNUNET_SYSERR; |
894 | ret = GNUNET_DISK_file_write (fh, buffer, n); | 720 | } |
895 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 721 | { |
896 | return ret; | 722 | char *dname; |
723 | |||
724 | dname = GNUNET_strdup (fn); | ||
725 | GNUNET_asprintf (&tmpl, | ||
726 | "%s/XXXXXX", | ||
727 | dirname (dname)); | ||
728 | GNUNET_free (dname); | ||
729 | } | ||
730 | fd = mkstemp (tmpl); | ||
731 | if (-1 == fd) | ||
732 | { | ||
733 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
734 | "mkstemp", | ||
735 | tmpl); | ||
736 | GNUNET_free (tmpl); | ||
737 | return GNUNET_SYSERR; | ||
738 | } | ||
739 | |||
740 | if (0 != fchmod (fd, | ||
741 | translate_unix_perms (mode))) | ||
742 | { | ||
743 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
744 | "chmod", | ||
745 | tmpl); | ||
746 | GNUNET_assert (0 == close (fd)); | ||
747 | if (0 != unlink (tmpl)) | ||
748 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
749 | "unlink", | ||
750 | tmpl); | ||
751 | GNUNET_free (tmpl); | ||
752 | return GNUNET_SYSERR; | ||
753 | } | ||
754 | if (buf_size != | ||
755 | write (fd, | ||
756 | buf, | ||
757 | buf_size)) | ||
758 | { | ||
759 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
760 | "write", | ||
761 | tmpl); | ||
762 | GNUNET_assert (0 == close (fd)); | ||
763 | if (0 != unlink (tmpl)) | ||
764 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
765 | "unlink", | ||
766 | tmpl); | ||
767 | GNUNET_free (tmpl); | ||
768 | return GNUNET_SYSERR; | ||
769 | } | ||
770 | GNUNET_assert (0 == close (fd)); | ||
771 | |||
772 | if (0 != link (tmpl, | ||
773 | fn)) | ||
774 | { | ||
775 | if (0 != unlink (tmpl)) | ||
776 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
777 | "unlink", | ||
778 | tmpl); | ||
779 | GNUNET_free (tmpl); | ||
780 | return GNUNET_NO; | ||
781 | } | ||
782 | if (0 != unlink (tmpl)) | ||
783 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
784 | "unlink", | ||
785 | tmpl); | ||
786 | GNUNET_free (tmpl); | ||
787 | return GNUNET_OK; | ||
788 | |||
789 | |||
897 | } | 790 | } |
898 | 791 | ||
899 | 792 | ||
900 | /** | ||
901 | * Scan a directory for files. | ||
902 | * | ||
903 | * @param dir_name the name of the directory | ||
904 | * @param callback the method to call for each file, | ||
905 | * can be NULL, in that case, we only count | ||
906 | * @param callback_cls closure for @a callback | ||
907 | * @return the number of files found, #GNUNET_SYSERR on error or | ||
908 | * ieration aborted by callback returning #GNUNET_SYSERR | ||
909 | */ | ||
910 | int | 793 | int |
911 | GNUNET_DISK_directory_scan (const char *dir_name, | 794 | GNUNET_DISK_directory_scan (const char *dir_name, |
912 | GNUNET_FileNameCallback callback, | 795 | GNUNET_FileNameCallback callback, |
@@ -916,7 +799,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
916 | struct dirent *finfo; | 799 | struct dirent *finfo; |
917 | struct stat istat; | 800 | struct stat istat; |
918 | int count = 0; | 801 | int count = 0; |
919 | int ret; | 802 | enum GNUNET_GenericReturnValue ret; |
920 | char *name; | 803 | char *name; |
921 | char *dname; | 804 | char *dname; |
922 | unsigned int name_len; | 805 | unsigned int name_len; |
@@ -1008,8 +891,9 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
1008 | * @param fn directory to remove | 891 | * @param fn directory to remove |
1009 | * @return #GNUNET_OK | 892 | * @return #GNUNET_OK |
1010 | */ | 893 | */ |
1011 | static int | 894 | static enum GNUNET_GenericReturnValue |
1012 | remove_helper (void *unused, const char *fn) | 895 | remove_helper (void *unused, |
896 | const char *fn) | ||
1013 | { | 897 | { |
1014 | (void) unused; | 898 | (void) unused; |
1015 | (void) GNUNET_DISK_directory_remove (fn); | 899 | (void) GNUNET_DISK_directory_remove (fn); |
@@ -1017,14 +901,7 @@ remove_helper (void *unused, const char *fn) | |||
1017 | } | 901 | } |
1018 | 902 | ||
1019 | 903 | ||
1020 | /** | 904 | enum GNUNET_GenericReturnValue |
1021 | * Remove all files in a directory (rm -r). Call with | ||
1022 | * caution. | ||
1023 | * | ||
1024 | * @param filename the file to remove | ||
1025 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1026 | */ | ||
1027 | int | ||
1028 | GNUNET_DISK_directory_remove (const char *filename) | 905 | GNUNET_DISK_directory_remove (const char *filename) |
1029 | { | 906 | { |
1030 | struct stat istat; | 907 | struct stat istat; |
@@ -1036,14 +913,17 @@ GNUNET_DISK_directory_remove (const char *filename) | |||
1036 | } | 913 | } |
1037 | if (0 != lstat (filename, &istat)) | 914 | if (0 != lstat (filename, &istat)) |
1038 | return GNUNET_NO; /* file may not exist... */ | 915 | return GNUNET_NO; /* file may not exist... */ |
1039 | (void) chmod (filename, S_IWUSR | S_IRUSR | S_IXUSR); | 916 | (void) chmod (filename, |
917 | S_IWUSR | S_IRUSR | S_IXUSR); | ||
1040 | if (0 == unlink (filename)) | 918 | if (0 == unlink (filename)) |
1041 | return GNUNET_OK; | 919 | return GNUNET_OK; |
1042 | if ((errno != EISDIR) && | 920 | if ( (errno != EISDIR) && |
1043 | /* EISDIR is not sufficient in all cases, e.g. | 921 | /* EISDIR is not sufficient in all cases, e.g. |
1044 | * sticky /tmp directory may result in EPERM on BSD. | 922 | * sticky /tmp directory may result in EPERM on BSD. |
1045 | * So we also explicitly check "isDirectory" */ | 923 | * So we also explicitly check "isDirectory" */ |
1046 | (GNUNET_YES != GNUNET_DISK_directory_test (filename, GNUNET_YES))) | 924 | (GNUNET_YES != |
925 | GNUNET_DISK_directory_test (filename, | ||
926 | GNUNET_YES)) ) | ||
1047 | { | 927 | { |
1048 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename); | 928 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename); |
1049 | return GNUNET_SYSERR; | 929 | return GNUNET_SYSERR; |
@@ -1060,15 +940,9 @@ GNUNET_DISK_directory_remove (const char *filename) | |||
1060 | } | 940 | } |
1061 | 941 | ||
1062 | 942 | ||
1063 | /** | 943 | enum GNUNET_GenericReturnValue |
1064 | * Copy a file. | 944 | GNUNET_DISK_file_copy (const char *src, |
1065 | * | 945 | const char *dst) |
1066 | * @param src file to copy | ||
1067 | * @param dst destination file name | ||
1068 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
1069 | */ | ||
1070 | int | ||
1071 | GNUNET_DISK_file_copy (const char *src, const char *dst) | ||
1072 | { | 946 | { |
1073 | char *buf; | 947 | char *buf; |
1074 | uint64_t pos; | 948 | uint64_t pos; |
@@ -1131,10 +1005,6 @@ FAIL: | |||
1131 | } | 1005 | } |
1132 | 1006 | ||
1133 | 1007 | ||
1134 | /** | ||
1135 | * @brief Removes special characters as ':' from a filename. | ||
1136 | * @param fn the filename to canonicalize | ||
1137 | */ | ||
1138 | void | 1008 | void |
1139 | GNUNET_DISK_filename_canonicalize (char *fn) | 1009 | GNUNET_DISK_filename_canonicalize (char *fn) |
1140 | { | 1010 | { |
@@ -1157,15 +1027,9 @@ GNUNET_DISK_filename_canonicalize (char *fn) | |||
1157 | } | 1027 | } |
1158 | 1028 | ||
1159 | 1029 | ||
1160 | /** | 1030 | enum GNUNET_GenericReturnValue |
1161 | * @brief Change owner of a file | 1031 | GNUNET_DISK_file_change_owner (const char *filename, |
1162 | * | 1032 | const char *user) |
1163 | * @param filename name of file to change the owner of | ||
1164 | * @param user name of the new owner | ||
1165 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
1166 | */ | ||
1167 | int | ||
1168 | GNUNET_DISK_file_change_owner (const char *filename, const char *user) | ||
1169 | { | 1033 | { |
1170 | struct passwd *pws; | 1034 | struct passwd *pws; |
1171 | 1035 | ||
@@ -1187,18 +1051,6 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1187 | } | 1051 | } |
1188 | 1052 | ||
1189 | 1053 | ||
1190 | /** | ||
1191 | * Open a file. Note that the access permissions will only be | ||
1192 | * used if a new file is created and if the underlying operating | ||
1193 | * system supports the given permissions. | ||
1194 | * | ||
1195 | * @param fn file name to be opened | ||
1196 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags | ||
1197 | * @param perm permissions for the newly created file, use | ||
1198 | * #GNUNET_DISK_PERM_NONE if a file could not be created by this | ||
1199 | * call (because of flags) | ||
1200 | * @return IO handle on success, NULL on error | ||
1201 | */ | ||
1202 | struct GNUNET_DISK_FileHandle * | 1054 | struct GNUNET_DISK_FileHandle * |
1203 | GNUNET_DISK_file_open (const char *fn, | 1055 | GNUNET_DISK_file_open (const char *fn, |
1204 | enum GNUNET_DISK_OpenFlags flags, | 1056 | enum GNUNET_DISK_OpenFlags flags, |
@@ -1270,42 +1122,28 @@ GNUNET_DISK_file_open (const char *fn, | |||
1270 | } | 1122 | } |
1271 | 1123 | ||
1272 | 1124 | ||
1273 | /** | 1125 | enum GNUNET_GenericReturnValue |
1274 | * Close an open file. | ||
1275 | * | ||
1276 | * @param h file handle | ||
1277 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1278 | */ | ||
1279 | int | ||
1280 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h) | 1126 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h) |
1281 | { | 1127 | { |
1282 | int ret; | 1128 | enum GNUNET_GenericReturnValue ret; |
1283 | 1129 | ||
1284 | if (h == NULL) | 1130 | if (NULL == h) |
1285 | { | 1131 | { |
1286 | errno = EINVAL; | 1132 | errno = EINVAL; |
1287 | return GNUNET_SYSERR; | 1133 | return GNUNET_SYSERR; |
1288 | } | 1134 | } |
1289 | 1135 | ||
1290 | ret = GNUNET_OK; | 1136 | ret = GNUNET_OK; |
1291 | 1137 | if (0 != close (h->fd)) | |
1292 | if (close (h->fd) != 0) | ||
1293 | { | 1138 | { |
1294 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "close"); | 1139 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "close"); |
1295 | ret = GNUNET_SYSERR; | 1140 | ret = GNUNET_SYSERR; |
1296 | } | 1141 | } |
1297 | |||
1298 | GNUNET_free (h); | 1142 | GNUNET_free (h); |
1299 | return ret; | 1143 | return ret; |
1300 | } | 1144 | } |
1301 | 1145 | ||
1302 | 1146 | ||
1303 | /** | ||
1304 | * Get a handle from a native integer FD. | ||
1305 | * | ||
1306 | * @param fno native integer file descriptor | ||
1307 | * @return file handle corresponding to the descriptor, NULL on error | ||
1308 | */ | ||
1309 | struct GNUNET_DISK_FileHandle * | 1147 | struct GNUNET_DISK_FileHandle * |
1310 | GNUNET_DISK_get_handle_from_int_fd (int fno) | 1148 | GNUNET_DISK_get_handle_from_int_fd (int fno) |
1311 | { | 1149 | { |
@@ -1322,12 +1160,6 @@ GNUNET_DISK_get_handle_from_int_fd (int fno) | |||
1322 | } | 1160 | } |
1323 | 1161 | ||
1324 | 1162 | ||
1325 | /** | ||
1326 | * Get a handle from a native streaming FD. | ||
1327 | * | ||
1328 | * @param fd native streaming file descriptor | ||
1329 | * @return file handle corresponding to the descriptor | ||
1330 | */ | ||
1331 | struct GNUNET_DISK_FileHandle * | 1163 | struct GNUNET_DISK_FileHandle * |
1332 | GNUNET_DISK_get_handle_from_native (FILE *fd) | 1164 | GNUNET_DISK_get_handle_from_native (FILE *fd) |
1333 | { | 1165 | { |
@@ -1336,7 +1168,6 @@ GNUNET_DISK_get_handle_from_native (FILE *fd) | |||
1336 | fno = fileno (fd); | 1168 | fno = fileno (fd); |
1337 | if (-1 == fno) | 1169 | if (-1 == fno) |
1338 | return NULL; | 1170 | return NULL; |
1339 | |||
1340 | return GNUNET_DISK_get_handle_from_int_fd (fno); | 1171 | return GNUNET_DISK_get_handle_from_int_fd (fno); |
1341 | } | 1172 | } |
1342 | 1173 | ||
@@ -1362,15 +1193,7 @@ struct GNUNET_DISK_MapHandle | |||
1362 | #define MAP_FAILED ((void *) -1) | 1193 | #define MAP_FAILED ((void *) -1) |
1363 | #endif | 1194 | #endif |
1364 | 1195 | ||
1365 | /** | 1196 | |
1366 | * Map a file into memory | ||
1367 | * | ||
1368 | * @param h open file handle | ||
1369 | * @param m handle to the new mapping | ||
1370 | * @param access access specification, GNUNET_DISK_MAP_TYPE_xxx | ||
1371 | * @param len size of the mapping | ||
1372 | * @return pointer to the mapped memory region, NULL on failure | ||
1373 | */ | ||
1374 | void * | 1197 | void * |
1375 | GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | 1198 | GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, |
1376 | struct GNUNET_DISK_MapHandle **m, | 1199 | struct GNUNET_DISK_MapHandle **m, |
@@ -1402,16 +1225,10 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | |||
1402 | } | 1225 | } |
1403 | 1226 | ||
1404 | 1227 | ||
1405 | /** | 1228 | enum GNUNET_GenericReturnValue |
1406 | * Unmap a file | ||
1407 | * | ||
1408 | * @param h mapping handle | ||
1409 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1410 | */ | ||
1411 | int | ||
1412 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) | 1229 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) |
1413 | { | 1230 | { |
1414 | int ret; | 1231 | enum GNUNET_GenericReturnValue ret; |
1415 | 1232 | ||
1416 | if (NULL == h) | 1233 | if (NULL == h) |
1417 | { | 1234 | { |
@@ -1424,12 +1241,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) | |||
1424 | } | 1241 | } |
1425 | 1242 | ||
1426 | 1243 | ||
1427 | /** | 1244 | enum GNUNET_GenericReturnValue |
1428 | * Write file changes to disk | ||
1429 | * @param h handle to an open file | ||
1430 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1431 | */ | ||
1432 | int | ||
1433 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) | 1245 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) |
1434 | { | 1246 | { |
1435 | if (h == NULL) | 1247 | if (h == NULL) |
@@ -1446,12 +1258,6 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) | |||
1446 | } | 1258 | } |
1447 | 1259 | ||
1448 | 1260 | ||
1449 | /** | ||
1450 | * Creates an interprocess channel | ||
1451 | * | ||
1452 | * @param pf how to configure the pipe | ||
1453 | * @return handle to the new pipe, NULL on error | ||
1454 | */ | ||
1455 | struct GNUNET_DISK_PipeHandle * | 1261 | struct GNUNET_DISK_PipeHandle * |
1456 | GNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf) | 1262 | GNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf) |
1457 | { | 1263 | { |
@@ -1469,15 +1275,6 @@ GNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf) | |||
1469 | } | 1275 | } |
1470 | 1276 | ||
1471 | 1277 | ||
1472 | /** | ||
1473 | * Creates a pipe object from a couple of file descriptors. | ||
1474 | * Useful for wrapping existing pipe FDs. | ||
1475 | * | ||
1476 | * @param pf how to configure the pipe | ||
1477 | * @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes | ||
1478 | * | ||
1479 | * @return handle to the new pipe, NULL on error | ||
1480 | */ | ||
1481 | struct GNUNET_DISK_PipeHandle * | 1278 | struct GNUNET_DISK_PipeHandle * |
1482 | GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, | 1279 | GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, |
1483 | int fd[2]) | 1280 | int fd[2]) |
@@ -1551,18 +1348,11 @@ GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, | |||
1551 | } | 1348 | } |
1552 | 1349 | ||
1553 | 1350 | ||
1554 | /** | 1351 | enum GNUNET_GenericReturnValue |
1555 | * Closes an interprocess channel | ||
1556 | * | ||
1557 | * @param p pipe to close | ||
1558 | * @param end which end of the pipe to close | ||
1559 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1560 | */ | ||
1561 | int | ||
1562 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, | 1352 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, |
1563 | enum GNUNET_DISK_PipeEnd end) | 1353 | enum GNUNET_DISK_PipeEnd end) |
1564 | { | 1354 | { |
1565 | int ret = GNUNET_OK; | 1355 | enum GNUNET_GenericReturnValue ret = GNUNET_OK; |
1566 | 1356 | ||
1567 | if (end == GNUNET_DISK_PIPE_END_READ) | 1357 | if (end == GNUNET_DISK_PIPE_END_READ) |
1568 | { | 1358 | { |
@@ -1580,23 +1370,10 @@ GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, | |||
1580 | p->fd[1] = NULL; | 1370 | p->fd[1] = NULL; |
1581 | } | 1371 | } |
1582 | } | 1372 | } |
1583 | |||
1584 | return ret; | 1373 | return ret; |
1585 | } | 1374 | } |
1586 | 1375 | ||
1587 | 1376 | ||
1588 | /** | ||
1589 | * Detaches one of the ends from the pipe. | ||
1590 | * Detached end is a fully-functional FileHandle, it will | ||
1591 | * not be affected by anything you do with the pipe afterwards. | ||
1592 | * Each end of a pipe can only be detched from it once (i.e. | ||
1593 | * it is not duplicated). | ||
1594 | * | ||
1595 | * @param p pipe to detach an end from | ||
1596 | * @param end which end of the pipe to detach | ||
1597 | * @return Detached end on success, NULL on failure | ||
1598 | * (or if that end is not present or is closed). | ||
1599 | */ | ||
1600 | struct GNUNET_DISK_FileHandle * | 1377 | struct GNUNET_DISK_FileHandle * |
1601 | GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, | 1378 | GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, |
1602 | enum GNUNET_DISK_PipeEnd end) | 1379 | enum GNUNET_DISK_PipeEnd end) |
@@ -1624,13 +1401,7 @@ GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, | |||
1624 | } | 1401 | } |
1625 | 1402 | ||
1626 | 1403 | ||
1627 | /** | 1404 | enum GNUNET_GenericReturnValue |
1628 | * Closes an interprocess channel | ||
1629 | * | ||
1630 | * @param p pipe to close | ||
1631 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1632 | */ | ||
1633 | int | ||
1634 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p) | 1405 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p) |
1635 | { | 1406 | { |
1636 | int ret = GNUNET_OK; | 1407 | int ret = GNUNET_OK; |
@@ -1661,13 +1432,6 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p) | |||
1661 | } | 1432 | } |
1662 | 1433 | ||
1663 | 1434 | ||
1664 | /** | ||
1665 | * Get the handle to a particular pipe end | ||
1666 | * | ||
1667 | * @param p pipe | ||
1668 | * @param n end to access | ||
1669 | * @return handle for the respective end | ||
1670 | */ | ||
1671 | const struct GNUNET_DISK_FileHandle * | 1435 | const struct GNUNET_DISK_FileHandle * |
1672 | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, | 1436 | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, |
1673 | enum GNUNET_DISK_PipeEnd n) | 1437 | enum GNUNET_DISK_PipeEnd n) |
@@ -1685,26 +1449,16 @@ GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, | |||
1685 | } | 1449 | } |
1686 | 1450 | ||
1687 | 1451 | ||
1688 | /** | 1452 | enum GNUNET_GenericReturnValue |
1689 | * Retrieve OS file handle | ||
1690 | * @internal | ||
1691 | * @param fh GNUnet file descriptor | ||
1692 | * @param dst destination buffer | ||
1693 | * @param dst_len length of dst | ||
1694 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
1695 | */ | ||
1696 | int | ||
1697 | GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh, | 1453 | GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh, |
1698 | void *dst, | 1454 | void *dst, |
1699 | size_t dst_len) | 1455 | size_t dst_len) |
1700 | { | 1456 | { |
1701 | if (NULL == fh) | 1457 | if (NULL == fh) |
1702 | return GNUNET_SYSERR; | 1458 | return GNUNET_SYSERR; |
1703 | |||
1704 | if (dst_len < sizeof(int)) | 1459 | if (dst_len < sizeof(int)) |
1705 | return GNUNET_SYSERR; | 1460 | return GNUNET_SYSERR; |
1706 | *((int *) dst) = fh->fd; | 1461 | *((int *) dst) = fh->fd; |
1707 | |||
1708 | return GNUNET_OK; | 1462 | return GNUNET_OK; |
1709 | } | 1463 | } |
1710 | 1464 | ||
@@ -1716,8 +1470,9 @@ GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh, | |||
1716 | * @param cfg our configuration | 1470 | * @param cfg our configuration |
1717 | * @return #GNUNET_OK on success | 1471 | * @return #GNUNET_OK on success |
1718 | */ | 1472 | */ |
1719 | static int | 1473 | static enum GNUNET_GenericReturnValue |
1720 | purge_cfg_dir (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 1474 | purge_cfg_dir (void *cls, |
1475 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
1721 | { | 1476 | { |
1722 | const char *option = cls; | 1477 | const char *option = cls; |
1723 | char *tmpname; | 1478 | char *tmpname; |
@@ -1739,15 +1494,9 @@ purge_cfg_dir (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1739 | } | 1494 | } |
1740 | 1495 | ||
1741 | 1496 | ||
1742 | /** | ||
1743 | * Remove the directory given under @a option in | ||
1744 | * section [PATHS] in configuration under @a cfg_filename | ||
1745 | * | ||
1746 | * @param cfg_filename configuration file to parse | ||
1747 | * @param option option with the dir name to purge | ||
1748 | */ | ||
1749 | void | 1497 | void |
1750 | GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, const char *option) | 1498 | GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, |
1499 | const char *option) | ||
1751 | { | 1500 | { |
1752 | GNUNET_break (GNUNET_OK == | 1501 | GNUNET_break (GNUNET_OK == |
1753 | GNUNET_CONFIGURATION_parse_and_run (cfg_filename, | 1502 | GNUNET_CONFIGURATION_parse_and_run (cfg_filename, |
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c index 136c6debb..5c3dfc12e 100644 --- a/src/util/gnunet-scrypt.c +++ b/src/util/gnunet-scrypt.c | |||
@@ -65,12 +65,15 @@ static void | |||
65 | shutdown_task (void *cls) | 65 | shutdown_task (void *cls) |
66 | { | 66 | { |
67 | (void) cls; | 67 | (void) cls; |
68 | if (sizeof(proof) != GNUNET_DISK_fn_write (pwfn, | 68 | if (GNUNET_OK != |
69 | &proof, | 69 | GNUNET_DISK_fn_write (pwfn, |
70 | sizeof(proof), | 70 | &proof, |
71 | GNUNET_DISK_PERM_USER_READ | 71 | sizeof(proof), |
72 | | GNUNET_DISK_PERM_USER_WRITE)) | 72 | GNUNET_DISK_PERM_USER_READ |
73 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", pwfn); | 73 | | GNUNET_DISK_PERM_USER_WRITE)) |
74 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
75 | "write", | ||
76 | pwfn); | ||
74 | } | 77 | } |
75 | 78 | ||
76 | 79 | ||
diff --git a/src/util/network.c b/src/util/network.c index b18030fcd..c4adefb8f 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -757,21 +757,17 @@ GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc, | |||
757 | struct sockaddr *src_addr, | 757 | struct sockaddr *src_addr, |
758 | socklen_t *addrlen) | 758 | socklen_t *addrlen) |
759 | { | 759 | { |
760 | int ret; | 760 | int flags = 0; |
761 | int flags; | ||
762 | |||
763 | flags = 0; | ||
764 | 761 | ||
765 | #ifdef MSG_DONTWAIT | 762 | #ifdef MSG_DONTWAIT |
766 | flags |= MSG_DONTWAIT; | 763 | flags |= MSG_DONTWAIT; |
767 | #endif | 764 | #endif |
768 | ret = recvfrom (desc->fd, | 765 | return recvfrom (desc->fd, |
769 | buffer, | 766 | buffer, |
770 | length, | 767 | length, |
771 | flags, | 768 | flags, |
772 | src_addr, | 769 | src_addr, |
773 | addrlen); | 770 | addrlen); |
774 | return ret; | ||
775 | } | 771 | } |
776 | 772 | ||
777 | 773 | ||
@@ -853,10 +849,7 @@ GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, | |||
853 | const struct sockaddr *dest_addr, | 849 | const struct sockaddr *dest_addr, |
854 | socklen_t dest_len) | 850 | socklen_t dest_len) |
855 | { | 851 | { |
856 | int ret; | 852 | int flags = 0; |
857 | int flags; | ||
858 | |||
859 | flags = 0; | ||
860 | 853 | ||
861 | #ifdef MSG_DONTWAIT | 854 | #ifdef MSG_DONTWAIT |
862 | flags |= MSG_DONTWAIT; | 855 | flags |= MSG_DONTWAIT; |
@@ -864,8 +857,12 @@ GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, | |||
864 | #ifdef MSG_NOSIGNAL | 857 | #ifdef MSG_NOSIGNAL |
865 | flags |= MSG_NOSIGNAL; | 858 | flags |= MSG_NOSIGNAL; |
866 | #endif | 859 | #endif |
867 | ret = sendto (desc->fd, message, length, flags, dest_addr, dest_len); | 860 | return sendto (desc->fd, |
868 | return ret; | 861 | message, |
862 | length, | ||
863 | flags, | ||
864 | dest_addr, | ||
865 | dest_len); | ||
869 | } | 866 | } |
870 | 867 | ||
871 | 868 | ||
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 6e783a95a..d1e5e0da5 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -142,7 +142,7 @@ GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd) | |||
142 | * @return NULL on error | 142 | * @return NULL on error |
143 | */ | 143 | */ |
144 | static char * | 144 | static char * |
145 | get_path_from_proc_maps () | 145 | get_path_from_proc_maps (void) |
146 | { | 146 | { |
147 | char fn[64]; | 147 | char fn[64]; |
148 | char line[1024]; | 148 | char line[1024]; |
@@ -152,15 +152,19 @@ get_path_from_proc_maps () | |||
152 | 152 | ||
153 | if (NULL == current_pd->libname) | 153 | if (NULL == current_pd->libname) |
154 | return NULL; | 154 | return NULL; |
155 | GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/maps", getpid ()); | 155 | GNUNET_snprintf (fn, |
156 | sizeof(fn), | ||
157 | "/proc/%u/maps", | ||
158 | getpid ()); | ||
156 | if (NULL == (f = fopen (fn, "r"))) | 159 | if (NULL == (f = fopen (fn, "r"))) |
157 | return NULL; | 160 | return NULL; |
158 | while (NULL != fgets (line, sizeof(line), f)) | 161 | while (NULL != fgets (line, sizeof(line), f)) |
159 | { | 162 | { |
160 | if ((1 == sscanf (line, | 163 | if ((1 == sscanf (line, |
161 | "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s", | 164 | "%*p-%*p %*c%*c%*c%*c %*x %*x:%*x %*u%*[ ]%1023s", |
162 | dir)) && | 165 | dir)) && |
163 | (NULL != (lgu = strstr (dir, current_pd->libname)))) | 166 | (NULL != (lgu = strstr (dir, |
167 | current_pd->libname)))) | ||
164 | { | 168 | { |
165 | lgu[0] = '\0'; | 169 | lgu[0] = '\0'; |
166 | fclose (f); | 170 | fclose (f); |
@@ -178,7 +182,7 @@ get_path_from_proc_maps () | |||
178 | * @return NULL on error | 182 | * @return NULL on error |
179 | */ | 183 | */ |
180 | static char * | 184 | static char * |
181 | get_path_from_proc_exe () | 185 | get_path_from_proc_exe (void) |
182 | { | 186 | { |
183 | char fn[64]; | 187 | char fn[64]; |
184 | char lnk[1024]; | 188 | char lnk[1024]; |
@@ -232,7 +236,7 @@ typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize); | |||
232 | * @return NULL on error | 236 | * @return NULL on error |
233 | */ | 237 | */ |
234 | static char * | 238 | static char * |
235 | get_path_from_NSGetExecutablePath () | 239 | get_path_from_NSGetExecutablePath (void) |
236 | { | 240 | { |
237 | static char zero = '\0'; | 241 | static char zero = '\0'; |
238 | char *path; | 242 | char *path; |
@@ -270,7 +274,7 @@ get_path_from_NSGetExecutablePath () | |||
270 | * @return NULL on error | 274 | * @return NULL on error |
271 | */ | 275 | */ |
272 | static char * | 276 | static char * |
273 | get_path_from_dyld_image () | 277 | get_path_from_dyld_image (void) |
274 | { | 278 | { |
275 | const char *path; | 279 | const char *path; |
276 | char *p; | 280 | char *p; |
@@ -359,7 +363,7 @@ get_path_from_PATH (const char *binary) | |||
359 | * @return NULL on error (environment variable not set) | 363 | * @return NULL on error (environment variable not set) |
360 | */ | 364 | */ |
361 | static char * | 365 | static char * |
362 | get_path_from_GNUNET_PREFIX () | 366 | get_path_from_GNUNET_PREFIX (void) |
363 | { | 367 | { |
364 | const char *p; | 368 | const char *p; |
365 | 369 | ||
@@ -380,7 +384,7 @@ get_path_from_GNUNET_PREFIX () | |||
380 | * @return a pointer to the executable path, or NULL on error | 384 | * @return a pointer to the executable path, or NULL on error |
381 | */ | 385 | */ |
382 | static char * | 386 | static char * |
383 | os_get_gnunet_path () | 387 | os_get_gnunet_path (void) |
384 | { | 388 | { |
385 | char *ret; | 389 | char *ret; |
386 | 390 | ||
@@ -461,7 +465,6 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) | |||
461 | * guess for the current app */ | 465 | * guess for the current app */ |
462 | if (NULL == execpath) | 466 | if (NULL == execpath) |
463 | execpath = os_get_gnunet_path (); | 467 | execpath = os_get_gnunet_path (); |
464 | |||
465 | if (NULL == execpath) | 468 | if (NULL == execpath) |
466 | return NULL; | 469 | return NULL; |
467 | 470 | ||
diff --git a/src/util/plugin.c b/src/util/plugin.c index bb310ada8..d169bc911 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -72,7 +72,7 @@ static struct PluginList *plugins; | |||
72 | * Setup libtool paths. | 72 | * Setup libtool paths. |
73 | */ | 73 | */ |
74 | static void | 74 | static void |
75 | plugin_init () | 75 | plugin_init (void) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | const char *opath; | 78 | const char *opath; |
@@ -95,7 +95,10 @@ plugin_init () | |||
95 | { | 95 | { |
96 | if (NULL != opath) | 96 | if (NULL != opath) |
97 | { | 97 | { |
98 | GNUNET_asprintf (&cpath, "%s:%s", opath, path); | 98 | GNUNET_asprintf (&cpath, |
99 | "%s:%s", | ||
100 | opath, | ||
101 | path); | ||
99 | lt_dlsetsearchpath (cpath); | 102 | lt_dlsetsearchpath (cpath); |
100 | GNUNET_free (path); | 103 | GNUNET_free (path); |
101 | GNUNET_free (cpath); | 104 | GNUNET_free (cpath); |
@@ -113,7 +116,7 @@ plugin_init () | |||
113 | * Shutdown libtool. | 116 | * Shutdown libtool. |
114 | */ | 117 | */ |
115 | static void | 118 | static void |
116 | plugin_fini () | 119 | plugin_fini (void) |
117 | { | 120 | { |
118 | lt_dlsetsearchpath (old_dlsearchpath); | 121 | lt_dlsetsearchpath (old_dlsearchpath); |
119 | if (NULL != old_dlsearchpath) | 122 | if (NULL != old_dlsearchpath) |
@@ -133,15 +136,21 @@ plugin_fini () | |||
133 | * @return NULL if the symbol was not found | 136 | * @return NULL if the symbol was not found |
134 | */ | 137 | */ |
135 | static GNUNET_PLUGIN_Callback | 138 | static GNUNET_PLUGIN_Callback |
136 | resolve_function (struct PluginList *plug, const char *name) | 139 | resolve_function (struct PluginList *plug, |
140 | const char *name) | ||
137 | { | 141 | { |
138 | char *initName; | 142 | char *initName; |
139 | void *mptr; | 143 | void *mptr; |
140 | 144 | ||
141 | GNUNET_asprintf (&initName, "_%s_%s", plug->name, name); | 145 | GNUNET_asprintf (&initName, |
142 | mptr = lt_dlsym (plug->handle, &initName[1]); | 146 | "_%s_%s", |
147 | plug->name, | ||
148 | name); | ||
149 | mptr = lt_dlsym (plug->handle, | ||
150 | &initName[1]); | ||
143 | if (NULL == mptr) | 151 | if (NULL == mptr) |
144 | mptr = lt_dlsym (plug->handle, initName); | 152 | mptr = lt_dlsym (plug->handle, |
153 | initName); | ||
145 | if (NULL == mptr) | 154 | if (NULL == mptr) |
146 | LOG (GNUNET_ERROR_TYPE_ERROR, | 155 | LOG (GNUNET_ERROR_TYPE_ERROR, |
147 | _ ("`%s' failed to resolve method '%s' with error: %s\n"), | 156 | _ ("`%s' failed to resolve method '%s' with error: %s\n"), |
@@ -179,7 +188,8 @@ GNUNET_PLUGIN_test (const char *library_name) | |||
179 | return GNUNET_NO; | 188 | return GNUNET_NO; |
180 | plug.handle = libhandle; | 189 | plug.handle = libhandle; |
181 | plug.name = (char *) library_name; | 190 | plug.name = (char *) library_name; |
182 | init = resolve_function (&plug, "init"); | 191 | init = resolve_function (&plug, |
192 | "init"); | ||
183 | if (NULL == init) | 193 | if (NULL == init) |
184 | { | 194 | { |
185 | GNUNET_break (0); | 195 | GNUNET_break (0); |
@@ -204,7 +214,8 @@ GNUNET_PLUGIN_test (const char *library_name) | |||
204 | * @return whatever the initialization function returned | 214 | * @return whatever the initialization function returned |
205 | */ | 215 | */ |
206 | void * | 216 | void * |
207 | GNUNET_PLUGIN_load (const char *library_name, void *arg) | 217 | GNUNET_PLUGIN_load (const char *library_name, |
218 | void *arg) | ||
208 | { | 219 | { |
209 | void *libhandle; | 220 | void *libhandle; |
210 | struct PluginList *plug; | 221 | struct PluginList *plug; |
@@ -217,7 +228,7 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
217 | plugin_init (); | 228 | plugin_init (); |
218 | } | 229 | } |
219 | libhandle = lt_dlopenext (library_name); | 230 | libhandle = lt_dlopenext (library_name); |
220 | if (libhandle == NULL) | 231 | if (NULL == libhandle) |
221 | { | 232 | { |
222 | LOG (GNUNET_ERROR_TYPE_ERROR, | 233 | LOG (GNUNET_ERROR_TYPE_ERROR, |
223 | _ ("`%s' failed for library `%s' with error: %s\n"), | 234 | _ ("`%s' failed for library `%s' with error: %s\n"), |
@@ -231,8 +242,10 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
231 | plug->name = GNUNET_strdup (library_name); | 242 | plug->name = GNUNET_strdup (library_name); |
232 | plug->next = plugins; | 243 | plug->next = plugins; |
233 | plugins = plug; | 244 | plugins = plug; |
234 | init = resolve_function (plug, "init"); | 245 | init = resolve_function (plug, |
235 | if ((init == NULL) || (NULL == (ret = init (arg)))) | 246 | "init"); |
247 | if ( (NULL == init) || | ||
248 | (NULL == (ret = init (arg))) ) | ||
236 | { | 249 | { |
237 | lt_dlclose (libhandle); | 250 | lt_dlclose (libhandle); |
238 | GNUNET_free (plug->name); | 251 | GNUNET_free (plug->name); |
@@ -253,7 +266,8 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg) | |||
253 | * @return whatever the shutdown function returned | 266 | * @return whatever the shutdown function returned |
254 | */ | 267 | */ |
255 | void * | 268 | void * |
256 | GNUNET_PLUGIN_unload (const char *library_name, void *arg) | 269 | GNUNET_PLUGIN_unload (const char *library_name, |
270 | void *arg) | ||
257 | { | 271 | { |
258 | struct PluginList *pos; | 272 | struct PluginList *pos; |
259 | struct PluginList *prev; | 273 | struct PluginList *prev; |
@@ -262,7 +276,9 @@ GNUNET_PLUGIN_unload (const char *library_name, void *arg) | |||
262 | 276 | ||
263 | prev = NULL; | 277 | prev = NULL; |
264 | pos = plugins; | 278 | pos = plugins; |
265 | while ((NULL != pos) && (0 != strcmp (pos->name, library_name))) | 279 | while ( (NULL != pos) && |
280 | (0 != strcmp (pos->name, | ||
281 | library_name)) ) | ||
266 | { | 282 | { |
267 | prev = pos; | 283 | prev = pos; |
268 | pos = pos->next; | 284 | pos = pos->next; |
@@ -270,7 +286,8 @@ GNUNET_PLUGIN_unload (const char *library_name, void *arg) | |||
270 | if (NULL == pos) | 286 | if (NULL == pos) |
271 | return NULL; | 287 | return NULL; |
272 | 288 | ||
273 | done = resolve_function (pos, "done"); | 289 | done = resolve_function (pos, |
290 | "done"); | ||
274 | ret = NULL; | 291 | ret = NULL; |
275 | if (NULL != done) | 292 | if (NULL != done) |
276 | ret = done (arg); | 293 | ret = done (arg); |
@@ -327,7 +344,8 @@ struct LoadAllContext | |||
327 | * @return #GNUNET_OK (continue loading) | 344 | * @return #GNUNET_OK (continue loading) |
328 | */ | 345 | */ |
329 | static int | 346 | static int |
330 | find_libraries (void *cls, const char *filename) | 347 | find_libraries (void *cls, |
348 | const char *filename) | ||
331 | { | 349 | { |
332 | struct LoadAllContext *lac = cls; | 350 | struct LoadAllContext *lac = cls; |
333 | const char *slashpos; | 351 | const char *slashpos; |
@@ -338,19 +356,26 @@ find_libraries (void *cls, const char *filename) | |||
338 | size_t n; | 356 | size_t n; |
339 | 357 | ||
340 | libname = filename; | 358 | libname = filename; |
341 | while (NULL != (slashpos = strstr (libname, DIR_SEPARATOR_STR))) | 359 | while (NULL != (slashpos = strstr (libname, |
360 | DIR_SEPARATOR_STR))) | ||
342 | libname = slashpos + 1; | 361 | libname = slashpos + 1; |
343 | n = strlen (libname); | 362 | n = strlen (libname); |
344 | if (0 != strncmp (lac->basename, libname, strlen (lac->basename))) | 363 | if (0 != strncmp (lac->basename, |
364 | libname, | ||
365 | strlen (lac->basename))) | ||
345 | return GNUNET_OK; /* wrong name */ | 366 | return GNUNET_OK; /* wrong name */ |
346 | if ((n > 3) && (0 == strcmp (&libname[n - 3], ".la"))) | 367 | if ( (n > 3) && |
368 | (0 == strcmp (&libname[n - 3], ".la")) ) | ||
347 | return GNUNET_OK; /* .la file */ | 369 | return GNUNET_OK; /* .la file */ |
348 | basename = GNUNET_strdup (libname); | 370 | basename = GNUNET_strdup (libname); |
349 | if (NULL != (dot = strstr (basename, "."))) | 371 | if (NULL != (dot = strstr (basename, "."))) |
350 | *dot = '\0'; | 372 | *dot = '\0'; |
351 | lib_ret = GNUNET_PLUGIN_load (basename, lac->arg); | 373 | lib_ret = GNUNET_PLUGIN_load (basename, |
374 | lac->arg); | ||
352 | if (NULL != lib_ret) | 375 | if (NULL != lib_ret) |
353 | lac->cb (lac->cb_cls, basename, lib_ret); | 376 | lac->cb (lac->cb_cls, |
377 | basename, | ||
378 | lib_ret); | ||
354 | GNUNET_free (basename); | 379 | GNUNET_free (basename); |
355 | return GNUNET_OK; | 380 | return GNUNET_OK; |
356 | } | 381 | } |
@@ -388,7 +413,9 @@ GNUNET_PLUGIN_load_all (const char *basename, | |||
388 | lac.arg = arg; | 413 | lac.arg = arg; |
389 | lac.cb = cb; | 414 | lac.cb = cb; |
390 | lac.cb_cls = cb_cls; | 415 | lac.cb_cls = cb_cls; |
391 | GNUNET_DISK_directory_scan (path, &find_libraries, &lac); | 416 | GNUNET_DISK_directory_scan (path, |
417 | &find_libraries, | ||
418 | &lac); | ||
392 | GNUNET_free (path); | 419 | GNUNET_free (path); |
393 | } | 420 | } |
394 | 421 | ||
diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 6969e49e6..12bde8107 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c | |||
@@ -30,12 +30,12 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | static int | 32 | static int |
33 | testReadWrite () | 33 | testReadWrite (void) |
34 | { | 34 | { |
35 | char tmp[100 + 1]; | 35 | char tmp[100 + 1]; |
36 | int ret; | 36 | int ret; |
37 | 37 | ||
38 | if (strlen (TESTSTRING) != | 38 | if (GNUNET_OK != |
39 | GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (TESTSTRING), | 39 | GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (TESTSTRING), |
40 | GNUNET_DISK_PERM_USER_READ | 40 | GNUNET_DISK_PERM_USER_READ |
41 | | GNUNET_DISK_PERM_USER_WRITE)) | 41 | | GNUNET_DISK_PERM_USER_WRITE)) |