diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch b/meta/recipes-core/systemd/systemd/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch new file mode 100644 index 0000000000..765e4767fd --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch | |||
@@ -0,0 +1,154 @@ | |||
1 | From f8a239b182158ca0a537ba053cb0e6bad9c3a2fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Chen Qi <Qi.Chen@windriver.com> | ||
3 | Date: Mon, 25 Feb 2019 14:56:21 +0800 | ||
4 | Subject: [PATCH 07/24] don't fail if GLOB_BRACE and GLOB_ALTDIRFUNC is not | ||
5 | defined | ||
6 | |||
7 | If the standard library doesn't provide brace | ||
8 | expansion users just won't get it. | ||
9 | |||
10 | Dont use GNU GLOB extentions on non-glibc systems | ||
11 | |||
12 | Conditionalize use of GLOB_ALTDIRFUNC | ||
13 | |||
14 | Upstream-Status: Inappropriate [musl specific] | ||
15 | |||
16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
17 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
18 | --- | ||
19 | src/basic/glob-util.c | 12 +++++++++++- | ||
20 | src/test/test-glob-util.c | 17 +++++++++++++++-- | ||
21 | src/tmpfiles/tmpfiles.c | 9 +++++++++ | ||
22 | 3 files changed, 35 insertions(+), 3 deletions(-) | ||
23 | |||
24 | diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c | ||
25 | index 9fac676..962d8b9 100644 | ||
26 | --- a/src/basic/glob-util.c | ||
27 | +++ b/src/basic/glob-util.c | ||
28 | @@ -10,6 +10,11 @@ | ||
29 | #include "macro.h" | ||
30 | #include "path-util.h" | ||
31 | #include "strv.h" | ||
32 | +/* Don't fail if the standard library | ||
33 | + * doesn't provide brace expansion */ | ||
34 | +#ifndef GLOB_BRACE | ||
35 | +#define GLOB_BRACE 0 | ||
36 | +#endif | ||
37 | |||
38 | static void closedir_wrapper(void* v) { | ||
39 | (void) closedir(v); | ||
40 | @@ -18,6 +23,7 @@ static void closedir_wrapper(void* v) { | ||
41 | int safe_glob(const char *path, int flags, glob_t *pglob) { | ||
42 | int k; | ||
43 | |||
44 | +#ifdef GLOB_ALTDIRFUNC | ||
45 | /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */ | ||
46 | assert(!(flags & GLOB_ALTDIRFUNC)); | ||
47 | |||
48 | @@ -31,10 +37,14 @@ int safe_glob(const char *path, int flags, glob_t *pglob) { | ||
49 | pglob->gl_lstat = lstat; | ||
50 | if (!pglob->gl_stat) | ||
51 | pglob->gl_stat = stat; | ||
52 | +#endif | ||
53 | |||
54 | errno = 0; | ||
55 | +#ifdef GLOB_ALTDIRFUNC | ||
56 | k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob); | ||
57 | - | ||
58 | +#else | ||
59 | + k = glob(path, flags, NULL, pglob); | ||
60 | +#endif | ||
61 | if (k == GLOB_NOMATCH) | ||
62 | return -ENOENT; | ||
63 | if (k == GLOB_NOSPACE) | ||
64 | diff --git a/src/test/test-glob-util.c b/src/test/test-glob-util.c | ||
65 | index b4f4144..955b3ba 100644 | ||
66 | --- a/src/test/test-glob-util.c | ||
67 | +++ b/src/test/test-glob-util.c | ||
68 | @@ -12,6 +12,11 @@ | ||
69 | #include "macro.h" | ||
70 | #include "rm-rf.h" | ||
71 | #include "tmpfile-util.h" | ||
72 | +/* Don't fail if the standard library | ||
73 | + * doesn't provide brace expansion */ | ||
74 | +#ifndef GLOB_BRACE | ||
75 | +#define GLOB_BRACE 0 | ||
76 | +#endif | ||
77 | |||
78 | static void test_glob_exists(void) { | ||
79 | char name[] = "/tmp/test-glob_exists.XXXXXX"; | ||
80 | @@ -38,25 +43,33 @@ static void closedir_wrapper(void* v) { | ||
81 | static void test_glob_no_dot(void) { | ||
82 | char template[] = "/tmp/test-glob-util.XXXXXXX"; | ||
83 | const char *fn; | ||
84 | - | ||
85 | _cleanup_globfree_ glob_t g = { | ||
86 | +#ifdef GLOB_ALTDIRFUNC | ||
87 | .gl_closedir = closedir_wrapper, | ||
88 | .gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot, | ||
89 | .gl_opendir = (void *(*)(const char *)) opendir, | ||
90 | .gl_lstat = lstat, | ||
91 | .gl_stat = stat, | ||
92 | +#endif | ||
93 | }; | ||
94 | - | ||
95 | int r; | ||
96 | |||
97 | assert_se(mkdtemp(template)); | ||
98 | |||
99 | fn = strjoina(template, "/*"); | ||
100 | +#ifdef GLOB_ALTDIRFUNC | ||
101 | r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g); | ||
102 | +#else | ||
103 | + r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g); | ||
104 | +#endif | ||
105 | assert_se(r == GLOB_NOMATCH); | ||
106 | |||
107 | fn = strjoina(template, "/.*"); | ||
108 | +#ifdef GLOB_ALTDIRFUNC | ||
109 | r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g); | ||
110 | +#else | ||
111 | + r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g); | ||
112 | +#endif | ||
113 | assert_se(r == GLOB_NOMATCH); | ||
114 | |||
115 | (void) rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL); | ||
116 | diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c | ||
117 | index b66765b..11dbbf4 100644 | ||
118 | --- a/src/tmpfiles/tmpfiles.c | ||
119 | +++ b/src/tmpfiles/tmpfiles.c | ||
120 | @@ -60,6 +60,11 @@ | ||
121 | #include "umask-util.h" | ||
122 | #include "user-util.h" | ||
123 | #include "util.h" | ||
124 | +/* Don't fail if the standard library | ||
125 | + * doesn't provide brace expansion */ | ||
126 | +#ifndef GLOB_BRACE | ||
127 | +#define GLOB_BRACE 0 | ||
128 | +#endif | ||
129 | |||
130 | /* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates | ||
131 | * them in the file system. This is intended to be used to create | ||
132 | @@ -1853,7 +1858,9 @@ finish: | ||
133 | |||
134 | static int glob_item(Item *i, action_t action) { | ||
135 | _cleanup_globfree_ glob_t g = { | ||
136 | +#ifdef GLOB_ALTDIRFUNC | ||
137 | .gl_opendir = (void *(*)(const char *)) opendir_nomod, | ||
138 | +#endif | ||
139 | }; | ||
140 | int r = 0, k; | ||
141 | char **fn; | ||
142 | @@ -1873,7 +1880,9 @@ static int glob_item(Item *i, action_t action) { | ||
143 | |||
144 | static int glob_item_recursively(Item *i, fdaction_t action) { | ||
145 | _cleanup_globfree_ glob_t g = { | ||
146 | +#ifdef GLOB_ALTDIRFUNC | ||
147 | .gl_opendir = (void *(*)(const char *)) opendir_nomod, | ||
148 | +#endif | ||
149 | }; | ||
150 | int r = 0, k; | ||
151 | char **fn; | ||
152 | -- | ||
153 | 2.7.4 | ||
154 | |||