chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dbus: fix serialization of calendar timers
[elogind.git]
/
src
/
core
/
execute.c
diff --git
a/src/core/execute.c
b/src/core/execute.c
index 76284700d7b3044b425775587b8296d62edd9038..7dc15044b4982866719a40801f0cee18378b903e 100644
(file)
--- a/
src/core/execute.c
+++ b/
src/core/execute.c
@@
-39,6
+39,7
@@
#include <linux/oom.h>
#include <sys/poll.h>
#include <linux/seccomp-bpf.h>
#include <linux/oom.h>
#include <sys/poll.h>
#include <linux/seccomp-bpf.h>
+#include <glob.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
@@
-1657,6
+1658,8
@@
int exec_context_load_environment(const ExecContext *c, char ***l) {
int k;
bool ignore = false;
char **p;
int k;
bool ignore = false;
char **p;
+ glob_t pglob;
+ int count, n;
fn = *i;
fn = *i;
@@
-1674,29
+1677,55
@@
int exec_context_load_environment(const ExecContext *c, char ***l) {
return -EINVAL;
}
return -EINVAL;
}
- if ((k = load_env_file(fn, &p)) < 0) {
+ /* Filename supports globbing, take all matching files */
+ zero(pglob);
+ errno = 0;
+ if (glob(fn, 0, NULL, &pglob) != 0) {
+ globfree(&pglob);
+ if (ignore)
+ continue;
+ strv_free(r);
+ return errno ? -errno : -EINVAL;
+ }
+ count = pglob.gl_pathc;
+ if (count == 0) {
+ globfree(&pglob);
if (ignore)
continue;
strv_free(r);
if (ignore)
continue;
strv_free(r);
- return
k
;
+ return
-EINVAL
;
}
}
+ for (n = 0; n < count; n++) {
+ k = load_env_file(pglob.gl_pathv[n], &p);
+ if (k < 0) {
+ if (ignore)
+ continue;
- if (r == NULL)
-
r = p
;
- else {
- char **m;
+ strv_free(r);
+
globfree(&pglob)
;
+ return k;
+ }
- m = strv_env_merge(2, r, p);
- strv_free(r);
- strv_free(p);
+ if (r == NULL)
+ r = p;
+ else {
+ char **m;
- if (!m)
- return -ENOMEM;
+ m = strv_env_merge(2, r, p);
+ strv_free(r);
+ strv_free(p);
- r = m;
+ if (!m) {
+ globfree(&pglob);
+ return -ENOMEM;
+ }
+
+ r = m;
+ }
}
}
+ globfree(&pglob);
}
*l = r;
}
*l = r;