[systemd-commits] 2 commits - fixme src/dbus-socket.c src/dbus-unit.c src/load-fragment.c src/socket.c src/socket.h src/socket-util.c src/socket-util.h src/unit.c src/unit.h

Lennart Poettering lennart at kemper.freedesktop.org
Fri May 21 14:42:00 PDT 2010


 fixme               |   10 ++++------
 src/dbus-socket.c   |    6 +++++-
 src/dbus-unit.c     |    3 +++
 src/load-fragment.c |   18 ++++++++++++------
 src/socket-util.c   |    8 ++++++++
 src/socket-util.h   |    7 ++++++-
 src/socket.c        |    2 +-
 src/socket.h        |    3 +--
 src/unit.c          |    6 ++++--
 src/unit.h          |    3 +++
 10 files changed, 47 insertions(+), 19 deletions(-)

New commits:
commit bc0f8771f23dc3952bf4b06301dc842ba625a0f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 21 23:41:54 2010 +0200

    unit: add simple only-by-dependency flag for units

diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index e3e1be1..5c474c0 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -281,6 +281,9 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
                 int r;
                 char *path;
 
+                if (job_type == JOB_START && u->meta.only_by_dependency)
+                        return bus_send_error_reply(m, message, NULL, -EPERM);
+
                 if (!dbus_message_get_args(
                                     message,
                                     &error,
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 3ebea43..70b6923 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1268,6 +1268,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "After",                  config_parse_deps,            UINT_TO_PTR(UNIT_AFTER),                         "Unit"    },
                 { "RecursiveStop",          config_parse_bool,            &u->meta.recursive_stop,                         "Unit"    },
                 { "StopWhenUnneeded",       config_parse_bool,            &u->meta.stop_when_unneeded,                     "Unit"    },
+                { "OnlyByDependency",       config_parse_bool,            &u->meta.only_by_dependency,                     "Unit"    },
 
                 { "PIDFile",                config_parse_path,            &u->service.pid_file,                            "Service" },
                 { "ExecStartPre",           config_parse_exec,            u->service.exec_command+SERVICE_EXEC_START_PRE,  "Service" },
diff --git a/src/unit.c b/src/unit.c
index 012edd4..b38be31 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -593,7 +593,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
                 "%s\tActive Enter Timestamp: %s\n"
                 "%s\tActive Exit Timestamp: %s\n"
                 "%s\tInactive Enter Timestamp: %s\n"
-                "%s\tGC Check Good: %s\n",
+                "%s\tGC Check Good: %s\n"
+                "%s\tOnly By Dependency: %s\n",
                 prefix, u->meta.id,
                 prefix, unit_description(u),
                 prefix, strna(u->meta.instance),
@@ -603,7 +604,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp)),
                 prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp)),
                 prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp)),
-                prefix, yes_no(unit_check_gc(u)));
+                prefix, yes_no(unit_check_gc(u)),
+                prefix, yes_no(u->meta.only_by_dependency));
 
         SET_FOREACH(t, u->meta.names, i)
                 fprintf(f, "%s\tName: %s\n", prefix, t);
diff --git a/src/unit.h b/src/unit.h
index 8f9d9e9..d8be185 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -136,6 +136,9 @@ struct Meta {
         UnitLoadState load_state;
         Unit *merged_into;
 
+        /* Refuse manual starting, allow starting only indirectly via dependency. */
+        bool only_by_dependency;
+
         char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
         char *instance;
 
commit c0120d992ce5ab004d9be5ff6ca15e5fe17f9884
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 21 23:41:25 2010 +0200

    socket: fix parsing of bind_ipv6_only

diff --git a/fixme b/fixme
index b8d0fca..08ba2dd 100644
--- 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:
 
diff --git a/src/dbus-socket.c b/src/dbus-socket.c
index 2a2349c..cb244a9 100644
--- a/src/dbus-socket.c
+++ b/src/dbus-socket.c
@@ -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 */
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 5e0637d..3ebea43 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -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;
 }
diff --git a/src/socket-util.c b/src/socket-util.c
index 32f6bcb..0c9fc9f 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -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);
diff --git a/src/socket-util.h b/src/socket-util.h
index 1419216..993972c 100644
--- a/src/socket-util.h
+++ b/src/socket-util.h
@@ -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
diff --git a/src/socket.c b/src/socket.c
index f9da353..4647d31 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -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,
diff --git a/src/socket.h b/src/socket.h
index 43d28d7..5aa5f27 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -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;


More information about the systemd-commits mailing list