Skip to content
Snippets Groups Projects

Wip/martyn/t7307 add relinquish options

Merged Martyn Welch requested to merge wip/martyn/T7307-Add-relinquish-options into apertis/v2021dev3
All threads resolved!

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Is there any specific patch that you had to poke? I mean, I don't want to review code that it's already upstream. :)

  • Martyn Welch added 1 commit

    added 1 commit

    • fdb6ff02 - Release systemd version 241-7~deb10u4co2

    Compare with previous version

  • I think the biggest changes from the upstream patches are:

    • Including util.h rather than errno-util.h, as the functionality hasn't been split out into a separate header file in our version.
    • Addition of ERRNO_IS_ACCEPT_AGAIN to varlink.c (it's not in the header file it's expected to be in, which doesn't exist in this version and since it's only used here, this seemed like the lowest impact way of handling this).
    • Working around the changed parameters for JSON_VARIANT_OBJECT_FOREACH (added call to json_variant_string(), based on how upstream was modified when macro changed)
    • Calls to inotify_add_watch factored out to function in newer versions of systemd.
  • Just realised I have a patch missing (not sure why it's passing testing, but it is :-/ )

    Just adding and retesting.

    Diff against upstream patches should be:

    diff -urN orig/fuzzer-add-varlink-fuzzer.patch deb/fuzzer-add-varlink-fuzzer.patch
    --- orig/fuzzer-add-varlink-fuzzer.patch	2020-08-31 10:36:48.508243729 +0100
    +++ deb/fuzzer-add-varlink-fuzzer.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,18 +1,19 @@
    -From d76846756364c9f67be960f7fb8459c10761f033 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Thu, 11 Apr 2019 18:42:37 +0200
    -Subject: [PATCH 3/8] fuzzer: add varlink fuzzer
    +Subject: fuzzer: add varlink fuzzer
     
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
    - src/fuzz/fuzz-varlink.c                       | 131 ++++++++++++++++++
    - src/fuzz/meson.build                          |   4 +
    - test/fuzz/fuzz-varlink/array                  | Bin 0 -> 5 bytes
    - test/fuzz/fuzz-varlink/do-something           | Bin 0 -> 81 bytes
    - test/fuzz/fuzz-varlink/huge-method            |   1 +
    - test/fuzz/fuzz-varlink/method-call            | Bin 0 -> 301 bytes
    - test/fuzz/fuzz-varlink/method-error           | Bin 0 -> 110 bytes
    - test/fuzz/fuzz-varlink/method-reply           | Bin 0 -> 142 bytes
    - ...t-d8a88bf4adea54537d21e3afb396e1a55c5b58bf | Bin 0 -> 10014 bytes
    + src/fuzz/fuzz-varlink.c                            | 131 +++++++++++++++++++++
    + src/fuzz/meson.build                               |   4 +
    + test/fuzz/fuzz-varlink/array                       | Bin 0 -> 5 bytes
    + test/fuzz/fuzz-varlink/do-something                | Bin 0 -> 81 bytes
    + test/fuzz/fuzz-varlink/huge-method                 |   1 +
    + test/fuzz/fuzz-varlink/method-call                 | Bin 0 -> 301 bytes
    + test/fuzz/fuzz-varlink/method-error                | Bin 0 -> 110 bytes
    + test/fuzz/fuzz-varlink/method-reply                | Bin 0 -> 142 bytes
    + ...imeout-d8a88bf4adea54537d21e3afb396e1a55c5b58bf | Bin 0 -> 10014 bytes
      9 files changed, 136 insertions(+)
      create mode 100644 src/fuzz/fuzz-varlink.c
      create mode 100644 test/fuzz/fuzz-varlink/array
    @@ -25,7 +26,7 @@
     
     diff --git a/src/fuzz/fuzz-varlink.c b/src/fuzz/fuzz-varlink.c
     new file mode 100644
    -index 0000000000..31c13e2bea
    +index 0000000..dd7fabc
     --- /dev/null
     +++ b/src/fuzz/fuzz-varlink.c
     @@ -0,0 +1,131 @@
    @@ -33,7 +34,7 @@
     +
     +#include <unistd.h>
     +
    -+#include "errno-util.h"
    ++#include "util.h"
     +#include "fd-util.h"
     +#include "fuzz.h"
     +#include "hexdecoct.h"
    @@ -161,7 +162,7 @@
     +        return 0;
     +}
     diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
    -index a6c6db372b..c88812d1de 100644
    +index f628001..0fa2e3e 100644
     --- a/src/fuzz/meson.build
     +++ b/src/fuzz/meson.build
     @@ -51,6 +51,10 @@ fuzzers += [
    @@ -177,28 +178,29 @@
                libshared],
     diff --git a/test/fuzz/fuzz-varlink/array b/test/fuzz/fuzz-varlink/array
     new file mode 100644
    -index 0000000000000000000000000000000000000000..f3ee40bcca777c00af494960ff3031f2d618b125
    -GIT binary patch
    -literal 5
    -Mcma!!j*Vpi00jvFaR2}S
    -
    -literal 0
    -HcmV?d00001
    -
    +index 0000000..f3ee40b
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/array
    +@@ -0,0 +1 @@
    ++[[]]
    +\ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/do-something b/test/fuzz/fuzz-varlink/do-something
     new file mode 100644
    -index 0000000000000000000000000000000000000000..3b124cb7d41abba22bc1b069e0303fd4470c309a
    -GIT binary patch
    -literal 81
    -zcmb>CQczIJO)bgDPf@Z`P|D2LD@iRb(R0ZU&IgHR=A|p?fRq#@79|1&Qj3a#%Bq1P
    -ZK%kVCpRc3<)RmN2qy!YI<*Mak008Rl7QO%g
    -
    -literal 0
    -HcmV?d00001
    -
    +index 0000000..3b124cb
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/do-something
    +@@ -0,0 +1,7 @@
    ++{
    ++  "method": "io.test.DoSomething",
    ++  "parameters": {
    ++     "foo" : "bar"
    ++  }
    ++}
    ++
    +\ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/huge-method b/test/fuzz/fuzz-varlink/huge-method
     new file mode 100644
    -index 0000000000..a480e417fc
    +index 0000000..a480e41
     --- /dev/null
     +++ b/test/fuzz/fuzz-varlink/huge-method
     @@ -0,0 +1 @@
    @@ -206,58 +208,105 @@
     \ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/method-call b/test/fuzz/fuzz-varlink/method-call
     new file mode 100644
    -index 0000000000000000000000000000000000000000..8654a7c06d30569327a3c2b86cf809ac3796e10a
    -GIT binary patch
    -literal 301
    -zcmZ{eK@Ni;5JkK86oz#r5m2yOPeK$a34%dLni%iiku>V2+yCeNH(ODbXjbv<NAxO@
    -z4;rhFoENL`6fN$h9g>w%_1;ZJry!&84m}TQkwF5f!V2UD31mYGLAiJa5LxfEiD^{F
    -zKH<2g8PDgid{$LWFuSVJtWmllQ%rD5SSJW&D0}wf0oaZ*X!YM#F@gCtdAEVAyPCU<
    -THmq%V+XycB&jzx+*o(&(yG%`2
    -
    -literal 0
    -HcmV?d00001
    -
    +index 0000000..8654a7c
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/method-call
    +@@ -0,0 +1,16 @@
    ++{
    ++  "method": "org.example.ftl.CalculateConfiguration",
    ++  "parameters": {
    ++    "current": {
    ++      "longitude": "27.13",
    ++      "latitude": "-12.4",
    ++      "distance": "48732498234"
    ++    },
    ++    "target": {
    ++      "longitude": "-48.7",
    ++      "latitude": "12.9",
    ++      "distance": "354667658787"
    ++    }
    ++  }
    ++}
    ++
    +\ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/method-error b/test/fuzz/fuzz-varlink/method-error
     new file mode 100644
    -index 0000000000000000000000000000000000000000..9ce68d8e4bf17efe29ad2681270ead269435e994
    -GIT binary patch
    -literal 110
    -zcmXwxQ3`+{5C!}86tdsp0lI|I4HkQbpcd-}L3H=*qu&{3ZeuM$WEYw&?Xo#sT#gJE
    -vHM^OG3l!o{^>N|4fyS>me$je%+m1Sn33>fC;S@ntx2C3C1E~AQJZ5+SxS1k&
    -
    -literal 0
    -HcmV?d00001
    -
    +index 0000000..9ce68d8
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/method-error
    +@@ -0,0 +1,7 @@
    ++{
    ++  "error": "org.example.ftl.ParameterOutOfRange",
    ++  "parameters": { 
    ++    "field": "current.distance"
    ++  }
    ++}
    ++
    +\ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/method-reply b/test/fuzz/fuzz-varlink/method-reply
     new file mode 100644
    -index 0000000000000000000000000000000000000000..cd4bd947ab80d10efaf8db55e083e56e7321248f
    -GIT binary patch
    -literal 142
    -zcmYL>K@LDL5Jjzfie}a}+EL;*O${NTGHM~xyBij4{^Gs7e<`hD^XwN&#5;8Q5+W?b
    -zb(qG3eVXF>VG;XA)C&M>(4w&j<y(kK>}Luo^7(kzx~6S@+y7@!SyMa28s0R^W|dWO
    -E1C;F}C;$Ke
    -
    -literal 0
    -HcmV?d00001
    -
    +index 0000000..cd4bd94
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/method-reply
    +@@ -0,0 +1,10 @@
    ++{
    ++  "parameters": {
    ++    "configuration": {
    ++      "speed": "32434234",
    ++      "trajectory": "686787",
    ++      "duration": "13256445"
    ++    }
    ++  }
    ++}
    ++
    +\ No newline at end of file
     diff --git a/test/fuzz/fuzz-varlink/timeout-d8a88bf4adea54537d21e3afb396e1a55c5b58bf b/test/fuzz/fuzz-varlink/timeout-d8a88bf4adea54537d21e3afb396e1a55c5b58bf
     new file mode 100644
    -index 0000000000000000000000000000000000000000..b0d8618298a986b6efdc10b1436ccf09a78c572a
    -GIT binary patch
    -literal 10014
    -zcmeI2v2KGf5Qa17DJ)MNQa1qyL)P>SI(D)Whgu>yB1Wnd(P!w~x9Gcc&)!$)(t|Xi
    -zO=$x|B^u5HAUMu<pU?P5Ku8DLhAx%8Gjlqj9muv!aZn!O5fVTGNTBTmF4`U-#)kxu
    -z01`j~NB{|Rn!s(Rv&ZC-01_ZH>$Q!->vp?sTTB=a5<mh-012EefyV|-+jOqzgwV^8
    -z!#ExEcU0(HudR${#U<_w*WrQhxSYcEE0XQZsFg{mEZn`xZv!VTXCt?C5=nc~|5s;k
    -z;OOv;h)|P+Ox?@nDpG7=BQ}-MECsJ>YT~@l()3$s`ViVtL=E6nnVw7tF#IX7dj1zW
    -zOcTIw;$k@HN+uG%y{TlqA1*>?X_Bb;Fn%zEG%|6hpFc{%Iolb6iM5P?X#Cu$Hx2UV
    -z5;UmmVpmptaT+&B00|(0ngqToj$E9)JpCX}Dwf}xouJu&C2&+855I}miu$OMXWB5U
    -z)|OqH8<YPzrQ@(tvF$~?1M4UYN&)^^#k*tfdBPj}!WX%WCnSSy*3bIA2E=#o3fyM`
    -bdMQ^|P>m2n13xEBUG928AjDV<hdpTT@w1QR
    -
    -literal 0
    -HcmV?d00001
    -
    --- 
    -2.28.0
    -
    +index 0000000..b0d8618
    +--- /dev/null
    ++++ b/test/fuzz/fuzz-varlink/timeout-d8a88bf4adea54537d21e3afb396e1a55c5b58bf
    +@@ -0,0 +1,43 @@
    ++                                                                                                                                                                                                                                     {"method":"                                                                                                                                                                                                                                             ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           [                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    "}                                                                                                                                                ����                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ��������������������������������������������itude": "-12.4",
    ++      "distance": "48732498234"
    ++  / },
    ++    "target": {
    ++   : "34.13",
    ++      "latitude": "-12.4",
    ++      "distance" },
    ++    "targe�
    ++  "method": "org.example.ftl.CalculateCon{
    ++  "method": 34"
    ++  / },
    ++    "tirget": {
    ++13",
    ++      "lat���������������������������������������������������������������itude": "-12.4",
    ++      "distance": "48732498234"
    ++  / },
    ++    "target": {
    ++   : "34.13",
    ++      "latitude": "-12.4",
    ++      "distance": "48732498234"
    ++  / },
    ++    "target": {figuration",
    ++  "parameters": {
    ++    "current": {
    ++      "longi�ude": "2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          7.13",
    ++      "latitude": "-12.4",
    ++      "distance": "48732498234"
    ++  / },
    ++    "target": {
    ++      "lo    "current":                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     {
    ++  "method": "orgԚxample.ftl.CalculateConfiguration",
    ++  "par                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 {
    ++  "method": "~org.example.ftl.CalculateConfiguration",
    ++  "parameters": {
    ++    "curio.test.DoSomethingrent": {
    ++      "longitude": "27.1.9",
    ++      "distance": "354667658787"
    ++    }
    ++  }
    ++}
    ++                                           e": "-48.7",
    ++
    ++      "longitud                                                                          343699775700
    +\ No newline at end of file
    diff -urN orig/journalctl-add-new-relinquish-and-smart-relinquish-option.patch deb/journalctl-add-new-relinquish-and-smart-relinquish-option.patch
    --- orig/journalctl-add-new-relinquish-and-smart-relinquish-option.patch	2020-08-31 10:36:48.588242257 +0100
    +++ deb/journalctl-add-new-relinquish-and-smart-relinquish-option.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,30 +1,31 @@
    -From c0dfcb318c28d87e1176a8ad87ac7cc4ecc50305 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Fri, 5 Apr 2019 18:21:02 +0200
    -Subject: [PATCH 7/8] journalctl: add new --relinquish and --smart-relinquish
    - options
    +Subject: journalctl: add new --relinquish and --smart-relinquish options
     
     The latter is identical to the former, but becomes a NOP if
     /var/log/journal is on the same mount as /, and thus during shutdown
     unmounting /var is not necessary and hence we can keep logging until the
     very end.
    +
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
    - src/journal/journalctl.c | 163 +++++++++++++++++++++++++--------------
    - 1 file changed, 104 insertions(+), 59 deletions(-)
    + src/journal/journalctl.c | 161 ++++++++++++++++++++++++++++++-----------------
    + 1 file changed, 103 insertions(+), 58 deletions(-)
     
     diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
    -index f08d0e8322..c2f967cef7 100644
    +index 910aced..5bde51d 100644
     --- a/src/journal/journalctl.c
     +++ b/src/journal/journalctl.c
    -@@ -52,6 +52,7 @@
    +@@ -51,6 +51,7 @@
    + #include "log.h"
      #include "logs-show.h"
    - #include "memory-util.h"
      #include "mkdir.h"
     +#include "mountpoint-util.h"
    - #include "nulstr-util.h"
      #include "pager.h"
      #include "parse-util.h"
    -@@ -168,6 +169,7 @@ static enum {
    + #include "path-util.h"
    +@@ -165,6 +166,7 @@ static enum {
              ACTION_UPDATE_CATALOG,
              ACTION_LIST_BOOTS,
              ACTION_FLUSH,
    @@ -32,7 +33,7 @@
              ACTION_SYNC,
              ACTION_ROTATE,
              ACTION_VACUUM,
    -@@ -369,6 +371,8 @@ static int help(void) {
    +@@ -361,6 +363,8 @@ static int help(void) {
                     "     --vacuum-time=TIME      Remove journal files older than specified time\n"
                     "     --verify                Verify journal file consistency\n"
                     "     --sync                  Synchronize unwritten journal messages to disk\n"
    @@ -41,7 +42,7 @@
                     "     --flush                 Flush all journal data from /run into /var\n"
                     "     --rotate                Request immediate rotation of the journal files\n"
                     "     --header                Show journal header information\n"
    -@@ -416,6 +420,8 @@ static int parse_argv(int argc, char *argv[]) {
    +@@ -407,6 +411,8 @@ static int parse_argv(int argc, char *argv[]) {
                      ARG_UTC,
                      ARG_SYNC,
                      ARG_FLUSH,
    @@ -50,7 +51,7 @@
                      ARG_ROTATE,
                      ARG_VACUUM_SIZE,
                      ARG_VACUUM_FILES,
    -@@ -425,65 +431,67 @@ static int parse_argv(int argc, char *argv[]) {
    +@@ -416,64 +422,66 @@ static int parse_argv(int argc, char *argv[]) {
              };
      
              static const struct option options[] = {
    @@ -89,7 +90,6 @@
     -                { "verify-key",     required_argument, NULL, ARG_VERIFY_KEY     },
     -                { "disk-usage",     no_argument,       NULL, ARG_DISK_USAGE     },
     -                { "cursor",         required_argument, NULL, 'c'                },
    --                { "cursor-file",    required_argument, NULL, ARG_CURSOR_FILE    },
     -                { "after-cursor",   required_argument, NULL, ARG_AFTER_CURSOR   },
     -                { "show-cursor",    no_argument,       NULL, ARG_SHOW_CURSOR    },
     -                { "since",          required_argument, NULL, 'S'                },
    @@ -148,7 +148,6 @@
     +                { "verify-key",           required_argument, NULL, ARG_VERIFY_KEY           },
     +                { "disk-usage",           no_argument,       NULL, ARG_DISK_USAGE           },
     +                { "cursor",               required_argument, NULL, 'c'                      },
    -+                { "cursor-file",          required_argument, NULL, ARG_CURSOR_FILE          },
     +                { "after-cursor",         required_argument, NULL, ARG_AFTER_CURSOR         },
     +                { "show-cursor",          no_argument,       NULL, ARG_SHOW_CURSOR          },
     +                { "since",                required_argument, NULL, 'S'                      },
    @@ -177,7 +176,7 @@
                      {}
              };
      
    -@@ -915,6 +923,35 @@ static int parse_argv(int argc, char *argv[]) {
    +@@ -897,6 +905,35 @@ static int parse_argv(int argc, char *argv[]) {
                              arg_action = ACTION_FLUSH;
                              break;
      
    @@ -213,7 +212,7 @@
                      case ARG_ROTATE:
                              arg_action = arg_action == ACTION_VACUUM ? ACTION_ROTATE_AND_VACUUM : ACTION_ROTATE;
                              break;
    -@@ -1925,6 +1962,10 @@ static int flush_to_var(void) {
    +@@ -1907,6 +1944,10 @@ static int flush_to_var(void) {
              return simple_varlink_call("--flush", "io.systemd.Journal.FlushToVar");
      }
      
    @@ -224,7 +223,7 @@
      static int rotate(void) {
              return simple_varlink_call("--rotate", "io.systemd.Journal.Rotate");
      }
    -@@ -2040,6 +2081,10 @@ int main(int argc, char *argv[]) {
    +@@ -2020,6 +2061,10 @@ int main(int argc, char *argv[]) {
                      r = flush_to_var();
                      goto finish;
      
    @@ -235,6 +234,3 @@
              case ACTION_SYNC:
                      r = sync_journal();
                      goto finish;
    --- 
    -2.28.0
    -
    diff -urN orig/journalctl-port-flush-sync-rotate-to-use-varlink-method-c.patch deb/journalctl-port-flush-sync-rotate-to-use-varlink-method-c.patch
    --- orig/journalctl-port-flush-sync-rotate-to-use-varlink-method-c.patch	2020-08-31 10:36:48.588242257 +0100
    +++ deb/journalctl-port-flush-sync-rotate-to-use-varlink-method-c.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,19 +1,19 @@
    -From 4f413af2a0a8fe6ec1efde405e61a4ff354974c5 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Thu, 4 Apr 2019 19:41:33 +0200
    -Subject: [PATCH 5/8] journalctl: port --flush/--sync/--rotate to use varlink
    - method calls
    +Subject: journalctl: port --flush/--sync/--rotate to use varlink method calls
     
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
    - src/journal/journalctl.c      | 152 ++++------------------------------
    - src/journal/journald-server.c |  58 ++++++++++++-
    - 2 files changed, 72 insertions(+), 138 deletions(-)
    + src/journal/journalctl.c      | 149 ++++--------------------------------------
    + src/journal/journald-server.c |  58 +++++++++++++++-
    + 2 files changed, 70 insertions(+), 137 deletions(-)
     
     diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
    -index 72c1622596..f08d0e8322 100644
    +index 14a02ed..910aced 100644
     --- a/src/journal/journalctl.c
     +++ b/src/journal/journalctl.c
    -@@ -67,6 +67,7 @@
    +@@ -65,6 +65,7 @@
      #include "tmpfile-util.h"
      #include "unit-name.h"
      #include "user-util.h"
    @@ -21,25 +21,10 @@
      
      #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE)
      
    -@@ -1901,156 +1902,35 @@ static int verify(sd_journal *j) {
    +@@ -1883,157 +1884,35 @@ static int verify(sd_journal *j) {
              return r;
      }
      
    --static int watch_run_systemd_journal(uint32_t mask) {
    --        _cleanup_close_ int watch_fd = -1;
    --
    --        (void) mkdir_p("/run/systemd/journal", 0755);
    --
    --        watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
    --        if (watch_fd < 0)
    --                return log_error_errno(errno, "Failed to create inotify object: %m");
    --
    --        if (inotify_add_watch(watch_fd, "/run/systemd/journal", mask) < 0)
    --                return log_error_errno(errno, "Failed to watch \"/run/systemd/journal\": %m");
    --
    --        return TAKE_FD(watch_fd);
    --}
    --
     -static int flush_to_var(void) {
     -        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
     -        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
    @@ -79,14 +64,21 @@
              if (r < 0)
     -                return log_error_errno(r, "Failed to kill journal service: %s", bus_error_message(&error, r));
     -
    --        watch_fd = watch_run_systemd_journal(IN_CREATE|IN_DONT_FOLLOW|IN_ONLYDIR);
    --        if (watch_fd < 0)
    --                return watch_fd;
    +-        mkdir_p("/run/systemd/journal", 0755);
     +                return log_error_errno(r, "Failed to connect to journal: %m");
      
    +-        watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
    +-        if (watch_fd < 0)
    +-                return log_error_errno(errno, "Failed to create inotify watch: %m");
    +-
    +-        r = inotify_add_watch(watch_fd, "/run/systemd/journal", IN_CREATE|IN_DONT_FOLLOW|IN_ONLYDIR);
    ++        r = varlink_call(link, method, NULL, NULL, &error, NULL);
    +         if (r < 0)
    +-                return log_error_errno(errno, "Failed to watch journal directory: %m");
    +-
     -        for (;;) {
     -                if (access("/run/systemd/journal/flushed", F_OK) >= 0)
    --                        return 0;
    +-                        break;
     -
     -                if (errno != ENOENT)
     -                        return log_error_errno(errno, "Failed to check for existence of /run/systemd/journal/flushed: %m");
    @@ -94,15 +86,14 @@
     -                r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
     -                if (r < 0)
     -                        return log_error_errno(r, "Failed to wait for event: %m");
    -+        r = varlink_call(link, method, NULL, NULL, &error, NULL);
    -+        if (r < 0)
    -+                return log_error_errno(r, "Failed to execute operation: %s", error);
    - 
    +-
     -                r = flush_fd(watch_fd);
     -                if (r < 0)
     -                        return log_error_errno(r, "Failed to flush inotify events: %m");
     -        }
    -+        return 0;
    ++                return log_error_errno(r, "Failed to execute operation: %s", error);
    + 
    +         return 0;
      }
      
     -static int send_signal_and_wait(int sig, const char *watch_path) {
    @@ -158,15 +149,23 @@
     -
     -                /* Let's install the inotify watch, if we didn't do that yet. */
     -                if (watch_fd < 0) {
    --                        watch_fd = watch_run_systemd_journal(IN_MOVED_TO|IN_DONT_FOLLOW|IN_ONLYDIR);
    +-
    +-                        mkdir_p("/run/systemd/journal", 0755);
    +-
    +-                        watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
     -                        if (watch_fd < 0)
    --                                return watch_fd;
    +-                                return log_error_errno(errno, "Failed to create inotify watch: %m");
    +-
    +-                        r = inotify_add_watch(watch_fd, "/run/systemd/journal", IN_MOVED_TO|IN_DONT_FOLLOW|IN_ONLYDIR);
    +-                        if (r < 0)
    +-                                return log_error_errno(errno, "Failed to watch journal directory: %m");
     -
     -                        /* Recheck the flag file immediately, so that we don't miss any event since the last check. */
     -                        continue;
     -                }
     -
    --                /* OK, all preparatory steps done, let's wait until inotify reports an event. */
    +-                /* OK, all preparatory steps done, let's wait until
    +-                 * inotify reports an event. */
     -
     -                r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
     -                if (r < 0)
    @@ -194,10 +193,10 @@
      
      static int wait_for_change(sd_journal *j, int poll_fd) {
     diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
    -index b5b11474f9..8ee7d78bae 100644
    +index dc4b259..2aad8e9 100644
     --- a/src/journal/journald-server.c
     +++ b/src/journal/journald-server.c
    -@@ -1825,8 +1825,37 @@ static int server_connect_notify(Server *s) {
    +@@ -1835,8 +1835,37 @@ static int server_connect_notify(Server *s) {
              return 0;
      }
      
    @@ -235,7 +234,7 @@
      
              assert(link);
              assert(s);
    -@@ -1835,9 +1864,34 @@ static int vl_method_synchronize(Varlink *link, JsonVariant *parameters, Varlink
    +@@ -1845,9 +1874,34 @@ static int vl_method_synchronize(Varlink *link, JsonVariant *parameters, Varlink
                      return varlink_error_invalid_parameter(link, parameters);
      
              log_info("Received client request to rotate journal.");
    @@ -272,6 +271,3 @@
      }
      
      static int vl_method_rotate(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
    --- 
    -2.28.0
    -
    diff -urN orig/journald-add-API-to-move-logging-from-var-to-run-again.patch deb/journald-add-API-to-move-logging-from-var-to-run-again.patch
    --- orig/journald-add-API-to-move-logging-from-var-to-run-again.patch	2020-08-31 10:36:48.588242257 +0100
    +++ deb/journald-add-API-to-move-logging-from-var-to-run-again.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,15 +1,17 @@
    -From b4e26d1d8e582d78e67ed766177f10e8e194404c Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Fri, 5 Apr 2019 18:20:25 +0200
    -Subject: [PATCH 6/8] journald: add API to move logging from /var to /run again
    +Subject: journald: add API to move logging from /var to /run again
     
     We now have this nice little Varlink API, let's beef it up a bit.
    +
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
    - src/journal/journald-server.c | 76 ++++++++++++++++++++++++++---------
    + src/journal/journald-server.c | 76 ++++++++++++++++++++++++++++++++-----------
      1 file changed, 57 insertions(+), 19 deletions(-)
     
     diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
    -index 8ee7d78bae..51e7dedad5 100644
    +index 2aad8e9..77eecee 100644
     --- a/src/journal/journald-server.c
     +++ b/src/journal/journald-server.c
     @@ -286,13 +286,14 @@ static bool flushed_flag_is_set(void) {
    @@ -148,7 +150,7 @@
              server_full_sync(s);
      
              return 0;
    -@@ -1924,6 +1946,21 @@ static int vl_method_flush_to_var(Varlink *link, JsonVariant *parameters, Varlin
    +@@ -1934,6 +1956,21 @@ static int vl_method_flush_to_var(Varlink *link, JsonVariant *parameters, Varlin
              return varlink_reply(link, NULL);
      }
      
    @@ -170,7 +172,7 @@
      static int server_open_varlink(Server *s) {
              int r;
      
    -@@ -1937,9 +1974,10 @@ static int server_open_varlink(Server *s) {
    +@@ -1947,9 +1984,10 @@ static int server_open_varlink(Server *s) {
      
              r = varlink_server_bind_method_many(
                              s->varlink_server,
    @@ -184,7 +186,7 @@
              if (r < 0)
                      return r;
      
    -@@ -2161,7 +2199,7 @@ int server_init(Server *s) {
    +@@ -2164,7 +2202,7 @@ int server_init(Server *s) {
      
              (void) client_context_acquire_default(s);
      
    @@ -193,6 +195,3 @@
      }
      
      void server_maybe_append_tags(Server *s) {
    --- 
    -2.28.0
    -
    diff -urN orig/journald-also-offer-flush-rotate-sync-as-varlink-method-c.patch deb/journald-also-offer-flush-rotate-sync-as-varlink-method-c.patch
    --- orig/journald-also-offer-flush-rotate-sync-as-varlink-method-c.patch	2020-08-31 10:36:48.580242403 +0100
    +++ deb/journald-also-offer-flush-rotate-sync-as-varlink-method-c.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,19 +1,20 @@
    -From 1ec23479e1b85b1f1bc29851ad934bd14d19b11c Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Thu, 4 Apr 2019 19:38:18 +0200
    -Subject: [PATCH 4/8] journald: also offer flush/rotate/sync as varlink method
    - calls
    +Subject: journald: also offer flush/rotate/sync as varlink method calls
     
     This makes the operations previously available via asynchronous signals
     also available as regular varlink method calls, i.e. with sane
     completion.
    +
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
    - src/journal/journald-server.c | 125 +++++++++++++++++++++++++++++++---
    + src/journal/journald-server.c | 125 ++++++++++++++++++++++++++++++++++++++----
      src/journal/journald-server.h |   3 +
      2 files changed, 117 insertions(+), 11 deletions(-)
     
     diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
    -index ee6c25541c..b5b11474f9 100644
    +index 7fe0f82..dc4b259 100644
     --- a/src/journal/journald-server.c
     +++ b/src/journal/journald-server.c
     @@ -1330,14 +1330,11 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void
    @@ -110,7 +111,7 @@
              return 0;
      }
      
    -@@ -1803,6 +1825,81 @@ static int server_connect_notify(Server *s) {
    +@@ -1813,6 +1835,81 @@ static int server_connect_notify(Server *s) {
              return 0;
      }
      
    @@ -203,7 +204,7 @@
              r = server_open_kernel_seqnum(s);
              if (r < 0)
                      return r;
    -@@ -2043,6 +2144,8 @@ void server_done(Server *s) {
    +@@ -2046,6 +2147,8 @@ void server_done(Server *s) {
      
              ordered_hashmap_free_with_destructor(s->user_journals, journal_file_close);
      
    @@ -213,18 +214,18 @@
              sd_event_source_unref(s->native_event_source);
              sd_event_source_unref(s->stdout_event_source);
     diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
    -index 5f0b3dd4ac..6ce9f269ff 100644
    +index 3f6b42d..b44e658 100644
     --- a/src/journal/journald-server.h
     +++ b/src/journal/journald-server.h
    -@@ -17,6 +17,7 @@ typedef struct Server Server;
    +@@ -16,6 +16,7 @@ typedef struct Server Server;
    + #include "journald-stream.h"
      #include "list.h"
      #include "prioq.h"
    - #include "time-util.h"
     +#include "varlink.h"
      
      typedef enum Storage {
              STORAGE_AUTO,
    -@@ -166,6 +167,8 @@ struct Server {
    +@@ -165,6 +166,8 @@ struct Server {
      
              ClientContext *my_context; /* the context of journald itself */
              ClientContext *pid1_context; /* the context of PID 1 */
    @@ -233,6 +234,3 @@
      };
      
      #define SERVER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))
    --- 
    -2.28.0
    -
    diff -urN orig/shared-add-minimal-varlink-implementation.patch deb/shared-add-minimal-varlink-implementation.patch
    --- orig/shared-add-minimal-varlink-implementation.patch	2020-08-31 10:36:48.464244539 +0100
    +++ deb/shared-add-minimal-varlink-implementation.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,7 +1,6 @@
    -From d41bd96f5454ea1a2746f96f202e79bf33ff7ae0 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Thu, 11 Apr 2019 18:46:54 +0200
    -Subject: [PATCH 1/8] shared: add minimal varlink implementation
    +Subject: shared: add minimal varlink implementation
     
     This adds a minimal Varlink (https://varlink.org/) implementation to our
     tree. Given that we already have a JSON logic it's an easy thing to add.
    @@ -39,19 +38,22 @@
        long before dbus is around)
     
     And there might be other cases similar to this.
    +
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
      src/shared/meson.build |    2 +
    - src/shared/varlink.c   | 2398 ++++++++++++++++++++++++++++++++++++++++
    - src/shared/varlink.h   |  162 +++
    - 3 files changed, 2562 insertions(+)
    + src/shared/varlink.c   | 2412 ++++++++++++++++++++++++++++++++++++++++++++++++
    + src/shared/varlink.h   |  162 ++++
    + 3 files changed, 2576 insertions(+)
      create mode 100644 src/shared/varlink.c
      create mode 100644 src/shared/varlink.h
     
     diff --git a/src/shared/meson.build b/src/shared/meson.build
    -index c80a67cdde..aa0423ccad 100644
    +index f6d1092..3a43168 100644
     --- a/src/shared/meson.build
     +++ b/src/shared/meson.build
    -@@ -164,6 +164,8 @@ shared_sources = files('''
    +@@ -153,6 +153,8 @@ shared_sources = files('''
              uid-range.c
              uid-range.h
              utmp-wtmp.h
    @@ -62,16 +64,15 @@
              vlan-util.c
     diff --git a/src/shared/varlink.c b/src/shared/varlink.c
     new file mode 100644
    -index 0000000000..3596bd2c87
    +index 0000000..2a89f88
     --- /dev/null
     +++ b/src/shared/varlink.c
    -@@ -0,0 +1,2398 @@
    +@@ -0,0 +1,2412 @@
     +/* SPDX-License-Identifier: LGPL-2.1+ */
     +
     +#include <sys/poll.h>
     +
     +#include "alloc-util.h"
    -+#include "errno-util.h"
     +#include "fd-util.h"
     +#include "hashmap.h"
     +#include "list.h"
    @@ -84,8 +85,19 @@
     +#include "time-util.h"
     +#include "umask-util.h"
     +#include "user-util.h"
    ++#include "util.h"
     +#include "varlink.h"
     +
    ++/* Transient errors we might get on accept() that we should ignore. As per error handling comment in
    ++ * the accept(2) man page. */
    ++static inline bool ERRNO_IS_ACCEPT_AGAIN(int r) {
    ++        return ERRNO_IS_DISCONNECT(r) ||
    ++                IN_SET(abs(r),
    ++                       EAGAIN,
    ++                       EINTR,
    ++                       EOPNOTSUPP);
    ++}
    ++
     +#define VARLINK_DEFAULT_CONNECTIONS_MAX 4096U
     +#define VARLINK_DEFAULT_CONNECTIONS_PER_UID_MAX 1024U
     +
    @@ -742,8 +754,7 @@
     +        _cleanup_(json_variant_unrefp) JsonVariant *parameters = NULL;
     +        VarlinkReplyFlags flags = 0;
     +        const char *error = NULL;
    -+        JsonVariant *e;
    -+        const char *k;
    ++        JsonVariant *k, *e;
     +        int r;
     +
     +        assert(v);
    @@ -759,8 +770,11 @@
     +                goto invalid;
     +
     +        JSON_VARIANT_OBJECT_FOREACH(k, e, v->current) {
    ++                const char *n;
     +
    -+                if (streq(k, "error")) {
    ++                assert_se(n = json_variant_string(k));
    ++
    ++                if (streq(n, "error")) {
     +                        if (error)
     +                                goto invalid;
     +                        if (!json_variant_is_string(e))
    @@ -769,7 +783,7 @@
     +                        error = json_variant_string(e);
     +                        flags |= VARLINK_REPLY_ERROR;
     +
    -+                } else if (streq(k, "parameters")) {
    ++                } else if (streq(n, "parameters")) {
     +                        if (parameters)
     +                                goto invalid;
     +                        if (!json_variant_is_object(e))
    @@ -777,7 +791,7 @@
     +
     +                        parameters = json_variant_ref(e);
     +
    -+                } else if (streq(k, "continues")) {
    ++                } else if (streq(n, "continues")) {
     +                        if (FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
     +                                goto invalid;
     +
    @@ -837,9 +851,8 @@
     +        _cleanup_(json_variant_unrefp) JsonVariant *parameters = NULL;
     +        VarlinkMethodFlags flags = 0;
     +        const char *method = NULL, *error;
    -+        JsonVariant *e;
    ++        JsonVariant *k, *e;
     +        VarlinkMethod callback;
    -+        const char *k;
     +        int r;
     +
     +        assert(v);
    @@ -853,8 +866,11 @@
     +                goto invalid;
     +
     +        JSON_VARIANT_OBJECT_FOREACH(k, e, v->current) {
    ++                const char *n;
    ++
    ++                assert_se(n = json_variant_string(k));
     +
    -+                if (streq(k, "method")) {
    ++                if (streq(n, "method")) {
     +                        if (method)
     +                                goto invalid;
     +                        if (!json_variant_is_string(e))
    @@ -862,7 +878,7 @@
     +
     +                        method = json_variant_string(e);
     +
    -+                } else if (streq(k, "parameters")) {
    ++                } else if (streq(n, "parameters")) {
     +                        if (parameters)
     +                                goto invalid;
     +                        if (!json_variant_is_object(e))
    @@ -870,7 +886,7 @@
     +
     +                        parameters = json_variant_ref(e);
     +
    -+                } else if (streq(k, "oneway")) {
    ++                } else if (streq(n, "oneway")) {
     +
     +                        if ((flags & (VARLINK_METHOD_ONEWAY|VARLINK_METHOD_MORE)) != 0)
     +                                goto invalid;
    @@ -881,7 +897,7 @@
     +                        if (json_variant_boolean(e))
     +                                flags |= VARLINK_METHOD_ONEWAY;
     +
    -+                } else if (streq(k, "more")) {
    ++                } else if (streq(n, "more")) {
     +
     +                        if ((flags & (VARLINK_METHOD_ONEWAY|VARLINK_METHOD_MORE)) != 0)
     +                                goto invalid;
    @@ -2466,7 +2482,7 @@
     +}
     diff --git a/src/shared/varlink.h b/src/shared/varlink.h
     new file mode 100644
    -index 0000000000..d96fa93619
    +index 0000000..d96fa93
     --- /dev/null
     +++ b/src/shared/varlink.h
     @@ -0,0 +1,162 @@
    @@ -2632,6 +2648,3 @@
     +#define VARLINK_ERROR_METHOD_NOT_FOUND "org.varlink.service.MethodNotFound"
     +#define VARLINK_ERROR_METHOD_NOT_IMPLEMENTED "org.varlink.service.MethodNotImplemented"
     +#define VARLINK_ERROR_INVALID_PARAMETER "org.varlink.service.InvalidParameter"
    --- 
    -2.28.0
    -
    diff -urN orig/tests-add-varlink-test.patch deb/tests-add-varlink-test.patch
    --- orig/tests-add-varlink-test.patch	2020-08-31 10:36:48.492244024 +0100
    +++ deb/tests-add-varlink-test.patch	2020-08-31 10:39:44.737656699 +0100
    @@ -1,19 +1,20 @@
    -From 635d059fa56dac2dee7a3f942de124bba92002c2 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Thu, 11 Apr 2019 18:47:10 +0200
    -Subject: [PATCH 2/8] tests: add varlink test
    +Subject: tests: add varlink test
     
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
      src/test/meson.build    |   4 +
    - src/test/test-varlink.c | 239 ++++++++++++++++++++++++++++++++++++++++
    + src/test/test-varlink.c | 239 ++++++++++++++++++++++++++++++++++++++++++++++++
      2 files changed, 243 insertions(+)
      create mode 100644 src/test/test-varlink.c
     
     diff --git a/src/test/meson.build b/src/test/meson.build
    -index e878d874af..ee6cdb6d54 100644
    +index 40154cf..9a50dc4 100644
     --- a/src/test/meson.build
     +++ b/src/test/meson.build
    -@@ -595,6 +595,10 @@ tests += [
    +@@ -567,6 +567,10 @@ tests += [
                libmount,
                libblkid]],
      
    @@ -26,7 +27,7 @@
               []],
     diff --git a/src/test/test-varlink.c b/src/test/test-varlink.c
     new file mode 100644
    -index 0000000000..fbfc72cd81
    +index 0000000..fbfc72c
     --- /dev/null
     +++ b/src/test/test-varlink.c
     @@ -0,0 +1,239 @@
    @@ -269,6 +270,3 @@
     +
     +        return 0;
     +}
    --- 
    -2.28.0
    -
    diff -urN orig/units-automatically-revert-to-run-logging-on-shutdown-if-.patch deb/units-automatically-revert-to-run-logging-on-shutdown-if-.patch
    --- orig/units-automatically-revert-to-run-logging-on-shutdown-if-.patch	2020-08-31 10:36:48.592242183 +0100
    +++ deb/units-automatically-revert-to-run-logging-on-shutdown-if-.patch	2020-08-31 12:07:07.702856993 +0100
    @@ -1,16 +1,17 @@
    -From 1e187d2dd52cbb4f0bb30e4d96acf7f72a145b91 Mon Sep 17 00:00:00 2001
     From: Lennart Poettering <lennart@poettering.net>
     Date: Fri, 5 Apr 2019 18:22:31 +0200
    -Subject: [PATCH 8/8] units: automatically revert to /run logging on shutdown
    - if necessary
    +Subject: units: automatically revert to /run logging on shutdown if necessary
     
     Fixes: #867
    +
    +Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
    +[Martyn Welch: Backported to systemd v241]
     ---
      units/systemd-journal-flush.service.in | 1 +
      1 file changed, 1 insertion(+)
     
     diff --git a/units/systemd-journal-flush.service.in b/units/systemd-journal-flush.service.in
    -index bacfe51d6f..29b006cba5 100644
    +index bacfe51..29b006c 100644
     --- a/units/systemd-journal-flush.service.in
     +++ b/units/systemd-journal-flush.service.in
     @@ -18,6 +18,7 @@ RequiresMountsFor=/var/log/journal
    @@ -21,6 +22,3 @@
      Type=oneshot
      RemainAfterExit=yes
      TimeoutSec=90s
    --- 
    -2.28.0
    -
  • Martyn Welch added 2 commits

    added 2 commits

    • 8bdc938b - journald: Backport support for --relinquish and --smart-relinquish options
    • 4ac5869a - Release systemd version 241-7~deb10u4co2

    Compare with previous version

  • Martyn Welch resolved all threads

    resolved all threads

  • Thank you!

  • Emanuele Aina mentioned in commit 8e058c97

    mentioned in commit 8e058c97

  • Emanuele Aina added 2 commits

    added 2 commits

    • 8e058c97 - journald: Backport support for --relinquish and --smart-relinquish options
    • 3975d0cd - Release systemd version 241-7~deb10u4co2

    Compare with previous version

  • I've edited the commit message on 8e058c97 to include your explanation from https://gitlab.apertis.org/pkg/target/systemd/-/merge_requests/26#note_20878

  • Emanuele Aina enabled an automatic merge when the pipeline for 3975d0cd succeeds

    enabled an automatic merge when the pipeline for 3975d0cd succeeds

  • merged

  • Denis Pynkin mentioned in commit f09e75bf

    mentioned in commit f09e75bf

  • Denis Pynkin mentioned in commit 2ce89c63

    mentioned in commit 2ce89c63

  • Denis Pynkin mentioned in merge request !40 (merged)

    mentioned in merge request !40 (merged)

  • Please register or sign in to reply
    Loading