diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-09-30 09:24:29 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-09-30 09:24:29 +0000 |
commit | 55be2c3525bd14a64664116b809fcb9d69eeb8a9 (patch) | |
tree | 5ca8f402c1d31ac5540f37c0d8a7600b9942b369 | |
parent | ab926cf88440b7e6827f778968ec2d88443bdb26 (diff) | |
download | s6-55be2c3525bd14a64664116b809fcb9d69eeb8a9.tar.xz |
Use mkstemp() in s6-accessrules-cdb-from-fs
-rw-r--r-- | src/conn-tools/s6-accessrules-cdb-from-fs.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/conn-tools/s6-accessrules-cdb-from-fs.c b/src/conn-tools/s6-accessrules-cdb-from-fs.c index ccd1204..9efacdb 100644 --- a/src/conn-tools/s6-accessrules-cdb-from-fs.c +++ b/src/conn-tools/s6-accessrules-cdb-from-fs.c @@ -3,6 +3,7 @@ #include <stdint.h> #include <unistd.h> #include <errno.h> +#include <stdlib.h> #include <stdio.h> #include <skalibs/types.h> #include <skalibs/cdb_make.h> @@ -11,9 +12,9 @@ #include <skalibs/direntry.h> #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> -#include <skalibs/random.h> #define USAGE "s6-accessrules-cdb-from-fs cdbfile dir" +#define SUFFIX ":s6-accessrules-cdb-from-fs:XXXXXX" static stralloc tmp = STRALLOC_ZERO ; @@ -109,16 +110,12 @@ int main (int argc, char const *const *argv) int fd ; PROG = "s6-accessrules-cdb-from-fs" ; if (argc < 3) strerr_dieusage(100, USAGE) ; - if (!random_init()) - strerr_diefu1sys(111, "init random generator") ; if (!stralloc_cats(&tmp, argv[1])) return 0 ; - if (!random_sauniquename(&tmp, 8)) - strerr_diefu1sys(111, "random_sauniquename") ; if (!stralloc_readyplus(&tmp, 8210)) strerr_diefu1sys(111, "stralloc_catb") ; - stralloc_0(&tmp) ; - fd = open_trunc(tmp.s) ; - if (fd < 0) strerr_diefu2sys(111, "open_trunc ", tmp.s) ; + stralloc_catb(&tmp, SUFFIX, sizeof(SUFFIX)) ; + fd = mkstemp(tmp.s) ; + if (fd < 0) strerr_diefu2sys(111, "mkstemp ", tmp.s) ; if (cdb_make_start(&c, fd) < 0) { cleanup() ; |