diff options
| author | 2023-02-07 09:25:01 +0100 | |
|---|---|---|
| committer | 2023-02-07 09:25:01 +0100 | |
| commit | 67f2d4318d76b305ab98a48ff48b47e2e87126c2 (patch) | |
| tree | e8c72fcf2aaf9ff0f8ec59dd07894736d0ab01ac /snac.c | |
| parent | Ensure the setgid bit is set in the base directory. (diff) | |
| download | snac2-67f2d4318d76b305ab98a48ff48b47e2e87126c2.tar.gz snac2-67f2d4318d76b305ab98a48ff48b47e2e87126c2.tar.xz snac2-67f2d4318d76b305ab98a48ff48b47e2e87126c2.zip | |
New utility function mkdirx().
Diffstat (limited to '')
| -rw-r--r-- | snac.c | 14 |
1 files changed, 13 insertions, 1 deletions
| @@ -30,6 +30,18 @@ int srv_running = 0; | |||
| 30 | int dbglevel = 0; | 30 | int dbglevel = 0; |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | int mkdirx(const char *pathname) | ||
| 34 | /* creates a directory with special permissions */ | ||
| 35 | { | ||
| 36 | int ret; | ||
| 37 | |||
| 38 | if ((ret = mkdir(pathname, DIR_PERM)) != -1) | ||
| 39 | ret = chmod(pathname, DIR_PERM); | ||
| 40 | |||
| 41 | return ret; | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 33 | int valid_status(int status) | 45 | int valid_status(int status) |
| 34 | /* is this HTTP status valid? */ | 46 | /* is this HTTP status valid? */ |
| 35 | { | 47 | { |
| @@ -149,7 +161,7 @@ void srv_archive(const char *direction, xs_dict *req, | |||
| 149 | xs *dir = xs_fmt("%s/archive/%s_%s", srv_basedir, date, direction); | 161 | xs *dir = xs_fmt("%s/archive/%s_%s", srv_basedir, date, direction); |
| 150 | FILE *f; | 162 | FILE *f; |
| 151 | 163 | ||
| 152 | if (mkdir(dir, DIR_PERM) != -1) { | 164 | if (mkdirx(dir) != -1) { |
| 153 | xs *meta_fn = xs_fmt("%s/_META", dir); | 165 | xs *meta_fn = xs_fmt("%s/_META", dir); |
| 154 | 166 | ||
| 155 | if ((f = fopen(meta_fn, "w")) != NULL) { | 167 | if ((f = fopen(meta_fn, "w")) != NULL) { |