commit d2aa572
default
·
2023-07-09 18:23:38 +0000 UTC
parent c562a45
Fixed failed mkdir() in restricted environments.
M
snac.c
+7,
-2
1@@ -35,8 +35,13 @@ int mkdirx(const char *pathname)
2 {
3 int ret;
4
5- if ((ret = mkdir(pathname, DIR_PERM)) != -1)
6- ret = chmod(pathname, DIR_PERM);
7+ if ((ret = mkdir(pathname, DIR_PERM)) != -1) {
8+ /* try to the set the setgid bit, to allow system users
9+ to create files in these directories using the
10+ command-line tool. This may fail in some restricted
11+ environments, but it's of no use there anyway */
12+ chmod(pathname, DIR_PERM_ADD);
13+ }
14
15 return ret;
16 }
M
snac.h
+2,
-1
1@@ -7,7 +7,8 @@
2
3 #define WHAT_IS_SNAC_URL "https:/" "/comam.es/what-is-snac"
4
5-#define DIR_PERM 02770
6+#define DIR_PERM 00770
7+#define DIR_PERM_ADD 02770
8
9 #define ISO_DATE_SPEC "%Y-%m-%dT%H:%M:%SZ"
10