summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-07-09 20:23:38 +0200
committerdefault <nobody@localhost>2023-07-09 20:23:38 +0200
commitd2aa5727baf8b17f99d0ffc041b225463bd2684d (patch)
tree2c2a48478f7b1ae5c66ea6d46bb4c6d9254ca7d7
parentc562a4531c438b4848f569d2c3901708b7bbce43 (diff)
Fixed failed mkdir() in restricted environments.
-rw-r--r--snac.c9
-rw-r--r--snac.h3
2 files changed, 9 insertions, 3 deletions
diff --git a/snac.c b/snac.c
index 7fbb61e..b35e645 100644
--- a/snac.c
+++ b/snac.c
@@ -35,8 +35,13 @@ int mkdirx(const char *pathname)
{
int ret;
- if ((ret = mkdir(pathname, DIR_PERM)) != -1)
- ret = chmod(pathname, DIR_PERM);
+ if ((ret = mkdir(pathname, DIR_PERM)) != -1) {
+ /* try to the set the setgid bit, to allow system users
+ to create files in these directories using the
+ command-line tool. This may fail in some restricted
+ environments, but it's of no use there anyway */
+ chmod(pathname, DIR_PERM_ADD);
+ }
return ret;
}
diff --git a/snac.h b/snac.h
index 72da95d..f19f7e1 100644
--- a/snac.h
+++ b/snac.h
@@ -7,7 +7,8 @@
#define WHAT_IS_SNAC_URL "https:/" "/comam.es/what-is-snac"
-#define DIR_PERM 02770
+#define DIR_PERM 00770
+#define DIR_PERM_ADD 02770
#define ISO_DATE_SPEC "%Y-%m-%dT%H:%M:%SZ"