aboutsummaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorStefano Marinelli <stefano@dragas.it>2026-01-06 11:02:36 +0100
committerStefano Marinelli <stefano@dragas.it>2026-01-06 11:02:36 +0100
commit688c54c87355b5424f33f7b089814460a74af594 (patch)
tree03bbe3779173b3d90aede93ea6e41e64869b415b /data.c
parentb84b92df74ed0e8f92617e37fdcb2f0aba2138cf (diff)
Implement configurable EXIF stripping for uploaded media
- Add `strip_exif` configuration option to enable metadata removal. - Add `mogrify_path` configuration to specify external tool location. - Implement strip_media using `mogrify -strip`. - Support multiple image formats: jpg, png, webp, heic, heif, avif, tiff, gif, bmp. - Add strict startup check: fail to start if `strip_exif` is enabled but `mogrify` is missing/broken. - Update documentation in `doc/snac.8`.
Diffstat (limited to 'data.c')
-rw-r--r--data.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/data.c b/data.c
index 22ea7b0..f32dc81 100644
--- a/data.c
+++ b/data.c
@@ -89,8 +89,15 @@ int srv_open(const char *basedir, int auto_upgrade)
else {
if (xs_number_get(xs_dict_get(srv_config, "layout")) < disk_layout)
error = xs_fmt("ERROR: disk layout changed - execute 'snac upgrade' first");
- else
- ret = 1;
+ else {
+ if (!check_strip_tool()) {
+ const char *mp = xs_dict_get(srv_config, "mogrify_path");
+ if (mp == NULL) mp = "mogrify";
+ error = xs_fmt("ERROR: strip_exif enabled but '%s' not found or not working (set 'mogrify_path' in server.json)", mp);
+ }
+ else
+ ret = 1;
+ }
}
}
@@ -2710,6 +2717,8 @@ void static_put(snac *snac, const char *id, const char *data, int size)
if (fn && (f = fopen(fn, "wb")) != NULL) {
fwrite(data, size, 1, f);
fclose(f);
+
+ strip_media(fn);
}
}