s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 55be2c3525bd14a64664116b809fcb9d69eeb8a9
parent ab926cf88440b7e6827f778968ec2d88443bdb26
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sat, 30 Sep 2017 09:24:29 +0000

 Use mkstemp() in s6-accessrules-cdb-from-fs

Diffstat:
Msrc/conn-tools/s6-accessrules-cdb-from-fs.c | 13+++++--------
1 file 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 @@ -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() ;