b11b5f
From 69ec7c9170e29fdf745fa282448d051edd1f88b2 Mon Sep 17 00:00:00 2001
b11b5f
From: Michal Sekletar <msekleta@redhat.com>
b11b5f
Date: Tue, 9 Aug 2022 11:41:04 +0200
b11b5f
Subject: [PATCH] core/load-fragment: move config_parse_sec_fix_0 to src/shared
b11b5f
b11b5f
(cherry picked from commit 4ee8176fe33bbcd0971c4583a0e7d1cc2a64ac06)
b11b5f
b11b5f
Related: #2122288
b11b5f
---
b11b5f
 src/core/load-fragment.c | 33 ---------------------------------
b11b5f
 src/core/load-fragment.h |  1 -
b11b5f
 src/shared/conf-parser.c |  2 ++
b11b5f
 src/shared/conf-parser.h |  1 +
b11b5f
 4 files changed, 3 insertions(+), 34 deletions(-)
b11b5f
b11b5f
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
b11b5f
index c0b1fd4f91..53de7ff5e9 100644
b11b5f
--- a/src/core/load-fragment.c
b11b5f
+++ b/src/core/load-fragment.c
b11b5f
@@ -1865,39 +1865,6 @@ int config_parse_service_timeout(
b11b5f
         return 0;
b11b5f
 }
b11b5f
 
b11b5f
-int config_parse_sec_fix_0(
b11b5f
-                const char *unit,
b11b5f
-                const char *filename,
b11b5f
-                unsigned line,
b11b5f
-                const char *section,
b11b5f
-                unsigned section_line,
b11b5f
-                const char *lvalue,
b11b5f
-                int ltype,
b11b5f
-                const char *rvalue,
b11b5f
-                void *data,
b11b5f
-                void *userdata) {
b11b5f
-
b11b5f
-        usec_t *usec = data;
b11b5f
-        int r;
b11b5f
-
b11b5f
-        assert(filename);
b11b5f
-        assert(lvalue);
b11b5f
-        assert(rvalue);
b11b5f
-        assert(usec);
b11b5f
-
b11b5f
-        /* This is pretty much like config_parse_sec(), except that this treats a time of 0 as infinity, for
b11b5f
-         * compatibility with older versions of systemd where 0 instead of infinity was used as indicator to turn off a
b11b5f
-         * timeout. */
b11b5f
-
b11b5f
-        r = parse_sec_fix_0(rvalue, usec);
b11b5f
-        if (r < 0) {
b11b5f
-                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue);
b11b5f
-                return 0;
b11b5f
-        }
b11b5f
-
b11b5f
-        return 0;
b11b5f
-}
b11b5f
-
b11b5f
 int config_parse_user_group_compat(
b11b5f
                 const char *unit,
b11b5f
                 const char *filename,
b11b5f
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
b11b5f
index f9d34d484d..b964737f9e 100644
b11b5f
--- a/src/core/load-fragment.h
b11b5f
+++ b/src/core/load-fragment.h
b11b5f
@@ -95,7 +95,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_bus_name);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_exec_utmp_mode);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_working_directory);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_fdname);
b11b5f
-CONFIG_PARSER_PROTOTYPE(config_parse_sec_fix_0);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_user_group_compat);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_user_group_strv_compat);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_restrict_namespaces);
b11b5f
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
b11b5f
index 1f40f00c72..414dde2e3d 100644
b11b5f
--- a/src/shared/conf-parser.c
b11b5f
+++ b/src/shared/conf-parser.c
b11b5f
@@ -1286,3 +1286,5 @@ int config_parse_permille(const char* unit,
b11b5f
 
b11b5f
         return 0;
b11b5f
 }
b11b5f
+
b11b5f
+DEFINE_CONFIG_PARSE_PTR(config_parse_sec_fix_0, parse_sec_fix_0, usec_t, "Failed to parse time value");
b11b5f
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
b11b5f
index 375b2e5a74..56fd302db8 100644
b11b5f
--- a/src/shared/conf-parser.h
b11b5f
+++ b/src/shared/conf-parser.h
b11b5f
@@ -142,6 +142,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_join_controllers);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_mtu);
b11b5f
 CONFIG_PARSER_PROTOTYPE(config_parse_rlimit);
b11b5f
+CONFIG_PARSER_PROTOTYPE(config_parse_sec_fix_0);
b11b5f
 
b11b5f
 typedef enum Disabled {
b11b5f
         DISABLED_CONFIGURATION,