diff options
| author | 2025-10-24 05:02:28 +0200 | |
|---|---|---|
| committer | 2025-10-24 05:02:28 +0200 | |
| commit | 1a42fdc8bd4d5dc045a87108e73dcda4f633266b (patch) | |
| tree | 0fad3d6cc5f6eff50edb610ef6d44acb6fdc598b | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | penes-snac2-1a42fdc8bd4d5dc045a87108e73dcda4f633266b.tar.gz penes-snac2-1a42fdc8bd4d5dc045a87108e73dcda4f633266b.tar.xz penes-snac2-1a42fdc8bd4d5dc045a87108e73dcda4f633266b.zip | |
Keep track of deleted users and return 410 Gone for them.
| -rw-r--r-- | activitypub.c | 10 | ||||
| -rw-r--r-- | data.c | 29 | ||||
| -rw-r--r-- | html.c | 5 | ||||
| -rw-r--r-- | httpd.c | 3 | ||||
| -rw-r--r-- | snac.h | 2 | ||||
| -rw-r--r-- | utils.c | 2 |
6 files changed, 45 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c index 2d53cbe..0368ac8 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -3660,8 +3660,9 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path, | |||
| 3660 | uid = xs_list_get(l, 1); | 3660 | uid = xs_list_get(l, 1); |
| 3661 | if (!user_open(&snac, uid)) { | 3661 | if (!user_open(&snac, uid)) { |
| 3662 | /* invalid user */ | 3662 | /* invalid user */ |
| 3663 | srv_debug(1, xs_fmt("activitypub_get_handler bad user %s", uid)); | 3663 | status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; |
| 3664 | return HTTP_STATUS_NOT_FOUND; | 3664 | srv_debug(1, xs_fmt("activitypub_get_handler bad user %s %d", uid, status)); |
| 3665 | return status; | ||
| 3665 | } | 3666 | } |
| 3666 | 3667 | ||
| 3667 | p_path = xs_list_get(l, 2); | 3668 | p_path = xs_list_get(l, 2); |
| @@ -3854,8 +3855,9 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path, | |||
| 3854 | const char *uid = xs_list_get(l, 1); | 3855 | const char *uid = xs_list_get(l, 1); |
| 3855 | if (!user_open(&snac, uid)) { | 3856 | if (!user_open(&snac, uid)) { |
| 3856 | /* invalid user */ | 3857 | /* invalid user */ |
| 3857 | srv_debug(1, xs_fmt("activitypub_post_handler bad user %s", uid)); | 3858 | status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; |
| 3858 | return HTTP_STATUS_NOT_FOUND; | 3859 | srv_debug(1, xs_fmt("activitypub_post_handler bad user %s %d", uid, status)); |
| 3860 | return status; | ||
| 3859 | } | 3861 | } |
| 3860 | 3862 | ||
| 3861 | /* if it has a digest, check it now, because | 3863 | /* if it has a digest, check it now, because |
| @@ -3137,6 +3137,35 @@ int instance_failure(const char *url, int op) | |||
| 3137 | } | 3137 | } |
| 3138 | 3138 | ||
| 3139 | 3139 | ||
| 3140 | int grave(const char *objid, int op) | ||
| 3141 | /* the graveyeard of deleted objects */ | ||
| 3142 | { | ||
| 3143 | int ret = 0; | ||
| 3144 | xs *dir = xs_fmt("%s/grave", srv_basedir); | ||
| 3145 | xs *md5 = xs_md5_hex(objid, strlen(objid)); | ||
| 3146 | xs *fn = xs_fmt("%s/%s", dir, md5); | ||
| 3147 | FILE *f; | ||
| 3148 | |||
| 3149 | switch (op) { | ||
| 3150 | case 0: /** check **/ | ||
| 3151 | ret = mtime(fn) > 0.0 ? 1 : 0; | ||
| 3152 | break; | ||
| 3153 | |||
| 3154 | case 1: /** add **/ | ||
| 3155 | mkdirx(dir); | ||
| 3156 | |||
| 3157 | if ((f = fopen(fn, "w")) != NULL) { | ||
| 3158 | fprintf(f, "%s\n", objid); | ||
| 3159 | fclose(f); | ||
| 3160 | } | ||
| 3161 | |||
| 3162 | break; | ||
| 3163 | } | ||
| 3164 | |||
| 3165 | return ret; | ||
| 3166 | } | ||
| 3167 | |||
| 3168 | |||
| 3140 | /** notifications **/ | 3169 | /** notifications **/ |
| 3141 | 3170 | ||
| 3142 | xs_str *notify_check_time(snac *snac, int reset) | 3171 | xs_str *notify_check_time(snac *snac, int reset) |
| @@ -3830,8 +3830,9 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3830 | 3830 | ||
| 3831 | if (!uid || !user_open(&snac, uid)) { | 3831 | if (!uid || !user_open(&snac, uid)) { |
| 3832 | /* invalid user */ | 3832 | /* invalid user */ |
| 3833 | srv_debug(1, xs_fmt("html_get_handler bad user %s", uid)); | 3833 | status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; |
| 3834 | return HTTP_STATUS_NOT_FOUND; | 3834 | srv_debug(1, xs_fmt("html_get_handler bad user %s %d", uid, status)); |
| 3835 | return status; | ||
| 3835 | } | 3836 | } |
| 3836 | 3837 | ||
| 3837 | user = &snac; /* for L() */ | 3838 | user = &snac; /* for L() */ |
| @@ -598,6 +598,9 @@ void httpd_connection(FILE *f) | |||
| 598 | if (status == HTTP_STATUS_NOT_FOUND) | 598 | if (status == HTTP_STATUS_NOT_FOUND) |
| 599 | body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>"); | 599 | body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>"); |
| 600 | 600 | ||
| 601 | if (status == HTTP_STATUS_GONE) | ||
| 602 | body = xs_str_new("<h1>410 Gone (" USER_AGENT ")</h1>"); | ||
| 603 | |||
| 601 | if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) | 604 | if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) |
| 602 | body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>"); | 605 | body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>"); |
| 603 | 606 | ||
| @@ -288,6 +288,8 @@ xs_list *content_search(snac *user, const char *regex, | |||
| 288 | int actor_failure(const char *actor, int op); | 288 | int actor_failure(const char *actor, int op); |
| 289 | int instance_failure(const char *url, int op); | 289 | int instance_failure(const char *url, int op); |
| 290 | 290 | ||
| 291 | int grave(const char *objid, int op); | ||
| 292 | |||
| 291 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); | 293 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); |
| 292 | void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); | 294 | void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); |
| 293 | void enqueue_output_raw(const char *keyid, const char *seckey, | 295 | void enqueue_output_raw(const char *keyid, const char *seckey, |
| @@ -454,6 +454,8 @@ int deluser(snac *user) | |||
| 454 | } | 454 | } |
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | grave(user->uid, 1); | ||
| 458 | |||
| 457 | rm_rf(user->basedir); | 459 | rm_rf(user->basedir); |
| 458 | 460 | ||
| 459 | return ret; | 461 | return ret; |