chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util-lib: rework /tmp and /var/tmp handling code
[elogind.git]
/
src
/
basic
/
fileio.c
diff --git
a/src/basic/fileio.c
b/src/basic/fileio.c
index df432eaee4283f9c182fa01301e48cffc869fb13..e377a9e00a7e60f18346dbd8c3e01ad28ac7a117 100644
(file)
--- a/
src/basic/fileio.c
+++ b/
src/basic/fileio.c
@@
-1166,8
+1166,8
@@
int tempfn_random_child(const char *p, const char *extra, char **ret) {
char *t, *x;
uint64_t u;
unsigned i;
char *t, *x;
uint64_t u;
unsigned i;
+ int r;
- assert(p);
assert(ret);
/* Turns this:
assert(ret);
/* Turns this:
@@
-1176,6
+1176,12
@@
int tempfn_random_child(const char *p, const char *extra, char **ret) {
* /foo/bar/waldo/.#<extra>3c2b6219aa75d7d0
*/
* /foo/bar/waldo/.#<extra>3c2b6219aa75d7d0
*/
+ if (!p) {
+ r = tmp_dir(&p);
+ if (r < 0)
+ return r;
+ }
+
if (!extra)
extra = "";
if (!extra)
extra = "";
@@
-1262,10
+1268,13
@@
int fputs_with_space(FILE *f, const char *s, const char *separator, bool *space)
int open_tmpfile_unlinkable(const char *directory, int flags) {
char *p;
int open_tmpfile_unlinkable(const char *directory, int flags) {
char *p;
- int fd;
+ int fd
, r
;
- if (!directory)
- directory = "/tmp";
+ if (!directory) {
+ r = tmp_dir(&directory);
+ if (r < 0)
+ return r;
+ }
/* Returns an unlinked temporary file that cannot be linked into the file system anymore */
/* Returns an unlinked temporary file that cannot be linked into the file system anymore */