bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainensafe_mkstemp_full(string_t *prefix, mode_t mode, uid_t uid, gid_t gid,
128ab2c52a29068be87e12ab5aebbb8fdc933adfTimo Sirainen i_error("stat(%s) failed: %m", str_c(prefix));
4ded3d18fa391ae5908f9834f1390cf55e8c99d5Timo Sirainen fd = open(str_c(prefix), O_RDWR | O_EXCL | O_CREAT, 0666);
b3a069922c8150a1cb14ec7683444f60dee98b55Timo Sirainen i_error("open(%s) failed: %m", str_c(prefix));
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainenint safe_mkstemp(string_t *prefix, mode_t mode, uid_t uid, gid_t gid)
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainen return safe_mkstemp_full(prefix, mode, uid, gid, NULL);
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainenint safe_mkstemp_group(string_t *prefix, mode_t mode,
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainen return safe_mkstemp_full(prefix, mode, (uid_t)-1, gid, gid_origin);
128ab2c52a29068be87e12ab5aebbb8fdc933adfTimo Sirainenint safe_mkstemp_hostpid(string_t *prefix, mode_t mode, uid_t uid, gid_t gid)
128ab2c52a29068be87e12ab5aebbb8fdc933adfTimo Sirainen str_printfa(prefix, "%s.%s.", my_hostname, my_pid);
033e315cc9396332a09b98bee7824b8e6641c2fcTimo Sirainen if ((fd = safe_mkstemp(prefix, mode, uid, gid)) == -1)
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainenint safe_mkstemp_hostpid_group(string_t *prefix, mode_t mode,
e156adefc1260d31a145df2f5e9b3c82050d4163Timo Sirainen str_printfa(prefix, "%s.%s.", my_hostname, my_pid);
033e315cc9396332a09b98bee7824b8e6641c2fcTimo Sirainen if ((fd = safe_mkstemp_group(prefix, mode, gid, gid_origin)) == -1)