diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-26 18:48:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-26 18:48:59 +0000 |
commit | fa7d6b32530d3d8c2d7e542a15319c74c22061b6 (patch) | |
tree | 8f4c7615c89f646a66fc709b698ef81becdf1ad1 /src/util | |
parent | d79a03493ba5d0581e828724a402a2054429e7be (diff) | |
download | gnunet-fa7d6b32530d3d8c2d7e542a15319c74c22061b6.tar.gz gnunet-fa7d6b32530d3d8c2d7e542a15319c74c22061b6.zip |
moving from abstract unix domain socket paths to normal unix domain socket paths (#2887), removing now unnecessary/dead flags argument to GNUNET_NETWORK_socket_bind
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/client.c | 30 | ||||
-rw-r--r-- | src/util/connection.c | 15 | ||||
-rw-r--r-- | src/util/disk.c | 12 | ||||
-rw-r--r-- | src/util/network.c | 28 | ||||
-rw-r--r-- | src/util/resolver.conf.in | 2 | ||||
-rw-r--r-- | src/util/server.c | 2 | ||||
-rw-r--r-- | src/util/service.c | 24 | ||||
-rw-r--r-- | src/util/test_connection.c | 6 | ||||
-rw-r--r-- | src/util/test_connection_addressing.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_receive_cancel.c | 6 | ||||
-rw-r--r-- | src/util/test_connection_timeout.c | 6 | ||||
-rw-r--r-- | src/util/test_server_with_client_unix.c | 7 |
12 files changed, 53 insertions, 87 deletions
diff --git a/src/util/client.c b/src/util/client.c index 30c80bf03..64960f232 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -251,7 +251,9 @@ try_unixpath (const char *service_name, | |||
251 | struct sockaddr_un s_un; | 251 | struct sockaddr_un s_un; |
252 | 252 | ||
253 | unixpath = NULL; | 253 | unixpath = NULL; |
254 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) && | 254 | if ((GNUNET_OK == |
255 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, | ||
256 | "UNIXPATH", &unixpath)) && | ||
255 | (0 < strlen (unixpath))) | 257 | (0 < strlen (unixpath))) |
256 | { | 258 | { |
257 | /* We have a non-NULL unixpath, need to validate it */ | 259 | /* We have a non-NULL unixpath, need to validate it */ |
@@ -299,7 +301,8 @@ test_service_configuration (const char *service_name, | |||
299 | #if AF_UNIX | 301 | #if AF_UNIX |
300 | char *unixpath = NULL; | 302 | char *unixpath = NULL; |
301 | 303 | ||
302 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) && | 304 | if ((GNUNET_OK == |
305 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", &unixpath)) && | ||
303 | (0 < strlen (unixpath))) | 306 | (0 < strlen (unixpath))) |
304 | ret = GNUNET_OK; | 307 | ret = GNUNET_OK; |
305 | GNUNET_free_non_null (unixpath); | 308 | GNUNET_free_non_null (unixpath); |
@@ -829,11 +832,12 @@ GNUNET_CLIENT_service_test (const char *service, | |||
829 | { | 832 | { |
830 | /* probe UNIX support */ | 833 | /* probe UNIX support */ |
831 | struct sockaddr_un s_un; | 834 | struct sockaddr_un s_un; |
832 | size_t slen; | ||
833 | char *unixpath; | 835 | char *unixpath; |
834 | 836 | ||
835 | unixpath = NULL; | 837 | unixpath = NULL; |
836 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service, "UNIXPATH", &unixpath)) && (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ | 838 | if ((GNUNET_OK == |
839 | GNUNET_CONFIGURATION_get_value_filename (cfg, service, "UNIXPATH", &unixpath)) && | ||
840 | (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ | ||
837 | { | 841 | { |
838 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) | 842 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) |
839 | { | 843 | { |
@@ -852,21 +856,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
852 | { | 856 | { |
853 | memset (&s_un, 0, sizeof (s_un)); | 857 | memset (&s_un, 0, sizeof (s_un)); |
854 | s_un.sun_family = AF_UNIX; | 858 | s_un.sun_family = AF_UNIX; |
855 | slen = strlen (unixpath) + 1; | 859 | strncpy (s_un.sun_path, unixpath, sizeof (s_un.sun_path) - 1); |
856 | if (slen >= sizeof (s_un.sun_path)) | ||
857 | slen = sizeof (s_un.sun_path) - 1; | ||
858 | memcpy (s_un.sun_path, unixpath, slen); | ||
859 | s_un.sun_path[slen] = '\0'; | ||
860 | slen = sizeof (struct sockaddr_un); | ||
861 | #if LINUX | ||
862 | s_un.sun_path[0] = '\0'; | ||
863 | #endif | ||
864 | #if HAVE_SOCKADDR_IN_SIN_LEN | 860 | #if HAVE_SOCKADDR_IN_SIN_LEN |
865 | s_un.sun_len = (u_char) slen; | 861 | s_un.sun_len = (u_char) sizeof (struct sockaddr_un); |
866 | #endif | 862 | #endif |
867 | if (GNUNET_OK != | 863 | if (GNUNET_OK != |
868 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, | 864 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, |
869 | slen, GNUNET_BIND_EXCLUSIVE)) | 865 | sizeof (struct sockaddr_un))) |
870 | { | 866 | { |
871 | /* failed to bind => service must be running */ | 867 | /* failed to bind => service must be running */ |
872 | GNUNET_free (unixpath); | 868 | GNUNET_free (unixpath); |
@@ -916,7 +912,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
916 | { | 912 | { |
917 | if (GNUNET_OK != | 913 | if (GNUNET_OK != |
918 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, | 914 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, |
919 | sizeof (s_in), GNUNET_BIND_EXCLUSIVE)) | 915 | sizeof (s_in))) |
920 | { | 916 | { |
921 | /* failed to bind => service must be running */ | 917 | /* failed to bind => service must be running */ |
922 | GNUNET_free (hostname); | 918 | GNUNET_free (hostname); |
@@ -949,7 +945,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
949 | { | 945 | { |
950 | if (GNUNET_OK != | 946 | if (GNUNET_OK != |
951 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, | 947 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, |
952 | sizeof (s_in6), GNUNET_BIND_EXCLUSIVE)) | 948 | sizeof (s_in6))) |
953 | { | 949 | { |
954 | /* failed to bind => service must be running */ | 950 | /* failed to bind => service must be running */ |
955 | GNUNET_free (hostname); | 951 | GNUNET_free (hostname); |
diff --git a/src/util/connection.c b/src/util/connection.c index 3290abcfc..c8d9919ea 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -828,22 +828,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
828 | #ifdef AF_UNIX | 828 | #ifdef AF_UNIX |
829 | struct GNUNET_CONNECTION_Handle *connection; | 829 | struct GNUNET_CONNECTION_Handle *connection; |
830 | struct sockaddr_un *un; | 830 | struct sockaddr_un *un; |
831 | size_t slen; | ||
832 | 831 | ||
833 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ | 832 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ |
834 | un = GNUNET_new (struct sockaddr_un); | 833 | un = GNUNET_new (struct sockaddr_un); |
835 | un->sun_family = AF_UNIX; | 834 | un->sun_family = AF_UNIX; |
836 | slen = strlen (unixpath); | 835 | strncpy(un->sun_path, unixpath, sizeof(un->sun_path) - 1); |
837 | if (slen >= sizeof (un->sun_path)) | ||
838 | slen = sizeof (un->sun_path) - 1; | ||
839 | memcpy (un->sun_path, unixpath, slen); | ||
840 | un->sun_path[slen] = '\0'; | ||
841 | slen = sizeof (struct sockaddr_un); | ||
842 | #if HAVE_SOCKADDR_IN_SIN_LEN | 836 | #if HAVE_SOCKADDR_IN_SIN_LEN |
843 | un->sun_len = (u_char) slen; | 837 | un->sun_len = (u_char) sizeof (struct sockaddr_un); |
844 | #endif | ||
845 | #if LINUX | ||
846 | un->sun_path[0] = '\0'; | ||
847 | #endif | 838 | #endif |
848 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 839 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
849 | connection->cfg = cfg; | 840 | connection->cfg = cfg; |
@@ -852,7 +843,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
852 | connection->port = 0; | 843 | connection->port = 0; |
853 | connection->hostname = NULL; | 844 | connection->hostname = NULL; |
854 | connection->addr = (struct sockaddr *) un; | 845 | connection->addr = (struct sockaddr *) un; |
855 | connection->addrlen = slen; | 846 | connection->addrlen = sizeof (struct sockaddr_un); |
856 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | 847 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); |
857 | if (NULL == connection->sock) | 848 | if (NULL == connection->sock) |
858 | { | 849 | { |
diff --git a/src/util/disk.c b/src/util/disk.c index 066b0b99b..34480e36a 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -759,13 +759,12 @@ GNUNET_DISK_directory_create (const char *dir) | |||
759 | 759 | ||
760 | 760 | ||
761 | /** | 761 | /** |
762 | * Create the directory structure for storing | 762 | * Create the directory structure for storing a file. |
763 | * a file. | ||
764 | * | 763 | * |
765 | * @param filename name of a file in the directory | 764 | * @param filename name of a file in the directory |
766 | * @returns GNUNET_OK on success, | 765 | * @returns #GNUNET_OK on success, |
767 | * GNUNET_SYSERR on failure, | 766 | * #GNUNET_SYSERR on failure, |
768 | * GNUNET_NO if the directory | 767 | * #GNUNET_NO if the directory |
769 | * exists but is not writeable for us | 768 | * exists but is not writeable for us |
770 | */ | 769 | */ |
771 | int | 770 | int |
@@ -792,10 +791,11 @@ GNUNET_DISK_directory_create_for_file (const char *filename) | |||
792 | 791 | ||
793 | /** | 792 | /** |
794 | * Read the contents of a binary file into a buffer. | 793 | * Read the contents of a binary file into a buffer. |
794 | * | ||
795 | * @param h handle to an open file | 795 | * @param h handle to an open file |
796 | * @param result the buffer to write the result to | 796 | * @param result the buffer to write the result to |
797 | * @param len the maximum number of bytes to read | 797 | * @param len the maximum number of bytes to read |
798 | * @return the number of bytes read on success, GNUNET_SYSERR on failure | 798 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure |
799 | */ | 799 | */ |
800 | ssize_t | 800 | ssize_t |
801 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result, | 801 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result, |
diff --git a/src/util/network.c b/src/util/network.c index c0b977368..793290b45 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -87,7 +87,9 @@ GNUNET_NETWORK_test_pf (int pf) | |||
87 | { | 87 | { |
88 | if (EAFNOSUPPORT == errno) | 88 | if (EAFNOSUPPORT == errno) |
89 | return GNUNET_NO; | 89 | return GNUNET_NO; |
90 | fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno)); | 90 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
91 | "Failed to create test socket: %s\n", | ||
92 | STRERROR (errno)); | ||
91 | return GNUNET_SYSERR; | 93 | return GNUNET_SYSERR; |
92 | } | 94 | } |
93 | #if WINDOWS | 95 | #if WINDOWS |
@@ -383,20 +385,18 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
383 | * @param desc socket to bind | 385 | * @param desc socket to bind |
384 | * @param address address to be bound | 386 | * @param address address to be bound |
385 | * @param address_len length of @a address | 387 | * @param address_len length of @a address |
386 | * @param flags flags affecting bind behaviour | ||
387 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 388 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
388 | */ | 389 | */ |
389 | int | 390 | int |
390 | GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | 391 | GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, |
391 | const struct sockaddr *address, | 392 | const struct sockaddr *address, |
392 | socklen_t address_len, | 393 | socklen_t address_len) |
393 | int flags) | ||
394 | { | 394 | { |
395 | int ret; | 395 | int ret; |
396 | socklen_t bind_address_len = address_len; | 396 | socklen_t bind_address_len = address_len; |
397 | 397 | ||
398 | #ifdef LINUX | 398 | #ifdef LINUX |
399 | if (address->sa_family == AF_UNIX) | 399 | if (AF_UNIX == address->sa_family) |
400 | { | 400 | { |
401 | const struct sockaddr_un *address_un = (const struct sockaddr_un *)address; | 401 | const struct sockaddr_un *address_un = (const struct sockaddr_un *)address; |
402 | if (address_un->sun_path[0] == '\0') | 402 | if (address_un->sun_path[0] == '\0') |
@@ -431,16 +431,6 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | |||
431 | LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt"); | 431 | LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt"); |
432 | } | 432 | } |
433 | #endif | 433 | #endif |
434 | #ifndef LINUX | ||
435 | #ifndef MINGW | ||
436 | if (address->sa_family == AF_UNIX && (flags & GNUNET_BIND_EXCLUSIVE) == 0) | ||
437 | { | ||
438 | const struct sockaddr_un *un = (const struct sockaddr_un *) address; | ||
439 | |||
440 | (void) unlink (un->sun_path); | ||
441 | } | ||
442 | #endif | ||
443 | #endif | ||
444 | ret = bind (desc->fd, address, bind_address_len); | 434 | ret = bind (desc->fd, address, bind_address_len); |
445 | #ifdef MINGW | 435 | #ifdef MINGW |
446 | if (SOCKET_ERROR == ret) | 436 | if (SOCKET_ERROR == ret) |
@@ -449,12 +439,10 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | |||
449 | if (ret != 0) | 439 | if (ret != 0) |
450 | return GNUNET_SYSERR; | 440 | return GNUNET_SYSERR; |
451 | #ifndef MINGW | 441 | #ifndef MINGW |
452 | #ifndef LINUX | ||
453 | desc->addr = GNUNET_malloc (address_len); | 442 | desc->addr = GNUNET_malloc (address_len); |
454 | memcpy (desc->addr, address, address_len); | 443 | memcpy (desc->addr, address, address_len); |
455 | desc->addrlen = address_len; | 444 | desc->addrlen = address_len; |
456 | #endif | 445 | #endif |
457 | #endif | ||
458 | return GNUNET_OK; | 446 | return GNUNET_OK; |
459 | } | 447 | } |
460 | 448 | ||
@@ -483,17 +471,17 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
483 | #else | 471 | #else |
484 | ret = close (desc->fd); | 472 | ret = close (desc->fd); |
485 | #endif | 473 | #endif |
486 | #ifndef LINUX | ||
487 | #ifndef MINGW | 474 | #ifndef MINGW |
488 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) | 475 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) |
489 | { | 476 | { |
490 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; | 477 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; |
491 | 478 | ||
492 | if (0 != unlink (un->sun_path)) | 479 | if (0 != unlink (un->sun_path)) |
493 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", un->sun_path); | 480 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
481 | "unlink", | ||
482 | un->sun_path); | ||
494 | } | 483 | } |
495 | #endif | 484 | #endif |
496 | #endif | ||
497 | GNUNET_NETWORK_socket_free_memory_only_ (desc); | 485 | GNUNET_NETWORK_socket_free_memory_only_ (desc); |
498 | return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR; | 486 | return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR; |
499 | } | 487 | } |
diff --git a/src/util/resolver.conf.in b/src/util/resolver.conf.in index cccb60c2f..005082ea5 100644 --- a/src/util/resolver.conf.in +++ b/src/util/resolver.conf.in | |||
@@ -6,7 +6,7 @@ HOME = $SERVICEHOME | |||
6 | BINARY = gnunet-service-resolver | 6 | BINARY = gnunet-service-resolver |
7 | ACCEPT_FROM = 127.0.0.1; | 7 | ACCEPT_FROM = 127.0.0.1; |
8 | ACCEPT_FROM6 = ::1; | 8 | ACCEPT_FROM6 = ::1; |
9 | UNIXPATH = /tmp/gnunet-service-resolver.sock | 9 | UNIXPATH = $SERVICEHOME/gnunet-service-resolver.sock |
10 | UNIX_MATCH_UID = NO | 10 | UNIX_MATCH_UID = NO |
11 | UNIX_MATCH_GID = NO | 11 | UNIX_MATCH_GID = NO |
12 | # DISABLE_SOCKET_FORWARDING = NO | 12 | # DISABLE_SOCKET_FORWARDING = NO |
diff --git a/src/util/server.c b/src/util/server.c index 9e88992ca..4df8fd83d 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -469,7 +469,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
469 | return NULL; | 469 | return NULL; |
470 | } | 470 | } |
471 | /* bind the socket */ | 471 | /* bind the socket */ |
472 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen, 0)) | 472 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen)) |
473 | { | 473 | { |
474 | eno = errno; | 474 | eno = errno; |
475 | if (EADDRINUSE != errno) | 475 | if (EADDRINUSE != errno) |
diff --git a/src/util/service.c b/src/util/service.c index b91be9664..489dd2e55 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -841,24 +841,15 @@ add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens, | |||
841 | { | 841 | { |
842 | #ifdef AF_UNIX | 842 | #ifdef AF_UNIX |
843 | struct sockaddr_un *un; | 843 | struct sockaddr_un *un; |
844 | size_t slen; | ||
845 | 844 | ||
846 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); | 845 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); |
847 | un->sun_family = AF_UNIX; | 846 | un->sun_family = AF_UNIX; |
848 | slen = strlen (unixpath) + 1; | 847 | strncpy (un->sun_path, unixpath, sizeof (un->sun_path) - 1); |
849 | if (slen >= sizeof (un->sun_path)) | ||
850 | slen = sizeof (un->sun_path) - 1; | ||
851 | memcpy (un->sun_path, unixpath, slen); | ||
852 | un->sun_path[slen] = '\0'; | ||
853 | slen = sizeof (struct sockaddr_un); | ||
854 | #if LINUX | ||
855 | un->sun_path[0] = '\0'; | ||
856 | #endif | ||
857 | #if HAVE_SOCKADDR_IN_SIN_LEN | 848 | #if HAVE_SOCKADDR_IN_SIN_LEN |
858 | un->sun_len = (u_char) slen; | 849 | un->sun_len = (u_char) sizeof (struct sockaddr_un); |
859 | #endif | 850 | #endif |
860 | *saddrs = (struct sockaddr *) un; | 851 | *saddrs = (struct sockaddr *) un; |
861 | *saddrlens = slen; | 852 | *saddrlens = sizeof (struct sockaddr_un); |
862 | #else | 853 | #else |
863 | /* this function should never be called | 854 | /* this function should never be called |
864 | * unless AF_UNIX is defined! */ | 855 | * unless AF_UNIX is defined! */ |
@@ -980,8 +971,8 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name, | |||
980 | if ((GNUNET_YES == | 971 | if ((GNUNET_YES == |
981 | GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && | 972 | GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && |
982 | (GNUNET_OK == | 973 | (GNUNET_OK == |
983 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", | 974 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", |
984 | &unixpath)) && | 975 | &unixpath)) && |
985 | (0 < strlen (unixpath))) | 976 | (0 < strlen (unixpath))) |
986 | { | 977 | { |
987 | /* probe UNIX support */ | 978 | /* probe UNIX support */ |
@@ -996,6 +987,11 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name, | |||
996 | LOG (GNUNET_ERROR_TYPE_INFO, | 987 | LOG (GNUNET_ERROR_TYPE_INFO, |
997 | _("Using `%s' instead\n"), unixpath); | 988 | _("Using `%s' instead\n"), unixpath); |
998 | } | 989 | } |
990 | if (GNUNET_OK != | ||
991 | GNUNET_DISK_directory_create_for_file (unixpath)) | ||
992 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
993 | "mkdir", | ||
994 | unixpath); | ||
999 | } | 995 | } |
1000 | if (NULL != unixpath) | 996 | if (NULL != unixpath) |
1001 | { | 997 | { |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 1ba20498f..6644623d4 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -65,9 +65,9 @@ open_listen_socket () | |||
65 | if (GNUNET_NETWORK_socket_setsockopt | 65 | if (GNUNET_NETWORK_socket_setsockopt |
66 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 66 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
67 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 67 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
68 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 68 | GNUNET_assert (GNUNET_OK == |
69 | (desc, (const struct sockaddr *) &sa, | 69 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
70 | sizeof (sa), 0) == GNUNET_OK); | 70 | sizeof (sa))); |
71 | GNUNET_NETWORK_socket_listen (desc, 5); | 71 | GNUNET_NETWORK_socket_listen (desc, 5); |
72 | return desc; | 72 | return desc; |
73 | } | 73 | } |
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index eeb610dd1..e5c8edeeb 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -68,7 +68,7 @@ open_listen_socket () | |||
68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
69 | if (GNUNET_OK != | 69 | if (GNUNET_OK != |
70 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, | 70 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
71 | sizeof (sa), 0)) | 71 | sizeof (sa))) |
72 | { | 72 | { |
73 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 73 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
74 | "bind"); | 74 | "bind"); |
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index 99905e232..c61272a57 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -64,9 +64,9 @@ open_listen_socket () | |||
64 | if (GNUNET_NETWORK_socket_setsockopt | 64 | if (GNUNET_NETWORK_socket_setsockopt |
65 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 65 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
66 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 66 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
67 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 67 | GNUNET_assert (GNUNET_OK == |
68 | (desc, (const struct sockaddr *) &sa, | 68 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
69 | sizeof (sa), 0) == GNUNET_OK); | 69 | sizeof (sa))); |
70 | GNUNET_NETWORK_socket_listen (desc, 5); | 70 | GNUNET_NETWORK_socket_listen (desc, 5); |
71 | return desc; | 71 | return desc; |
72 | } | 72 | } |
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 6608e18db..7241bbfae 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -61,9 +61,9 @@ open_listen_socket () | |||
61 | if (GNUNET_NETWORK_socket_setsockopt | 61 | if (GNUNET_NETWORK_socket_setsockopt |
62 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 62 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
64 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 64 | GNUNET_assert (GNUNET_OK == |
65 | (desc, (const struct sockaddr *) &sa, | 65 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
66 | sizeof (sa), 0) == GNUNET_OK); | 66 | sizeof (sa))); |
67 | GNUNET_NETWORK_socket_listen (desc, 5); | 67 | GNUNET_NETWORK_socket_listen (desc, 5); |
68 | return desc; | 68 | return desc; |
69 | } | 69 | } |
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index 57a67d3f4..a4e0ffe5d 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c | |||
@@ -134,20 +134,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
134 | { | 134 | { |
135 | struct sockaddr_un un; | 135 | struct sockaddr_un un; |
136 | const char *unixpath = "/tmp/testsock"; | 136 | const char *unixpath = "/tmp/testsock"; |
137 | size_t slen = strlen (unixpath); | ||
138 | struct sockaddr *sap[2]; | 137 | struct sockaddr *sap[2]; |
139 | socklen_t slens[2]; | 138 | socklen_t slens[2]; |
140 | 139 | ||
141 | memset (&un, 0, sizeof (un)); | 140 | memset (&un, 0, sizeof (un)); |
142 | un.sun_family = AF_UNIX; | 141 | un.sun_family = AF_UNIX; |
143 | memcpy (un.sun_path, unixpath, slen); | 142 | strncpy(un.sun_path, unixpath, sizeof (un.sun_path) - 1); |
144 | un.sun_path[slen] = '\0'; | ||
145 | #if HAVE_SOCKADDR_IN_SIN_LEN | 143 | #if HAVE_SOCKADDR_IN_SIN_LEN |
146 | un.sun_len = (u_char) sizeof (un); | 144 | un.sun_len = (u_char) sizeof (un); |
147 | #endif | 145 | #endif |
148 | #if LINUX | ||
149 | un.sun_path[0] = '\0'; | ||
150 | #endif | ||
151 | 146 | ||
152 | sap[0] = (struct sockaddr *) &un; | 147 | sap[0] = (struct sockaddr *) &un; |
153 | slens[0] = sizeof (un); | 148 | slens[0] = sizeof (un); |