core: make NotifyAccess= and FileDescriptorStoreMax= available to transient services
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Jun 2017 17:17:38 +0000 (19:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 26 Jun 2017 13:14:41 +0000 (15:14 +0200)
This is helpful for debugging/testing #5606.

src/basic/unit-name.c
src/basic/unit-name.h
src/core/dbus-service.c
src/core/service.c
src/core/service.h
src/shared/bus-unit-util.c

index 0a6efa4..920ca0d 100644 (file)
@@ -1047,3 +1047,12 @@ static const char* const unit_dependency_table[_UNIT_DEPENDENCY_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);
+
+static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = {
+        [NOTIFY_NONE] = "none",
+        [NOTIFY_MAIN] = "main",
+        [NOTIFY_EXEC] = "exec",
+        [NOTIFY_ALL] = "all"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
index 44eadf0..0f164a6 100644 (file)
@@ -257,6 +257,15 @@ typedef enum UnitDependency {
         _UNIT_DEPENDENCY_INVALID = -1
 } UnitDependency;
 
+typedef enum NotifyAccess {
+        NOTIFY_NONE,
+        NOTIFY_ALL,
+        NOTIFY_MAIN,
+        NOTIFY_EXEC,
+        _NOTIFY_ACCESS_MAX,
+        _NOTIFY_ACCESS_INVALID = -1
+} NotifyAccess;
+
 typedef enum UnitNameFlags {
         UNIT_NAME_PLAIN = 1,      /* Allow foo.service */
         UNIT_NAME_INSTANCE = 2,   /* Allow foo@bar.service */
@@ -365,3 +374,6 @@ TimerState timer_state_from_string(const char *s) _pure_;
 
 const char *unit_dependency_to_string(UnitDependency i) _const_;
 UnitDependency unit_dependency_from_string(const char *s) _pure_;
+
+const char* notify_access_to_string(NotifyAccess i) _const_;
+NotifyAccess notify_access_from_string(const char *s) _pure_;
index 85b6731..6458ee5 100644 (file)
@@ -199,6 +199,39 @@ static int bus_service_set_transient_property(
 
                 return 1;
 
+        } else if (streq(name, "FileDescriptorStoreMax")) {
+                uint32_t u;
+
+                r = sd_bus_message_read(message, "u", &u);
+                if (r < 0)
+                        return r;
+
+                if (mode != UNIT_CHECK) {
+                        s->n_fd_store_max = (unsigned) u;
+                        unit_write_drop_in_private_format(UNIT(s), mode, name, "FileDescriptorStoreMax=%" PRIu32, u);
+                }
+
+                return 1;
+
+        } else if (streq(name, "NotifyAccess")) {
+                const char *t;
+                NotifyAccess k;
+
+                r = sd_bus_message_read(message, "s", &t);
+                if (r < 0)
+                        return r;
+
+                k = notify_access_from_string(t);
+                if (k < 0)
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid notify access setting %s", t);
+
+                if (mode != UNIT_CHECK) {
+                        s->notify_access = k;
+                        unit_write_drop_in_private_format(UNIT(s), mode, name, "NotifyAccess=%s", notify_access_to_string(s->notify_access));
+                }
+
+                return 1;
+
         } else if (streq(name, "ExecStart")) {
                 unsigned n = 0;
 
index e1f02cc..4c577db 100644 (file)
@@ -3583,15 +3583,6 @@ static const char* const service_exec_command_table[_SERVICE_EXEC_COMMAND_MAX] =
 
 DEFINE_STRING_TABLE_LOOKUP(service_exec_command, ServiceExecCommand);
 
-static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = {
-        [NOTIFY_NONE] = "none",
-        [NOTIFY_MAIN] = "main",
-        [NOTIFY_EXEC] = "exec",
-        [NOTIFY_ALL] = "all"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
-
 static const char* const notify_state_table[_NOTIFY_STATE_MAX] = {
         [NOTIFY_UNKNOWN] = "unknown",
         [NOTIFY_READY] = "ready",
index ff9cfae..f4ba604 100644 (file)
@@ -61,15 +61,6 @@ typedef enum ServiceExecCommand {
         _SERVICE_EXEC_COMMAND_INVALID = -1
 } ServiceExecCommand;
 
-typedef enum NotifyAccess {
-        NOTIFY_NONE,
-        NOTIFY_ALL,
-        NOTIFY_MAIN,
-        NOTIFY_EXEC,
-        _NOTIFY_ACCESS_MAX,
-        _NOTIFY_ACCESS_INVALID = -1
-} NotifyAccess;
-
 typedef enum NotifyState {
         NOTIFY_UNKNOWN,
         NOTIFY_READY,
@@ -218,9 +209,6 @@ ServiceType service_type_from_string(const char *s) _pure_;
 const char* service_exec_command_to_string(ServiceExecCommand i) _const_;
 ServiceExecCommand service_exec_command_from_string(const char *s) _pure_;
 
-const char* notify_access_to_string(NotifyAccess i) _const_;
-NotifyAccess notify_access_from_string(const char *s) _pure_;
-
 const char* notify_state_to_string(NotifyState i) _const_;
 NotifyState notify_state_from_string(const char *s) _pure_;
 
index 7b0bc82..7e446cb 100644 (file)
@@ -266,7 +266,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                               "StandardInput", "StandardOutput", "StandardError",
                               "Description", "Slice", "Type", "WorkingDirectory",
                               "RootDirectory", "SyslogIdentifier", "ProtectSystem",
-                              "ProtectHome", "SELinuxContext", "Restart", "RootImage"))
+                              "ProtectHome", "SELinuxContext", "Restart", "RootImage",
+                              "NotifyAccess"))
                 r = sd_bus_message_append(m, "v", "s", eq);
 
         else if (streq(field, "SyslogLevel")) {
@@ -389,6 +390,15 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
                 r = sd_bus_message_append(m, "v", "i", (int32_t) n);
 
+        } else if (streq(field, "FileDescriptorStoreMax")) {
+                unsigned u;
+
+                r = safe_atou(eq, &u);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to parse file descriptor store limit: %s", eq);
+
+                r = sd_bus_message_append(m, "v", "u", (uint32_t) u);
+
         } else if (STR_IN_SET(field, "Environment", "PassEnvironment")) {
                 const char *p;