]> err.no Git - systemd/commitdiff
socket: fix parsing of bind_ipv6_only
authorLennart Poettering <lennart@poettering.net>
Fri, 21 May 2010 21:41:25 +0000 (23:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 21 May 2010 21:41:25 +0000 (23:41 +0200)
fixme
src/dbus-socket.c
src/load-fragment.c
src/socket-util.c
src/socket-util.h
src/socket.c
src/socket.h

diff --git a/fixme b/fixme
index b8d0fca354027e641c4d65ac28335ae30095c5ba..08ba2dda1ba8b1710d6e68a9f475acbf172031b6 100644 (file)
--- a/fixme
+++ b/fixme
@@ -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:
 
index 2a2349c00d7348e49b569918f99e01df5b3e40c7..cb244a900349dba41d9cfbbdd5c99f674dd705a4 100644 (file)
@@ -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 */
index 5e0637de65ed42120a76b80ce367cfae3ff7d74f..3ebea4316fc4a86275191fe2e11e9302700ef3bf 100644 (file)
@@ -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;
 }
index 32f6bcb94196380049860485a0bab4102e29dbf6..0c9fc9f999e939b1c3fe188ef2b8c51a790433d1 100644 (file)
@@ -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);
index 14192167aa861ca6d35d1cd0c507d26ee9b6f081..993972c458380bdff080980f9be2c7bf18fea509 100644 (file)
@@ -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
index f9da353c1280a720b1f5c7f0b52db0a6b5c25339..4647d3174e47a0900e57f30e21470ccc63064a22 100644 (file)
@@ -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,
index 43d28d7e04d3a207873c41ece3c33977e410deaf..5aa5f2783c0dd0dd9c3580abb2aa67bff1b7bce3 100644 (file)
@@ -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;