summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/libreboot-utils/lib/state.c')
-rw-r--r--util/libreboot-utils/lib/state.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/util/libreboot-utils/lib/state.c b/util/libreboot-utils/lib/state.c
index 2fc22d52..2d2f6087 100644
--- a/util/libreboot-utils/lib/state.c
+++ b/util/libreboot-utils/lib/state.c
@@ -26,6 +26,9 @@ struct xstate *
xstart(int argc, char *argv[])
{
static int first_run = 1;
+ static char *dir = NULL;
+ static char *base = NULL;
+ char *realdir = NULL;
static struct xstate us = {
{
@@ -107,7 +110,15 @@ xstart(int argc, char *argv[])
us.f.tmp_fd = -1;
us.f.tname = NULL;
- if (new_tmpfile(&us.f.tmp_fd, &us.f.tname) < 0)
+ if ((realdir = realpath(us.f.fname, NULL)) == NULL)
+ err_no_cleanup(errno, "xstart: can't get realpath of %s",
+ us.f.fname);
+
+ if (fs_dirname_basename(realdir, &dir, &base, 0) < 0)
+ err_no_cleanup(errno, "xstart: don't know CWD of %s",
+ us.f.fname);
+
+ if (new_tmpfile(&us.f.tmp_fd, &us.f.tname, dir) < 0)
err_no_cleanup(errno, "%s", us.f.tname);
if (us.f.tname == NULL)