diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-01-21 19:07:16 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-01-21 19:07:16 -0500 |
commit | 1ebf647b05a7314cfc0279810f802dd1dfa332c1 (patch) | |
tree | 8bec0cc019cd228384a55fe37904d38e57caaae2 /src | |
parent | dd43e0b64c8a4c24f3fb363da5b83e3aa14c367e (diff) |
Fall back on POSIX mkstemp() for systems lacking mkostemp()
We add an autotools check to use mkstemp() and fcntl() when mkostemp()
is missing. This is not strictly equivalent because we have no way of
setting the file access mode O_WRONLY flag, but that should produce no
functional difference.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libudev/util.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libudev/util.c b/src/libudev/util.c index 43defd35b5..1d57a01567 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -4300,10 +4300,10 @@ int execute_command(const char *command, char *const argv[]) { pid_t pid; - int status; + int status; - if ((status = access(command, X_OK)) != 0) - return status; + if ((status = access(command, X_OK)) != 0) + return status; if ((pid = fork()) < 0) { log_error("Failed to fork: %m"); @@ -4582,7 +4582,12 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { t[k] = '.'; stpcpy(stpcpy(t+k+1, fn), "XXXXXX"); +#if HAVE_DECL_MKOSTEMP fd = mkostemp(t, O_WRONLY|O_CLOEXEC); +#else + fd = mkstemp(t); + fcntl(t, F_SETFD, FD_CLOEXEC); +#endif if (fd < 0) { free(t); return -errno; |