summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/mkhtemp.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/libreboot-utils/lib/mkhtemp.c')
-rw-r--r--util/libreboot-utils/lib/mkhtemp.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/util/libreboot-utils/lib/mkhtemp.c b/util/libreboot-utils/lib/mkhtemp.c
index 4e7f6013..bb714b82 100644
--- a/util/libreboot-utils/lib/mkhtemp.c
+++ b/util/libreboot-utils/lib/mkhtemp.c
@@ -4,10 +4,6 @@
* Hardened mktemp (be nice to the demon).
*/
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 700
-#endif
-
/* for openat2 / fast path: */
#ifdef __linux__
#if !defined(USE_OPENAT) || \
@@ -138,7 +134,7 @@ new_tmp_common(int *fd, char **path, int type,
if (*fd < 0)
goto err;
- close_on_eintr(&dirfd);
+ xclose(&dirfd);
errno = saved_errno;
*path = dest;
@@ -149,8 +145,8 @@ new_tmp_common(int *fd, char **path, int type,
err:
free_and_set_null(&dest);
- close_on_eintr(&dirfd);
- close_on_eintr(fd);
+ xclose(&dirfd);
+ xclose(fd);
/* where a TMPDIR isn't found, and we err,
* we pass this back through for the
@@ -294,8 +290,8 @@ success_same_dir:
rval = 1; /* SUCCESS */
}
- close_on_eintr(&fd_a);
- close_on_eintr(&fd_b);
+ xclose(&fd_a);
+ xclose(&fd_b);
/* we reset caller errno regardless
* of success, so long as it's not
@@ -307,8 +303,8 @@ success_same_dir:
err_same_dir:
/* FAILURE (probably syscall) - returns -1
*/
- close_on_eintr(&fd_a);
- close_on_eintr(&fd_b);
+ xclose(&fd_a);
+ xclose(&fd_b);
return with_fallback_errno(EIO); /* -1 */
}
@@ -363,12 +359,12 @@ sticky_heaven:
if (faccessat(dirfd, ".", X_OK, AT_EACCESS) < 0)
goto sticky_hell; /* down you go! */
- close_on_eintr(&dirfd);
+ xclose(&dirfd);
reset_caller_errno(0);
return 1;
sticky_hell:
- close_on_eintr(&dirfd);
+ xclose(&dirfd);
(void) with_fallback_errno(EPERM);
return 0;
}
@@ -499,7 +495,7 @@ mkhtemp(int *fd,
errno = EEXIST;
err:
- close_on_eintr(fd);
+ xclose(fd);
free_and_set_null(&fname_copy);
return with_fallback_errno(EIO);
@@ -639,7 +635,7 @@ out:
reset_caller_errno(0);
return rval;
err:
- close_on_eintr(fd);
+ xclose(fd);
if (file_created)
(void) unlinkat(dirfd, fname_copy, 0);
@@ -725,7 +721,7 @@ err:
if (linked)
(void) unlinkat(dirfd, fname_copy, 0);
- close_on_eintr(&tmpfd);
+ xclose(&tmpfd);
return with_fallback_errno(EIO);
out:
reset_caller_errno(0);
@@ -756,9 +752,7 @@ int secure_file(int *fd,
if_err(*fd < 0, EBADF))
goto err_demons;
- while (fs_retry(saved_errno,
- flags = fcntl(*fd, F_GETFL)));
- if (flags == -1)
+ if ((flags = fcntl(*fd, F_GETFL)) == -1)
goto err_demons;
if (if_err(bad_flags > 0 && (flags & bad_flags), EPERM))
@@ -903,9 +897,7 @@ lock_file(int fd, int flags)
fl.l_whence = SEEK_SET;
- while (fs_retry(saved_errno,
- fcntl_rval = fcntl(fd, F_SETLK, &fl)));
- if (fcntl_rval == -1)
+ if ((fcntl_rval = fcntl(fd, F_SETLK, &fl)) == -1)
goto err_lock_file;
reset_caller_errno(0);