Commit c0120d99 authored by Lennart Poettering's avatar Lennart Poettering
Browse files

socket: fix parsing of bind_ipv6_only

parent 88ce42f6
......@@ -37,8 +37,6 @@
* provide sysv-like command line utilities
* Add OnlyByDependency
* ability to kill services? i.e. in contrast to stopping them, go directly
into killing mode?
......@@ -48,9 +46,9 @@
- nscd DONE
- dbus DONE
- rsyslog DONE
- rpcbind (/var/run/rpcbind.sock!)
- avahi-daemon (/var/run/avahi-daemon/socket)
- cups
- rpcbind (/var/run/rpcbind.sock!) DONE
- cups DONE
- avahi-daemon (/var/run/avahi-daemon/socket) DONE
- ssh CLASSIC
- postfix, saslauthd
- apache/samba
......@@ -63,7 +61,7 @@
* Figure out which signal handlers we actually have to reset in the
forked off child
* loopback-setup is borked for ipv6
* Add code to systemctl to wait for an operation to finish
Regularly:
......
......@@ -19,6 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include "dbus-unit.h"
#include "dbus-socket.h"
#include "dbus-execute.h"
......@@ -43,10 +45,12 @@ static const char introspection[] =
BUS_INTROSPECTABLE_INTERFACE
"</node>";
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_property_append_bool, "b", &u->socket.bind_ipv6_only },
{ "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
{ "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &u->socket.backlog },
{ "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &u->socket.timeout_usec },
/* ExecCommand */
......
......@@ -252,8 +252,8 @@ static int config_parse_socket_bind(
void *data,
void *userdata) {
int r;
Socket *s;
SocketAddressBindIPv6Only b;
assert(filename);
assert(lvalue);
......@@ -262,12 +262,17 @@ static int config_parse_socket_bind(
s = (Socket*) data;
if ((r = parse_boolean(rvalue)) < 0) {
log_error("[%s:%u] Failed to parse bind IPv6 only value: %s", filename, line, rvalue);
return r;
}
if ((b = socket_address_bind_ipv6_only_from_string(rvalue)) < 0) {
int r;
s->bind_ipv6_only = r ? SOCKET_ADDRESS_IPV6_ONLY : SOCKET_ADDRESS_BOTH;
if ((r = parse_boolean(rvalue)) < 0) {
log_error("[%s:%u] Failed to parse bind IPv6 only value: %s", filename, line, rvalue);
return -EBADMSG;
}
s->bind_ipv6_only = r ? SOCKET_ADDRESS_IPV6_ONLY : SOCKET_ADDRESS_BOTH;
} else
s->bind_ipv6_only = b;
return 0;
}
......
......@@ -466,3 +466,11 @@ bool socket_address_needs_mount(const SocketAddress *a, const char *prefix) {
return path_startswith(a->sockaddr.un.sun_path, prefix);
}
static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX] = {
[SOCKET_ADDRESS_DEFAULT] = "default",
[SOCKET_ADDRESS_BOTH] = "both",
[SOCKET_ADDRESS_IPV6_ONLY] = "ipv6-only"
};
DEFINE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
......@@ -50,7 +50,9 @@ typedef struct SocketAddress {
typedef enum SocketAddressBindIPv6Only {
SOCKET_ADDRESS_DEFAULT,
SOCKET_ADDRESS_BOTH,
SOCKET_ADDRESS_IPV6_ONLY
SOCKET_ADDRESS_IPV6_ONLY,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_INVALID = -1
} SocketAddressBindIPv6Only;
#define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
......@@ -76,4 +78,7 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b);
bool socket_address_needs_mount(const SocketAddress *a, const char *prefix);
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b);
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s);
#endif
......@@ -290,7 +290,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
"%sSocketMode: %04o\n"
"%sDirectoryMode: %04o\n",
prefix, socket_state_to_string(s->state),
prefix, yes_no(s->bind_ipv6_only),
prefix, socket_address_bind_ipv6_only_to_string(s->bind_ipv6_only),
prefix, s->backlog,
prefix, kill_mode_to_string(s->kill_mode),
prefix, s->socket_mode,
......
......@@ -70,7 +70,6 @@ struct SocketPort {
SocketAddress address;
char *path;
Watch fd_watch;
LIST_FIELDS(SocketPort, port);
......@@ -82,7 +81,7 @@ struct Socket {
LIST_HEAD(SocketPort, ports);
/* Only for INET6 sockets: issue IPV6_V6ONLY sockopt */
bool bind_ipv6_only;
SocketAddressBindIPv6Only bind_ipv6_only;
unsigned backlog;
usec_t timeout_usec;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment