diff options
Diffstat (limited to 'util/libreboot-utils/mkhtemp.c')
| -rw-r--r-- | util/libreboot-utils/mkhtemp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/util/libreboot-utils/mkhtemp.c b/util/libreboot-utils/mkhtemp.c index 1f7c8b79..bcbc63a9 100644 --- a/util/libreboot-utils/mkhtemp.c +++ b/util/libreboot-utils/mkhtemp.c @@ -78,6 +78,8 @@ main(int argc, char *argv[]) int type = MKHTEMP_FILE; size_t len; + char *rp; + #if defined (PATH_LEN) && \ (PATH_LEN) >= 256 size_t maxlen = PATH_LEN; @@ -85,6 +87,8 @@ main(int argc, char *argv[]) size_t maxlen = 4096; #endif + char resolved[maxlen]; + if (lbgetprogname(argv[0]) == NULL) err_no_cleanup(errno, "could not set progname"); @@ -119,6 +123,16 @@ main(int argc, char *argv[]) err_no_cleanup(EINVAL, "usage: mkhtemp [-d] [-p dir] [template]\n"); + + if (tmpdir != NULL) { + rp = realpath(tmpdir, resolved); + if (rp == NULL) + err_no_cleanup(errno, + "realpath: %s", tmpdir); + + tmpdir = resolved; + } + if (new_tmp_common(&fd, &s, type, tmpdir) < 0) err_no_cleanup(errno, "%s", s); |
