[systemd/f18] Fix parsing of envfiles with empty lines (#951866).
Michal Schmidt
michich at fedoraproject.org
Mon Apr 15 13:54:35 UTC 2013
commit 718276242461ed5146fcf79cd6f345f02b1819cf
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Mon Apr 15 15:42:32 2013 +0200
Fix parsing of envfiles with empty lines (#951866).
...nvfiles-do-not-skip-lines-following-empty.patch | 165 ++++++++++++++++++++
systemd.spec | 6 +-
2 files changed, 170 insertions(+), 1 deletions(-)
---
diff --git a/0014-fileio-in-envfiles-do-not-skip-lines-following-empty.patch b/0014-fileio-in-envfiles-do-not-skip-lines-following-empty.patch
new file mode 100644
index 0000000..fca45f1
--- /dev/null
+++ b/0014-fileio-in-envfiles-do-not-skip-lines-following-empty.patch
@@ -0,0 +1,165 @@
+From bdeb02a1dc5b545ff05415d570d44ae7fef95edc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek at in.waw.pl>
+Date: Sat, 13 Apr 2013 20:22:53 -0400
+Subject: [PATCH] fileio: in envfiles, do not skip lines following empty lines
+
+https://bugs.freedesktop.org/show_bug.cgi?id=63477
+(cherry picked from commit d3b6d0c21ea5a0d15ec6dbd8b8d179138b7463bc)
+---
+ src/binfmt/binfmt.c | 2 +-
+ src/journal/catalog.c | 2 +-
+ src/modules-load/modules-load.c | 2 +-
+ src/shared/conf-parser.c | 2 +-
+ src/shared/install.c | 2 +-
+ src/shared/util.h | 2 +-
+ src/sysctl/sysctl.c | 2 +-
+ src/test/test-unit-file.c | 31 +++++++++++++++++++++++++++++++
+ 8 files changed, 38 insertions(+), 7 deletions(-)
+
+diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
+index 9ca1e60..5a42b3d 100644
+--- a/src/binfmt/binfmt.c
++++ b/src/binfmt/binfmt.c
+@@ -110,7 +110,7 @@ static int apply_file(const char *path, bool ignore_enoent) {
+ p = strstrip(l);
+ if (!*p)
+ continue;
+- if (strchr(COMMENTS, *p))
++ if (strchr(COMMENTS "\n", *p))
+ continue;
+
+ k = apply_rule(p);
+diff --git a/src/journal/catalog.c b/src/journal/catalog.c
+index ebf0622..7681af6 100644
+--- a/src/journal/catalog.c
++++ b/src/journal/catalog.c
+@@ -180,7 +180,7 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
+ continue;
+ }
+
+- if (strchr(COMMENTS, line[0]))
++ if (strchr(COMMENTS "\n", line[0]))
+ continue;
+
+ if (empty_line &&
+diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
+index 9ee2603..b3f7af0 100644
+--- a/src/modules-load/modules-load.c
++++ b/src/modules-load/modules-load.c
+@@ -206,7 +206,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent
+ l = strstrip(line);
+ if (!*l)
+ continue;
+- if (strchr(COMMENTS, *l))
++ if (strchr(COMMENTS "\n", *l))
+ continue;
+
+ k = load_module(ctx, l);
+diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
+index fbacf98..fea2e56 100644
+--- a/src/shared/conf-parser.c
++++ b/src/shared/conf-parser.c
+@@ -174,7 +174,7 @@ static int parse_line(
+ if (!*l)
+ return 0;
+
+- if (strchr(COMMENTS, *l))
++ if (strchr(COMMENTS "\n", *l))
+ return 0;
+
+ if (startswith(l, ".include ")) {
+diff --git a/src/shared/install.c b/src/shared/install.c
+index 9e87039..230f18b 100644
+--- a/src/shared/install.c
++++ b/src/shared/install.c
+@@ -1699,7 +1699,7 @@ int unit_file_query_preset(UnitFileScope scope, const char *name) {
+ if (!*l)
+ continue;
+
+- if (strchr(COMMENTS, *l))
++ if (strchr(COMMENTS "\n", *l))
+ continue;
+
+ if (first_word(l, "enable")) {
+diff --git a/src/shared/util.h b/src/shared/util.h
+index 3885123..d3838e1 100644
+--- a/src/shared/util.h
++++ b/src/shared/util.h
+@@ -52,7 +52,7 @@ union dirent_storage {
+ #define WHITESPACE " \t\n\r"
+ #define NEWLINE "\n\r"
+ #define QUOTES "\"\'"
+-#define COMMENTS "#;\n"
++#define COMMENTS "#;"
+
+ #define FORMAT_BYTES_MAX 8
+
+diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
+index e0ba78a..db18dd9 100644
+--- a/src/sysctl/sysctl.c
++++ b/src/sysctl/sysctl.c
+@@ -149,7 +149,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
+ if (!*p)
+ continue;
+
+- if (strchr(COMMENTS, *p))
++ if (strchr(COMMENTS "\n", *p))
+ continue;
+
+ value = strchr(p, '=');
+diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
+index 3cf8463..1bf11e6 100644
+--- a/src/test/test-unit-file.c
++++ b/src/test/test-unit-file.c
+@@ -199,6 +199,17 @@ static void test_config_parse_exec(void) {
+ "#--nouser-config \\\n" \
+ "normal=line"
+
++#define env_file_4 \
++ "# Generated\n" \
++ "\n" \
++ "HWMON_MODULES=\"coretemp f71882fg\"\n" \
++ "\n" \
++ "# For compatibility reasons\n" \
++ "\n" \
++ "MODULE_0=coretemp\n" \
++ "MODULE_1=f71882fg"
++
++
+ static void test_load_env_file_1(void) {
+ char _cleanup_strv_free_ **data = NULL;
+ int r;
+@@ -251,6 +262,25 @@ static void test_load_env_file_3(void) {
+ unlink(name);
+ }
+
++static void test_load_env_file_4(void) {
++ char _cleanup_strv_free_ **data = NULL;
++ int r;
++
++ char name[] = "/tmp/test-load-env-file.XXXXXX";
++ int _cleanup_close_ fd = mkstemp(name);
++ assert(fd >= 0);
++ assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4));
++
++ r = load_env_file(name, NULL, &data);
++ assert(r == 0);
++ assert(streq(data[0], "HWMON_MODULES=coretemp f71882fg"));
++ assert(streq(data[1], "MODULE_0=coretemp"));
++ assert(streq(data[2], "MODULE_1=f71882fg"));
++ assert(data[3] == NULL);
++ unlink(name);
++}
++
++
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wnonnull"
+
+@@ -327,6 +357,7 @@ int main(int argc, char *argv[]) {
+ test_load_env_file_1();
+ test_load_env_file_2();
+ test_load_env_file_3();
++ test_load_env_file_4();
+ test_install_printf();
+
+ return 0;
diff --git a/systemd.spec b/systemd.spec
index 3f23618..b598721 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -13,7 +13,7 @@
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
Version: 201
-Release: 2%{?gitcommit:.git%{gitcommit}}%{?dist}.2
+Release: 2%{?gitcommit:.git%{gitcommit}}%{?dist}.3
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: A System and Service Manager
@@ -51,6 +51,7 @@ Patch0010: 0010-shutdown-print-a-nice-message-before-returning-to-in.patch
Patch0011: 0011-units-fix-some-left-over-mentions-of-remote-fs-setup.patch
Patch0012: 0012-logind-avoid-creating-stale-session-state-files.patch
Patch0013: 0013-F18-main-downgrade-message-about-failure-to-isolate-.patch
+Patch0014: 0014-fileio-in-envfiles-do-not-skip-lines-following-empty.patch
# kernel-install patch for grubby, drop if grubby is obsolete
Patch1000: kernel-install-grubby.patch
@@ -788,6 +789,9 @@ fi
%{_libdir}/pkgconfig/gudev-1.0*
%changelog
+* Mon Apr 15 2013 Michal Schmidt <mschmidt at redhat.com> - 201-2.fc18.3
+- Fix parsing of envfiles with empty lines (#951866).
+
* Thu Apr 11 2013 Michal Schmidt <mschmidt at redhat.com> - 201-2.fc18.2
- Do not create /var/log/journal in F18.
- Downgrade error message about non-isolatable default target to debug level.
More information about the scm-commits
mailing list