From d2aa5727baf8b17f99d0ffc041b225463bd2684d Mon Sep 17 00:00:00 2001 From: default Date: Sun, 9 Jul 2023 20:23:38 +0200 Subject: Fixed failed mkdir() in restricted environments. --- snac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'snac.c') 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; } -- cgit v1.2.3