summaryrefslogtreecommitdiff
path: root/src/usertree/s6-usertree-maker.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-01-07 23:38:06 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-01-07 23:38:06 +0000
commitc771aabafeaea4ba903dd8f06ad6fc1e95504946 (patch)
tree7c101679ac52be46827de669440883c6ef1c9a6c /src/usertree/s6-usertree-maker.c
parentf481d14e9d9c5b2d57995aa0d9094500676e013e (diff)
downloads6-c771aabafeaea4ba903dd8f06ad6fc1e95504946.tar.xz
Doc clarification, QoL fix for s6-usertree-maker
Diffstat (limited to 'src/usertree/s6-usertree-maker.c')
-rw-r--r--src/usertree/s6-usertree-maker.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/usertree/s6-usertree-maker.c b/src/usertree/s6-usertree-maker.c
index 9326e82..26c4f1b 100644
--- a/src/usertree/s6-usertree-maker.c
+++ b/src/usertree/s6-usertree-maker.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/uio.h>
+#include <errno.h>
#include <skalibs/config.h>
#include <skalibs/uint64.h>
@@ -274,9 +275,8 @@ int main (int argc, char *const *argv)
mask = umask(0) ;
umask(mask) ;
mask = ~mask & 0666 ;
-
- if (mkdir(argv[2], 0755) < 0) strerr_diefu2sys(111, "mkdir ", argv[2]) ;
dirlen = strlen(argv[2]) ;
+
if (rcinfo[0])
{
size_t svclen = strlen(rcinfo[0]) ;
@@ -285,6 +285,8 @@ int main (int argc, char *const *argv)
memcpy(dir, argv[2], dirlen) ;
dir[dirlen] = '/' ;
memcpy(dir + dirlen + 1, rcinfo[0], svclen + 1) ;
+ if (mkdir(argv[2], 0755) < 0 && errno != EEXIST)
+ strerr_diefu2sys(111, "mkdir ", argv[2]) ;
if (mkdir(dir, 0755) < 0) strerr_diefu2sys(111, "mkdir ", dir) ;
write_service(dir, argv[0], userscandir, rcinfo[1], path, userenvdir, vars, varlen) ;
memcpy(dir + dirlen + 1, rcinfo[1], loglen + 1) ;
@@ -295,6 +297,7 @@ int main (int argc, char *const *argv)
char dir[dirlen + 5] ;
memcpy(dir, argv[2], dirlen) ;
memcpy(dir + dirlen, "/log", 5) ;
+ if (mkdir(argv[2], 0755) < 0) strerr_diefu2sys(111, "mkdir ", argv[2]) ;
write_service(argv[2], argv[0], userscandir, 0, path, userenvdir, vars, varlen) ;
write_logger(dir, loguser, argv[1], stamptype, nfiles, filesize, maxsize, 0, 0) ;
}