2 * This module handles the expiry of old messages and the purging of old users.
4 * You might also see this module affectionately referred to as the DAP (the Dreaded Auto-Purger).
6 * Copyright (c) 1988-2011 by citadel.org (Art Cancro, Wilifried Goesgens, and others)
8 * This program is open source software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * A brief technical discussion:
25 * Several of the purge operations found in this module operate in two
26 * stages: the first stage generates a linked list of objects to be deleted,
27 * then the second stage deletes all listed objects from the database.
29 * At first glance this may seem cumbersome and unnecessary. The reason it is
30 * implemented in this way is because Berkeley DB, and possibly other backends
31 * we may hook into in the future, explicitly do _not_ support the deletion of
32 * records from a file while the file is being traversed. The delete operation
33 * will succeed, but the traversal is not guaranteed to visit every object if
34 * this is done. Therefore we utilize the two-stage purge.
36 * When using Berkeley DB, there's another reason for the two-phase purge: we
37 * don't want the entire thing being done as one huge transaction.
39 * You'll also notice that we build the in-memory list of records to be deleted
40 * sometimes with a linked list and sometimes with a hash table. There is no
41 * reason for this aside from the fact that the linked list ones were written
42 * before we had the hash table library available.
54 #include <sys/types.h>
56 #if TIME_WITH_SYS_TIME
57 # include <sys/time.h>
61 # include <sys/time.h>
70 #include <libcitadel.h>
73 #include "citserver.h"
81 #include "serv_network.h" /* Needed for definition of UseTable */
85 #include "ctdl_module.h"
89 struct PurgeList *next;
90 char name[ROOMNAMELEN]; /* use the larger of username or roomname */
94 struct VPurgeList *next;
101 struct ValidRoom *next;
107 struct ValidUser *next;
113 struct ctdlroomref *next;
118 struct UPurgeList *next;
123 struct EPurgeList *next;
129 struct PurgeList *UserPurgeList = NULL;
130 struct PurgeList *RoomPurgeList = NULL;
131 struct ValidRoom *ValidRoomList = NULL;
132 struct ValidUser *ValidUserList = NULL;
134 int users_not_purged;
135 char *users_corrupt_msg = NULL;
136 char *users_zero_msg = NULL;
137 struct ctdlroomref *rr = NULL;
138 int force_purge_now = 0; /* set to nonzero to force a run right now */
142 * First phase of message purge -- gather the locations of messages which
143 * qualify for purging and write them to a temp file.
145 void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) {
146 struct ExpirePolicy epbuf;
149 struct CtdlMessage *msg = NULL;
151 struct cdbdata *cdbfr;
152 long *msglist = NULL;
156 purgelist = (FILE *)data;
157 fprintf(purgelist, "r=%s\n", qrbuf->QRname);
160 GetExpirePolicy(&epbuf, qrbuf);
162 /* If the room is set to never expire messages ... do nothing */
163 if (epbuf.expire_mode == EXPIRE_NEXTLEVEL) return;
164 if (epbuf.expire_mode == EXPIRE_MANUAL) return;
166 /* Don't purge messages containing system configuration, dumbass. */
167 if (!strcasecmp(qrbuf->QRname, SYSCONFIGROOM)) return;
169 /* Ok, we got this far ... now let's see what's in the room */
170 cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long));
173 msglist = malloc(cdbfr->len);
174 memcpy(msglist, cdbfr->ptr, cdbfr->len);
175 num_msgs = cdbfr->len / sizeof(long);
179 /* Nothing to do if there aren't any messages */
181 if (msglist != NULL) free(msglist);
186 /* If the room is set to expire by count, do that */
187 if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
188 if (num_msgs > epbuf.expire_value) {
189 for (a=0; a<(num_msgs - epbuf.expire_value); ++a) {
190 fprintf(purgelist, "m=%ld\n", msglist[a]);
196 /* If the room is set to expire by age... */
197 if (epbuf.expire_mode == EXPIRE_AGE) {
198 for (a=0; a<num_msgs; ++a) {
201 msg = CtdlFetchMessage(delnum, 0); /* dont need body */
203 xtime = atol(msg->cm_fields['T']);
204 CtdlFreeMessage(msg);
210 && (now - xtime > (time_t)(epbuf.expire_value * 86400L))) {
211 fprintf(purgelist, "m=%ld\n", delnum);
217 if (msglist != NULL) free(msglist);
222 * Second phase of message purge -- read list of msgs from temp file and
225 void DoPurgeMessages(FILE *purgelist) {
226 char roomname[ROOMNAMELEN];
231 strcpy(roomname, "nonexistent room ___ ___");
232 while (fgets(buf, sizeof buf, purgelist) != NULL) {
233 buf[strlen(buf)-1]=0;
234 if (!strncasecmp(buf, "r=", 2)) {
235 strcpy(roomname, &buf[2]);
237 if (!strncasecmp(buf, "m=", 2)) {
238 msgnum = atol(&buf[2]);
240 CtdlDeleteMessages(roomname, &msgnum, 1, "");
247 void PurgeMessages(void) {
250 syslog(LOG_DEBUG, "PurgeMessages() called");
253 purgelist = tmpfile();
254 if (purgelist == NULL) {
255 syslog(LOG_CRIT, "Can't create purgelist temp file: %s", strerror(errno));
259 CtdlForEachRoom(GatherPurgeMessages, (void *)purgelist );
260 DoPurgeMessages(purgelist);
265 void AddValidUser(struct ctdluser *usbuf, void *data) {
266 struct ValidUser *vuptr;
268 vuptr = (struct ValidUser *)malloc(sizeof(struct ValidUser));
269 vuptr->next = ValidUserList;
270 vuptr->vu_usernum = usbuf->usernum;
271 ValidUserList = vuptr;
274 void AddValidRoom(struct ctdlroom *qrbuf, void *data) {
275 struct ValidRoom *vrptr;
277 vrptr = (struct ValidRoom *)malloc(sizeof(struct ValidRoom));
278 vrptr->next = ValidRoomList;
279 vrptr->vr_roomnum = qrbuf->QRnumber;
280 vrptr->vr_roomgen = qrbuf->QRgen;
281 ValidRoomList = vrptr;
284 void DoPurgeRooms(struct ctdlroom *qrbuf, void *data) {
285 time_t age, purge_secs;
286 struct PurgeList *pptr;
287 struct ValidUser *vuptr;
290 /* For mailbox rooms, there's only one purging rule: if the user who
291 * owns the room still exists, we keep the room; otherwise, we purge
292 * it. Bypass any other rules.
294 if (qrbuf->QRflags & QR_MAILBOX) {
295 /* if user not found, do_purge will be 1 */
297 for (vuptr=ValidUserList; vuptr!=NULL; vuptr=vuptr->next) {
298 if (vuptr->vu_usernum == atol(qrbuf->QRname)) {
304 /* Any of these attributes render a room non-purgable */
305 if (qrbuf->QRflags & QR_PERMANENT) return;
306 if (qrbuf->QRflags & QR_DIRECTORY) return;
307 if (qrbuf->QRflags & QR_NETWORK) return;
308 if (qrbuf->QRflags2 & QR2_SYSTEM) return;
309 if (!strcasecmp(qrbuf->QRname, SYSCONFIGROOM)) return;
310 if (CtdlIsNonEditable(qrbuf)) return;
312 /* If we don't know the modification date, be safe and don't purge */
313 if (qrbuf->QRmtime <= (time_t)0) return;
315 /* If no room purge time is set, be safe and don't purge */
316 if (config.c_roompurge < 0) return;
318 /* Otherwise, check the date of last modification */
319 age = time(NULL) - (qrbuf->QRmtime);
320 purge_secs = (time_t)config.c_roompurge * (time_t)86400;
321 if (purge_secs <= (time_t)0) return;
322 syslog(LOG_DEBUG, "<%s> is <%ld> seconds old", qrbuf->QRname, (long)age);
323 if (age > purge_secs) do_purge = 1;
327 pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList));
328 pptr->next = RoomPurgeList;
329 strcpy(pptr->name, qrbuf->QRname);
330 RoomPurgeList = pptr;
337 int PurgeRooms(void) {
338 struct PurgeList *pptr;
339 int num_rooms_purged = 0;
340 struct ctdlroom qrbuf;
341 struct ValidUser *vuptr;
342 char *transcript = NULL;
344 syslog(LOG_DEBUG, "PurgeRooms() called");
347 /* Load up a table full of valid user numbers so we can delete
348 * user-owned rooms for users who no longer exist */
349 ForEachUser(AddValidUser, NULL);
351 /* Then cycle through the room file */
352 CtdlForEachRoom(DoPurgeRooms, NULL);
354 /* Free the valid user list */
355 while (ValidUserList != NULL) {
356 vuptr = ValidUserList->next;
358 ValidUserList = vuptr;
362 transcript = malloc(SIZ);
363 strcpy(transcript, "The following rooms have been auto-purged:\n");
365 while (RoomPurgeList != NULL) {
366 if (CtdlGetRoom(&qrbuf, RoomPurgeList->name) == 0) {
367 transcript=realloc(transcript, strlen(transcript)+SIZ);
368 snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
370 CtdlDeleteRoom(&qrbuf);
372 pptr = RoomPurgeList->next;
374 RoomPurgeList = pptr;
378 if (num_rooms_purged > 0) CtdlAideMessage(transcript, "Room Autopurger Message");
381 syslog(LOG_DEBUG, "Purged %d rooms.", num_rooms_purged);
382 return(num_rooms_purged);
387 * Back end function to check user accounts for associated Unix accounts
388 * which no longer exist. (Only relevant for host auth mode.)
390 void do_uid_user_purge(struct ctdluser *us, void *data) {
391 struct PurgeList *pptr;
393 if ((us->uid != (-1)) && (us->uid != CTDLUID)) {
394 if (getpwuid(us->uid) == NULL) {
395 pptr = (struct PurgeList *)
396 malloc(sizeof(struct PurgeList));
397 pptr->next = UserPurgeList;
398 strcpy(pptr->name, us->fullname);
399 UserPurgeList = pptr;
411 * Back end function to check user accounts for expiration.
413 void do_user_purge(struct ctdluser *us, void *data) {
417 struct PurgeList *pptr;
419 /* Set purge time; if the user overrides the system default, use it */
420 if (us->USuserpurge > 0) {
421 purge_time = ((time_t)us->USuserpurge) * 86400L;
424 purge_time = ((time_t)config.c_userpurge) * 86400L;
427 /* The default rule is to not purge. */
430 /* If the user hasn't called in two months and expiring of accounts is turned on, his/her account
431 * has expired, so purge the record.
433 if (config.c_userpurge > 0)
436 if ((now - us->lastcall) > purge_time) purge = 1;
439 /* If the record is marked as permanent, don't purge it.
441 if (us->flags & US_PERM) purge = 0;
443 /* If the user is an Aide, don't purge him/her/it.
445 if (us->axlevel == 6) purge = 0;
447 /* If the access level is 0, the record should already have been
448 * deleted, but maybe the user was logged in at the time or something.
449 * Delete the record now.
451 if (us->axlevel == 0) purge = 1;
453 /* If the user set his/her password to 'deleteme', he/she
454 * wishes to be deleted, so purge the record.
455 * Moved this lower down so that aides and permanent users get purged if they ask to be.
457 if (!strcasecmp(us->password, "deleteme")) purge = 1;
459 /* 0 calls is impossible. If there are 0 calls, it must
460 * be a corrupted record, so purge it.
461 * Actually it is possible if an Aide created the user so now we check for less than 0 (DRW)
463 if (us->timescalled < 0) purge = 1;
465 /* any negative user number, is
468 if (us->usernum < 0L) purge = 1;
470 /* Don't purge user 0. That user is there for the system */
471 if (us->usernum == 0L)
473 /* FIXME: Temporary log message. Until we do unauth access with user 0 we should
474 * try to get rid of all user 0 occurences. Many will be remnants from old code so
475 * we will need to try and purge them from users data bases.Some will not have names but
476 * those with names should be purged.
478 syslog(LOG_DEBUG, "Auto purger found a user 0 with name <%s>", us->fullname);
482 /* If the user has no full name entry then we can't purge them
483 * since the actual purge can't find them.
484 * This shouldn't happen but does somehow.
486 if (IsEmptyStr(us->fullname))
490 if (us->usernum > 0L)
493 if (users_corrupt_msg == NULL)
495 users_corrupt_msg = malloc(SIZ);
496 strcpy(users_corrupt_msg,
497 "The auto-purger found the following user numbers with no name.\n"
498 "The system has no way to purge a user with no name,"
499 " and should not be able to create them either.\n"
500 "This indicates corruption of the user DB or possibly a bug.\n"
501 "It may be a good idea to restore your DB from a backup.\n"
505 users_corrupt_msg=realloc(users_corrupt_msg, strlen(users_corrupt_msg)+30);
506 snprintf(&users_corrupt_msg[strlen(users_corrupt_msg)], 29, " %ld\n", us->usernum);
511 pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList));
512 pptr->next = UserPurgeList;
513 strcpy(pptr->name, us->fullname);
514 UserPurgeList = pptr;
524 int PurgeUsers(void) {
525 struct PurgeList *pptr;
526 int num_users_purged = 0;
527 char *transcript = NULL;
529 syslog(LOG_DEBUG, "PurgeUsers() called");
530 users_not_purged = 0;
532 switch(config.c_auth_mode) {
533 case AUTHMODE_NATIVE:
534 ForEachUser(do_user_purge, NULL);
537 ForEachUser(do_uid_user_purge, NULL);
540 syslog(LOG_DEBUG, "User purge for auth mode %d is not implemented.",
545 transcript = malloc(SIZ);
547 if (users_not_purged == 0) {
548 strcpy(transcript, "The auto-purger was told to purge every user. It is\n"
549 "refusing to do this because it usually indicates a problem\n"
550 "such as an inability to communicate with a name service.\n"
552 while (UserPurgeList != NULL) {
553 pptr = UserPurgeList->next;
555 UserPurgeList = pptr;
561 strcpy(transcript, "The following users have been auto-purged:\n");
562 while (UserPurgeList != NULL) {
563 transcript=realloc(transcript, strlen(transcript)+SIZ);
564 snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
565 UserPurgeList->name);
566 purge_user(UserPurgeList->name);
567 pptr = UserPurgeList->next;
569 UserPurgeList = pptr;
574 if (num_users_purged > 0) CtdlAideMessage(transcript, "User Purge Message");
577 if(users_corrupt_msg)
579 CtdlAideMessage(users_corrupt_msg, "User Corruption Message");
580 free (users_corrupt_msg);
581 users_corrupt_msg = NULL;
586 CtdlAideMessage(users_zero_msg, "User Zero Message");
587 free (users_zero_msg);
588 users_zero_msg = NULL;
591 syslog(LOG_DEBUG, "Purged %d users.", num_users_purged);
592 return(num_users_purged);
599 * This is a really cumbersome "garbage collection" function. We have to
600 * delete visits which refer to rooms and/or users which no longer exist. In
601 * order to prevent endless traversals of the room and user files, we first
602 * build linked lists of rooms and users which _do_ exist on the system, then
603 * traverse the visit file, checking each record against those two lists and
604 * purging the ones that do not have a match on _both_ lists. (Remember, if
605 * either the room or user being referred to is no longer on the system, the
606 * record is completely useless.)
608 int PurgeVisits(void) {
609 struct cdbdata *cdbvisit;
611 struct VPurgeList *VisitPurgeList = NULL;
612 struct VPurgeList *vptr;
616 struct ValidRoom *vrptr;
617 struct ValidUser *vuptr;
618 int RoomIsValid, UserIsValid;
620 /* First, load up a table full of valid room/gen combinations */
621 CtdlForEachRoom(AddValidRoom, NULL);
623 /* Then load up a table full of valid user numbers */
624 ForEachUser(AddValidUser, NULL);
626 /* Now traverse through the visits, purging irrelevant records... */
627 cdb_rewind(CDB_VISIT);
628 while(cdbvisit = cdb_next_item(CDB_VISIT), cdbvisit != NULL) {
629 memset(&vbuf, 0, sizeof(visit));
630 memcpy(&vbuf, cdbvisit->ptr,
631 ( (cdbvisit->len > sizeof(visit)) ?
632 sizeof(visit) : cdbvisit->len) );
638 /* Check to see if the room exists */
639 for (vrptr=ValidRoomList; vrptr!=NULL; vrptr=vrptr->next) {
640 if ( (vrptr->vr_roomnum==vbuf.v_roomnum)
641 && (vrptr->vr_roomgen==vbuf.v_roomgen))
645 /* Check to see if the user exists */
646 for (vuptr=ValidUserList; vuptr!=NULL; vuptr=vuptr->next) {
647 if (vuptr->vu_usernum == vbuf.v_usernum)
651 /* Put the record on the purge list if it's dead */
652 if ((RoomIsValid==0) || (UserIsValid==0)) {
653 vptr = (struct VPurgeList *)
654 malloc(sizeof(struct VPurgeList));
655 vptr->next = VisitPurgeList;
656 vptr->vp_roomnum = vbuf.v_roomnum;
657 vptr->vp_roomgen = vbuf.v_roomgen;
658 vptr->vp_usernum = vbuf.v_usernum;
659 VisitPurgeList = vptr;
664 /* Free the valid room/gen combination list */
665 while (ValidRoomList != NULL) {
666 vrptr = ValidRoomList->next;
668 ValidRoomList = vrptr;
671 /* Free the valid user list */
672 while (ValidUserList != NULL) {
673 vuptr = ValidUserList->next;
675 ValidUserList = vuptr;
678 /* Now delete every visit on the purged list */
679 while (VisitPurgeList != NULL) {
680 IndexLen = GenerateRelationshipIndex(IndexBuf,
681 VisitPurgeList->vp_roomnum,
682 VisitPurgeList->vp_roomgen,
683 VisitPurgeList->vp_usernum);
684 cdb_delete(CDB_VISIT, IndexBuf, IndexLen);
685 vptr = VisitPurgeList->next;
686 free(VisitPurgeList);
687 VisitPurgeList = vptr;
695 * Purge the use table of old entries.
698 int PurgeUseTable(void) {
700 struct cdbdata *cdbut;
702 struct UPurgeList *ul = NULL;
703 struct UPurgeList *uptr;
705 /* Phase 1: traverse through the table, discovering old records... */
706 syslog(LOG_DEBUG, "Purge use table: phase 1");
707 cdb_rewind(CDB_USETABLE);
708 while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
711 * TODODRW: change this to create a new function time_t cdb_get_timestamp( struct cdbdata *)
712 * this will release this file from the serv_network.h
713 * Maybe it could be a macro that extracts and casts the reult
715 memcpy(&ut, cdbut->ptr,
716 ((cdbut->len > sizeof(struct UseTable)) ?
717 sizeof(struct UseTable) : cdbut->len));
720 if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN ) {
721 uptr = (struct UPurgeList *) malloc(sizeof(struct UPurgeList));
724 safestrncpy(uptr->up_key, ut.ut_msgid, sizeof uptr->up_key);
732 /* Phase 2: delete the records */
733 syslog(LOG_DEBUG, "Purge use table: phase 2");
735 cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key));
741 syslog(LOG_DEBUG, "Purge use table: finished (purged %d records)", purged);
748 * Purge the EUID Index of old records.
751 int PurgeEuidIndexTable(void) {
753 struct cdbdata *cdbei;
754 struct EPurgeList *el = NULL;
755 struct EPurgeList *eptr;
757 struct CtdlMessage *msg = NULL;
759 /* Phase 1: traverse through the table, discovering old records... */
760 syslog(LOG_DEBUG, "Purge EUID index: phase 1");
761 cdb_rewind(CDB_EUIDINDEX);
762 while(cdbei = cdb_next_item(CDB_EUIDINDEX), cdbei != NULL) {
764 memcpy(&msgnum, cdbei->ptr, sizeof(long));
766 msg = CtdlFetchMessage(msgnum, 0);
768 CtdlFreeMessage(msg); /* it still exists, so do nothing */
771 eptr = (struct EPurgeList *) malloc(sizeof(struct EPurgeList));
774 eptr->ep_keylen = cdbei->len - sizeof(long);
775 eptr->ep_key = malloc(cdbei->len);
776 memcpy(eptr->ep_key, &cdbei->ptr[sizeof(long)], eptr->ep_keylen);
786 /* Phase 2: delete the records */
787 syslog(LOG_DEBUG, "Purge euid index: phase 2");
789 cdb_delete(CDB_EUIDINDEX, el->ep_key, el->ep_keylen);
796 syslog(LOG_DEBUG, "Purge euid index: finished (purged %d records)", purged);
803 * Purge OpenID assocations for missing users (theoretically this will never delete anything)
805 int PurgeStaleOpenIDassociations(void) {
806 struct cdbdata *cdboi;
807 struct ctdluser usbuf;
808 HashList *keys = NULL;
810 char *deleteme = NULL;
817 keys = NewHash(1, NULL);
818 if (!keys) return(0);
821 cdb_rewind(CDB_OPENID);
822 while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
823 if (cdboi->len > sizeof(long)) {
824 memcpy(&usernum, cdboi->ptr, sizeof(long));
825 if (CtdlGetUserByNumber(&usbuf, usernum) != 0) {
826 deleteme = strdup(cdboi->ptr + sizeof(long)),
827 Put(keys, deleteme, strlen(deleteme), deleteme, NULL);
833 /* Go through the hash list, deleting keys we stored in it */
835 HashPos = GetNewHashPos(keys, 0);
836 while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
838 syslog(LOG_DEBUG, "Deleting associated OpenID <%s>", (char*)Value);
839 cdb_delete(CDB_OPENID, Value, strlen(Value));
840 /* note: don't free(Value) -- deleting the hash list will handle this for us */
843 DeleteHashPos(&HashPos);
852 void purge_databases(void)
855 static time_t last_purge = 0;
859 /* Do the auto-purge if the current hour equals the purge hour,
860 * but not if the operation has already been performed in the
861 * last twelve hours. This is usually enough granularity.
864 localtime_r(&now, &tm);
866 ((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200))
867 && (force_purge_now == 0)
872 syslog(LOG_INFO, "Auto-purger: starting.");
874 if (!server_shutting_down)
876 retval = PurgeUsers();
877 syslog(LOG_NOTICE, "Purged %d users.", retval);
880 if (!server_shutting_down)
883 syslog(LOG_NOTICE, "Expired %d messages.", messages_purged);
886 if (!server_shutting_down)
888 retval = PurgeRooms();
889 syslog(LOG_NOTICE, "Expired %d rooms.", retval);
892 if (!server_shutting_down)
894 retval = PurgeVisits();
895 syslog(LOG_NOTICE, "Purged %d visits.", retval);
898 if (!server_shutting_down)
900 retval = PurgeUseTable();
901 syslog(LOG_NOTICE, "Purged %d entries from the use table.", retval);
904 if (!server_shutting_down)
906 retval = PurgeEuidIndexTable();
907 syslog(LOG_NOTICE, "Purged %d entries from the EUID index.", retval);
910 if (!server_shutting_down)
912 retval = PurgeStaleOpenIDassociations();
913 syslog(LOG_NOTICE, "Purged %d stale OpenID associations.", retval);
916 if (!server_shutting_down)
918 retval = TDAP_ProcessAdjRefCountQueue();
919 syslog(LOG_NOTICE, "Processed %d message reference count adjustments.", retval);
922 if (!server_shutting_down)
924 syslog(LOG_INFO, "Auto-purger: finished.");
925 last_purge = now; /* So we don't do it again soon */
929 syslog(LOG_INFO, "Auto-purger: STOPPED.");
935 * Manually initiate a run of The Dreaded Auto-Purger (tm)
937 void cmd_tdap(char *argbuf) {
938 if (CtdlAccessCheck(ac_aide)) return;
940 cprintf("%d Manually initiating a purger run now.\n", CIT_OK);
945 CTDL_MODULE_INIT(expire)
949 CtdlRegisterProtoHook(cmd_tdap, "TDAP", "Manually initiate auto-purger");
950 CtdlRegisterProtoHook(cmd_gpex, "GPEX", "Get expire policy");
951 CtdlRegisterProtoHook(cmd_spex, "SPEX", "Set expire policy");
952 CtdlRegisterSessionHook(purge_databases, EVT_TIMER);
955 /* return our module name for the log */