]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #24242 from msekletar/terminate-idle-sessions
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Aug 2022 09:39:42 +0000 (11:39 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Aug 2022 09:39:42 +0000 (11:39 +0200)
Add option to stop idle sessions after specified timeout

1  2 
man/org.freedesktop.login1.xml
src/core/load-fragment.c

index dc67e0100904adef982b71525f0ebde025449326,277ba3ff85db7611480176658925df48f0083d5e..6781e1dcaaec50e59a5e8615d6a9a869a20e8c30
@@@ -245,6 -245,8 +245,8 @@@ node /org/freedesktop/login1 
        readonly t SessionsMax = ...;
        @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
        readonly t NCurrentSessions = ...;
+       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+       readonly t StopIdleSessionUSec = ...;
    };
    interface org.freedesktop.DBus.Peer { ... };
    interface org.freedesktop.DBus.Introspectable { ... };
  
      <!--property HandleHibernateKeyLongPress is not documented!-->
  
+     <!--property StopIdleSessionUSec is not documented!-->
      <!--Autogenerated cross-references for systemd.directives, do not edit-->
  
      <variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.login1.Manager"/>
  
      <variablelist class="dbus-property" generated="True" extra-ref="NCurrentSessions"/>
  
+     <variablelist class="dbus-property" generated="True" extra-ref="StopIdleSessionUSec"/>
      <!--End of Autogenerated section-->
  
      <refsect2>
@@@ -873,9 -879,8 +879,9 @@@ node /org/freedesktop/login1/seat/seat
      <refsect2>
        <title>Methods</title>
  
 -      <para><function>Terminate()</function> and <function>ActivateSession()</function> work similar to
 -      TerminateSeat(), ActivationSessionOnSeat() on the Manager object.</para>
 +      <para><function>Terminate()</function> and <function>ActivateSession()</function> work similarly to
 +      <function>TerminateSeat()</function> and <function>ActivationSessionOnSeat()</function> on the Manager
 +      object.</para>
  
        <para><function>SwitchTo()</function> switches to the session on the virtual terminal
        <varname>vtnr</varname>. <function>SwitchToNext()</function> and
        encoded in a structure consisting of the ID and the object path.</para>
  
        <para>The <varname>IdleHint</varname>, <varname>IdleSinceHint</varname>, and
 -      <varname>IdleSinceHintMonotonic</varname> properties encode the idle state, similar to the ones exposed
 -      on the <interfacename>Manager</interfacename> object, but specific for this seat.</para>
 +      <varname>IdleSinceHintMonotonic</varname> properties encode the idle state, similarly to the ones
 +      exposed on the <interfacename>Manager</interfacename> object, but specific for this seat.</para>
      </refsect2>
    </refsect1>
  
@@@ -1001,7 -1006,7 +1007,7 @@@ node /org/freedesktop/login1/user/_100
      <refsect2>
        <title>Methods</title>
  
 -      <para><function>Terminate()</function> and <function>Kill()</function> work similar to the
 +      <para><function>Terminate()</function> and <function>Kill()</function> work similarly to the
        <function>TerminateUser()</function> and <function>KillUser()</function> methods on the manager
        object.</para>
      </refsect2>
        user. Each structure consists of the ID and object path.</para>
  
        <para>The <varname>IdleHint</varname>, <varname>IdleSinceHint</varname>, and
 -      <varname>IdleSinceHintMonotonic</varname> properties encode the idle hint state of the user, similar to
 -      the <interfacename>Manager</interfacename>'s properties, but specific for this user.</para>
 +      <varname>IdleSinceHintMonotonic</varname> properties encode the idle hint state of the user, similarly
 +      to the <interfacename>Manager</interfacename>'s properties, but specific for this user.</para>
  
        <para>The <varname>Linger</varname> property shows whether lingering is enabled for this user.</para>
      </refsect2>
