aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/wgtpkg-pack.c8
-rw-r--r--src/wgtpkg-workdir.c8
2 files changed, 13 insertions, 3 deletions
diff --git a/src/wgtpkg-pack.c b/src/wgtpkg-pack.c
index 80ad87a..5a81d7e 100644
--- a/src/wgtpkg-pack.c
+++ b/src/wgtpkg-pack.c
@@ -161,13 +161,17 @@ int main(int ac, char **av)
/* compute absolutes paths */
x = realpath(wgtfile, NULL);
if (x == NULL) {
- ERROR("realpath failed for %s",wgtfile);
+ ERROR("realpath failed for %s", wgtfile);
return 1;
}
wgtfile = x;
/* set and enter the workdir */
- if (set_workdir(directory, 0))
+ if (chdir(directory)) {
+ ERROR("failed to enter directory %s", directory);
+ return 1;
+ }
+ if (set_workdir(".", 0))
return 1;
diff --git a/src/wgtpkg-workdir.c b/src/wgtpkg-workdir.c
index c0fb6aa..ea37666 100644
--- a/src/wgtpkg-workdir.c
+++ b/src/wgtpkg-workdir.c
@@ -61,7 +61,7 @@ static void put_workdir(int fd, const char *name, size_t length)
workdir[1] = 0;
workdirfd = AT_FDCWD;
} else {
-
+
assert(length < sizeof workdir);
memcpy(workdir, name, 1 + length);
workdirfd = fd;
@@ -81,6 +81,12 @@ int set_workdir(const char *name, int create)
return -1;
}
+ /* check if . */
+ if (length == 1 && name[0] == '.') {
+ put_workdir(AT_FDCWD, name, length);
+ return 0;
+ }
+
/* opens the directory */
dirfd = openat(AT_FDCWD, name, O_PATH|O_DIRECTORY|O_RDONLY);
if (dirfd < 0) {