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/transport | |
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/transport')
-rw-r--r-- | src/transport/gnunet-helper-transport-bluetooth.c | 4 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 4 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 51 | ||||
-rw-r--r-- | src/transport/transport.conf.in | 2 |
4 files changed, 21 insertions, 40 deletions
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c index 43eccf0aa..f12303982 100644 --- a/src/transport/gnunet-helper-transport-bluetooth.c +++ b/src/transport/gnunet-helper-transport-bluetooth.c | |||
@@ -1070,6 +1070,7 @@ read_from_the_socket (void *sock, | |||
1070 | return count; | 1070 | return count; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | |||
1073 | /** | 1074 | /** |
1074 | * Open the bluetooth interface for reading/writing | 1075 | * Open the bluetooth interface for reading/writing |
1075 | * | 1076 | * |
@@ -1087,7 +1088,8 @@ open_device (struct HardwareInfos *dev) | |||
1087 | addr.btAddr = 0; | 1088 | addr.btAddr = 0; |
1088 | addr.port = BT_PORT_ANY; | 1089 | addr.port = BT_PORT_ANY; |
1089 | 1090 | ||
1090 | if (GNUNET_NETWORK_socket_bind (dev->handle, (const SOCKADDR*)&addr, sizeof (SOCKADDR_BTH), 0) != GNUNET_OK) | 1091 | if (GNUNET_OK != |
1092 | GNUNET_NETWORK_socket_bind (dev->handle, (const SOCKADDR*)&addr, sizeof (SOCKADDR_BTH))) | ||
1091 | { | 1093 | { |
1092 | fprintf (stderr, "Failed to bind the socket: "); | 1094 | fprintf (stderr, "Failed to bind the socket: "); |
1093 | if (GetLastError() == WSAENETDOWN) | 1095 | if (GetLastError() == WSAENETDOWN) |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index bc64fd5d2..eb3d92163 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2808,7 +2808,7 @@ setup_sockets (struct Plugin *plugin, | |||
2808 | GNUNET_a2s (serverAddr, addrlen)); | 2808 | GNUNET_a2s (serverAddr, addrlen)); |
2809 | /* binding */ | 2809 | /* binding */ |
2810 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv6, | 2810 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv6, |
2811 | serverAddr, addrlen, 0)) | 2811 | serverAddr, addrlen)) |
2812 | break; | 2812 | break; |
2813 | eno = errno; | 2813 | eno = errno; |
2814 | if (0 != plugin->port) | 2814 | if (0 != plugin->port) |
@@ -2885,7 +2885,7 @@ setup_sockets (struct Plugin *plugin, | |||
2885 | 2885 | ||
2886 | /* binding */ | 2886 | /* binding */ |
2887 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, | 2887 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, |
2888 | serverAddr, addrlen, 0)) | 2888 | serverAddr, addrlen)) |
2889 | break; | 2889 | break; |
2890 | eno = errno; | 2890 | eno = errno; |
2891 | if (0 != plugin->port) | 2891 | if (0 != plugin->port) |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 2087d30e5..4e3038787 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -572,7 +572,6 @@ unix_real_send (void *cls, | |||
572 | const void *sb; | 572 | const void *sb; |
573 | size_t sbs; | 573 | size_t sbs; |
574 | struct sockaddr_un un; | 574 | struct sockaddr_un un; |
575 | size_t slen; | ||
576 | const char *unix_path; | 575 | const char *unix_path; |
577 | 576 | ||
578 | 577 | ||
@@ -592,21 +591,12 @@ unix_real_send (void *cls, | |||
592 | unix_path = (const char *) &addr[1]; | 591 | unix_path = (const char *) &addr[1]; |
593 | memset (&un, 0, sizeof (un)); | 592 | memset (&un, 0, sizeof (un)); |
594 | un.sun_family = AF_UNIX; | 593 | un.sun_family = AF_UNIX; |
595 | slen = strlen (unix_path); | 594 | strncpy (un.sun_path, unix_path, sizeof (un.sun_path) - 1); |
596 | if (slen >= sizeof (un.sun_path)) | ||
597 | slen = sizeof (un.sun_path) - 1; | ||
598 | GNUNET_assert (slen < sizeof (un.sun_path)); | ||
599 | memcpy (un.sun_path, unix_path, slen); | ||
600 | un.sun_path[slen] = '\0'; | ||
601 | slen = sizeof (struct sockaddr_un); | ||
602 | #if LINUX | ||
603 | un.sun_path[0] = '\0'; | ||
604 | #endif | ||
605 | #if HAVE_SOCKADDR_IN_SIN_LEN | 595 | #if HAVE_SOCKADDR_IN_SIN_LEN |
606 | un.sun_len = (u_char) slen; | 596 | un.sun_len = (u_char) sizeof (struct sockaddr_un); |
607 | #endif | 597 | #endif |
608 | sb = (struct sockaddr *) &un; | 598 | sb = (struct sockaddr *) &un; |
609 | sbs = slen; | 599 | sbs = sizeof (struct sockaddr_un); |
610 | 600 | ||
611 | resend: | 601 | resend: |
612 | /* Send the data */ | 602 | /* Send the data */ |
@@ -1023,19 +1013,18 @@ unix_plugin_select_read (struct Plugin *plugin) | |||
1023 | } | 1013 | } |
1024 | else | 1014 | else |
1025 | { | 1015 | { |
1026 | #if LINUX | 1016 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1027 | un.sun_path[0] = '/'; | 1017 | "Read %d bytes from socket %s\n", |
1028 | #endif | 1018 | (int) ret, |
1029 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %d bytes from socket %s\n", ret, | 1019 | un.sun_path); |
1030 | &un.sun_path[0]); | ||
1031 | } | 1020 | } |
1032 | 1021 | ||
1033 | GNUNET_assert (AF_UNIX == (un.sun_family)); | 1022 | GNUNET_assert (AF_UNIX == (un.sun_family)); |
1034 | ua_len = sizeof (struct UnixAddress) + strlen (&un.sun_path[0]) +1; | 1023 | ua_len = sizeof (struct UnixAddress) + strlen (un.sun_path) + 1; |
1035 | ua = GNUNET_malloc (ua_len); | 1024 | ua = GNUNET_malloc (ua_len); |
1036 | ua->addrlen = htonl (strlen (&un.sun_path[0]) +1); | 1025 | ua->addrlen = htonl (strlen (&un.sun_path[0]) +1); |
1037 | ua->options = htonl (0); | 1026 | ua->options = htonl (0); |
1038 | memcpy (&ua[1], &un.sun_path[0], strlen (&un.sun_path[0]) +1); | 1027 | memcpy (&ua[1], &un.sun_path[0], strlen (un.sun_path) + 1); |
1039 | 1028 | ||
1040 | msg = (struct UNIXMessage *) buf; | 1029 | msg = (struct UNIXMessage *) buf; |
1041 | csize = ntohs (msg->header.size); | 1030 | csize = ntohs (msg->header.size); |
@@ -1214,7 +1203,7 @@ unix_plugin_select (void *cls, | |||
1214 | * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4. | 1203 | * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4. |
1215 | * | 1204 | * |
1216 | * @param cls closure for server start, should be a struct Plugin * | 1205 | * @param cls closure for server start, should be a struct Plugin * |
1217 | * @return number of sockets created or GNUNET_SYSERR on error | 1206 | * @return number of sockets created or #GNUNET_SYSERR on error |
1218 | */ | 1207 | */ |
1219 | static int | 1208 | static int |
1220 | unix_transport_server_start (void *cls) | 1209 | unix_transport_server_start (void *cls) |
@@ -1223,26 +1212,16 @@ unix_transport_server_start (void *cls) | |||
1223 | struct sockaddr *serverAddr; | 1212 | struct sockaddr *serverAddr; |
1224 | socklen_t addrlen; | 1213 | socklen_t addrlen; |
1225 | struct sockaddr_un un; | 1214 | struct sockaddr_un un; |
1226 | size_t slen; | ||
1227 | 1215 | ||
1228 | memset (&un, 0, sizeof (un)); | 1216 | memset (&un, 0, sizeof (un)); |
1229 | un.sun_family = AF_UNIX; | 1217 | un.sun_family = AF_UNIX; |
1230 | slen = strlen (plugin->unix_socket_path) + 1; | 1218 | strncpy (un.sun_path, plugin->unix_socket_path, sizeof (un.sun_path) - 1); |
1231 | if (slen >= sizeof (un.sun_path)) | ||
1232 | slen = sizeof (un.sun_path) - 1; | ||
1233 | |||
1234 | memcpy (un.sun_path, plugin->unix_socket_path, slen); | ||
1235 | un.sun_path[slen] = '\0'; | ||
1236 | slen = sizeof (struct sockaddr_un); | ||
1237 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1219 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1238 | un.sun_len = (u_char) slen; | 1220 | un.sun_len = (u_char) sizeof (struct sockaddr_un); |
1239 | #endif | 1221 | #endif |
1240 | 1222 | ||
1241 | serverAddr = (struct sockaddr *) &un; | 1223 | serverAddr = (struct sockaddr *) &un; |
1242 | addrlen = slen; | 1224 | addrlen = sizeof (struct sockaddr_un); |
1243 | #if LINUX | ||
1244 | un.sun_path[0] = '\0'; | ||
1245 | #endif | ||
1246 | plugin->ats_network = plugin->env->get_address_type (plugin->env->cls, serverAddr, addrlen); | 1225 | plugin->ats_network = plugin->env->get_address_type (plugin->env->cls, serverAddr, addrlen); |
1247 | plugin->unix_sock.desc = | 1226 | plugin->unix_sock.desc = |
1248 | GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0); | 1227 | GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0); |
@@ -1251,8 +1230,8 @@ unix_transport_server_start (void *cls) | |||
1251 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 1230 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
1252 | return GNUNET_SYSERR; | 1231 | return GNUNET_SYSERR; |
1253 | } | 1232 | } |
1254 | if (GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc, serverAddr, addrlen, 0) | 1233 | if (GNUNET_OK != |
1255 | != GNUNET_OK) | 1234 | GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc, serverAddr, addrlen)) |
1256 | { | 1235 | { |
1257 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); | 1236 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); |
1258 | GNUNET_NETWORK_socket_close (plugin->unix_sock.desc); | 1237 | GNUNET_NETWORK_socket_close (plugin->unix_sock.desc); |
diff --git a/src/transport/transport.conf.in b/src/transport/transport.conf.in index fd8b5dbbb..d33fa99fe 100644 --- a/src/transport/transport.conf.in +++ b/src/transport/transport.conf.in | |||
@@ -9,7 +9,7 @@ NEIGHBOUR_LIMIT = 50 | |||
9 | ACCEPT_FROM = 127.0.0.1; | 9 | ACCEPT_FROM = 127.0.0.1; |
10 | ACCEPT_FROM6 = ::1; | 10 | ACCEPT_FROM6 = ::1; |
11 | PLUGINS = tcp udp | 11 | PLUGINS = tcp udp |
12 | UNIXPATH = /tmp/gnunet-service-transport.sock | 12 | UNIXPATH = $SERVICEHOME/gnunet-service-transport.sock |
13 | BLACKLIST_FILE = $SERVICEHOME/blacklist | 13 | BLACKLIST_FILE = $SERVICEHOME/blacklist |
14 | UNIX_MATCH_UID = NO | 14 | UNIX_MATCH_UID = NO |
15 | UNIX_MATCH_GID = YES | 15 | UNIX_MATCH_GID = YES |