diff --combined src/core/load-fragment.c
index 6a7390a6f09abe6aec63f1f7f8260fb5cdc8079e,801e7d6ccc2611e25bc082e8672c82d1f53f9eb7..30d885e7a1d74819a3df6e1eca2464a71466d3d3
@@@ -148,36 -148,12 +148,36 @@@ DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(c
  DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint64_t, "Invalid block IO weight");
  DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight");
  DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t, "Invalid CPU weight");
 -DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares");
 +static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares");
  DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag");
  DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type");
  DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat, "Failed to parse status unit format");
  DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping, "Failed to parse timestamping precision");
  
 +int config_parse_cpu_shares(
 +                const char *unit,
 +                const char *filename,
 +                unsigned line,
 +                const char *section,
 +                unsigned section_line,
 +                const char *lvalue,
 +                int ltype,
 +                const char *rvalue,
 +                void *data,
 +                void *userdata) {
 +
 +        assert(filename);
 +        assert(lvalue);
 +        assert(rvalue);
 +
 +
 +        log_syntax(unit, LOG_WARNING, filename, line, 0,
 +                   "Unit uses %s=; please use CPUWeight= instead. Support for %s= will be removed soon.",
 +                   lvalue, lvalue);
 +
 +        return config_parse_cpu_shares_internal(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
 +}
 +
  bool contains_instance_specifier_superset(const char *s) {
          const char *p, *q;
          bool percent = false;
@@@ -843,9 -819,9 +843,9 @@@ int config_parse_kill_mode
  
          if (m == KILL_NONE)
                  log_syntax(unit, LOG_WARNING, filename, line, 0,
 -                           "Unit configured to use KillMode=none. "
 +                           "Unit uses KillMode=none. "
                             "This is unsafe, as it disables systemd's process lifecycle management for the service. "
 -                           "Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'. "
 +                           "Please update the service to use a safer KillMode=, such as 'mixed' or 'control-group'. "
                             "Support for KillMode=none is deprecated and will eventually be removed.");
  
          *k = m;
@@@ -2544,37 -2520,6 +2544,6 @@@ int config_parse_service_timeout_abort
          return 0;
  }
  
- int config_parse_sec_fix_0(
-                 const char *unit,
-                 const char *filename,
-                 unsigned line,
-                 const char *section,
-                 unsigned section_line,
-                 const char *lvalue,
-                 int ltype,
-                 const char *rvalue,
-                 void *data,
-                 void *userdata) {
-         usec_t *usec = data;
-         int r;
-         assert(filename);
-         assert(lvalue);
-         assert(rvalue);
-         assert(usec);
-         /* This is pretty much like config_parse_sec(), except that this treats a time of 0 as infinity, for
-          * compatibility with older versions of systemd where 0 instead of infinity was used as indicator to turn off a
-          * timeout. */
-         r = parse_sec_fix_0(rvalue, usec);
-         if (r < 0)
-                 log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue);
-         return 0;
- }
  int config_parse_user_group_compat(
                  const char *unit,
                  const char *filename,
@@@ -3938,11 -3883,9 +3907,11 @@@ int config_parse_memory_limit
                  c->memory_max = bytes;
          else if (streq(lvalue, "MemorySwapMax"))
                  c->memory_swap_max = bytes;
 -        else if (streq(lvalue, "MemoryLimit"))
 +        else if (streq(lvalue, "MemoryLimit")) {
 +                log_syntax(unit, LOG_WARNING, filename, line, 0,
 +                           "Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon.");
                  c->memory_limit = bytes;
 -        else
 +        else
                  return -EINVAL;
  
          return 0;
@@@ -4468,10 -4411,6 +4437,10 @@@ int config_parse_blockio_device_weight
          assert(lvalue);
          assert(rvalue);
  
 +        log_syntax(unit, LOG_WARNING, filename, line, 0,
 +                   "Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
 +                   lvalue, lvalue);
 +
          if (isempty(rvalue)) {
                  while (c->blockio_device_weights)
                          cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
@@@ -4547,10 -4486,6 +4516,10 @@@ int config_parse_blockio_bandwidth
          assert(lvalue);
          assert(rvalue);
  
 +        log_syntax(unit, LOG_WARNING, filename, line, 0,
 +                   "Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
 +                   lvalue, lvalue);
 +
          read = streq("BlockIOReadBandwidth", lvalue);
  
          if (isempty(rvalue)) {