From 8e03114518950ce9982e841cebada749dcf2c991 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 28 Mar 2023 15:01:18 +0200 Subject: [PATCH] patches: add support for running sysrepo-plugind in the foreground Signed-off-by: Joachim Wiberg --- .../sysrepo/sysrepo-plugind-foreground.patch | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 patches/sysrepo/sysrepo-plugind-foreground.patch diff --git a/patches/sysrepo/sysrepo-plugind-foreground.patch b/patches/sysrepo/sysrepo-plugind-foreground.patch new file mode 100644 index 00000000..827cfded --- /dev/null +++ b/patches/sysrepo/sysrepo-plugind-foreground.patch @@ -0,0 +1,64 @@ +commit 6fc440089353d76a9b8cb7c480402ee911a1387d +Author: Joachim Wiberg +Date: Tue Mar 28 10:37:53 2023 +0200 + + sysrepo-plugind: add support for running in foreground with syslog + + Signed-off-by: Joachim Wiberg + +diff --git a/src/executables/sysrepo-plugind.c b/src/executables/sysrepo-plugind.c +index bd584ed5..3079a855 100644 +--- a/src/executables/sysrepo-plugind.c ++++ b/src/executables/sysrepo-plugind.c +@@ -97,6 +97,7 @@ help_print(void) + " Change verbosity to a level (none, error, warning, info, debug) or\n" + " number (0, 1, 2, 3, 4).\n" + " -d, --debug Debug mode - is not daemonized and logs to stderr instead of syslog.\n" ++ " -n, --foreground Run in foreground and log to syslog.\n" + " -P, --plugin-install \n" + " Install a sysrepo-plugind plugin. The plugin is simply copied\n" + " to the designated plugin directory.\n" +@@ -200,6 +201,8 @@ daemon_init(int debug, sr_log_level_t log_level) + + if (debug) { + handle_signals(); ++ if (debug < 0) ++ goto done; + sr_log_stderr(log_level); + return; + } +@@ -240,6 +243,7 @@ daemon_init(int debug, sr_log_level_t log_level) + close(fd); + } + ++done: + /* set verbosity */ + sr_log_syslog("sysrepo-plugind", log_level); + } +@@ -459,6 +463,7 @@ main(int argc, char **argv) + {"version", no_argument, NULL, 'V'}, + {"verbosity", required_argument, NULL, 'v'}, + {"debug", no_argument, NULL, 'd'}, ++ {"foreground", no_argument, NULL, 'n'}, + {"plugin-install", required_argument, NULL, 'P'}, + {"pid-file", required_argument, NULL, 'p'}, + {"fatal-plugin-fail", no_argument, NULL, 'f'}, +@@ -467,7 +472,7 @@ main(int argc, char **argv) + + /* process options */ + opterr = 0; +- while ((opt = getopt_long(argc, argv, "hVv:dP:p:f", options, NULL)) != -1) { ++ while ((opt = getopt_long(argc, argv, "hVv:dnP:p:f", options, NULL)) != -1) { + switch (opt) { + case 'h': + version_print(); +@@ -499,6 +504,9 @@ main(int argc, char **argv) + case 'd': + debug = 1; + break; ++ case 'n': ++ debug = -1; ++ break; + case 'P': + /* plugin-install */ + if (get_plugins_dir(&plugins_dir)) {