diff options
author | José Bollo <jose.bollo@iot.bzh> | 2015-12-11 14:57:32 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2015-12-11 14:57:32 +0100 |
commit | 9ab266df6642c6e930e03b3024d7c3d53ef88bbc (patch) | |
tree | 95c7686ad33af3c012a02412938f9b2c0191dc7b /src/wgtpkg-xmlsec.c | |
parent | 26d75de504d808191dbadc9a735009a214a789b0 (diff) |
don't change of directory anymore
Change-Id: I9f5906d3e053b3fa0f3000d07c4af3f666fe079a
Diffstat (limited to 'src/wgtpkg-xmlsec.c')
-rw-r--r-- | src/wgtpkg-xmlsec.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/wgtpkg-xmlsec.c b/src/wgtpkg-xmlsec.c index 843ea2b..a403b77 100644 --- a/src/wgtpkg-xmlsec.c +++ b/src/wgtpkg-xmlsec.c @@ -21,6 +21,7 @@ #include <dirent.h> #include <string.h> #include <assert.h> +#include <fcntl.h> #include <libxml/tree.h> #include <xmlsec/xmlsec.h> @@ -53,6 +54,7 @@ static int file_match_cb(const char *uri) static void *file_open_cb(const char *file) { struct filedesc *fdesc; + int fd; FILE *f; fdesc = file_of_name(file); @@ -61,10 +63,13 @@ static void *file_open_cb(const char *file) return NULL; } - f = fopen(file, "r"); - if (f == NULL) + fd = openat(workdirfd, file, O_RDONLY); + f = fd < 0 ? NULL : fdopen(fd, "r"); + if (f == NULL) { syslog(LOG_ERR, "can't open file %s for reading", file); - else + if (fd >= 0) + close(fd); + } else fdesc->flags |= flag_opened; return f; |