*
*/
-#ifdef DLL_EXPORT
-#define IN_LIBCIT
-#endif
-
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
+#include <dirent.h>
#include <errno.h>
#include <limits.h>
/* #include <dlfcn.h> */
#include "policy.h"
#include "control.h"
#include "tools.h"
+#include "euidindex.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
check_ref_counts();
lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
- create_room(BASEROOM, 0, "", 0, 1, 0, VIEW_BBS);
+ create_room(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
lputroom(&qrbuf);
}
+ /*
+ * Create a room in which we can deposit "deleted" messages for
+ * deferred deletion. This will silently fail if the room already
+ * exists, and that's perfectly ok, because we want it to exist.
+ */
+ create_room(DELETED_MSGS_ROOM, 3, "", 0, 1, 0, VIEW_MAILBOX);
+
+ /*
+ * Make sure it's set to be a "system room" so it doesn't show up
+ * in the <K>nown rooms list for Aides. Also set the message expire
+ * policy to "by count, 1 message" so everything gets deleted all
+ * the time (we can't set it to 0 because that's invalid, so we keep
+ * a single message around).
+ */
+ if (lgetroom(&qrbuf, DELETED_MSGS_ROOM) == 0) {
+ qrbuf.QRflags2 |= QR2_SYSTEM;
+ qrbuf.QRep.expire_mode = EXPIRE_NUMMSGS;
+ qrbuf.QRep.expire_value = 1;
+ lputroom(&qrbuf);
+ }
+
lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
urandom = fopen("/dev/urandom", "r");
if (urandom != NULL) {
(*fcn->h_function_pointer)();
}
+ /* Shut down the indexer thread */
+ lprintf(CTDL_INFO, "Waiting for the indexer thread to shut down\n");
+ pthread_join(indexer_thread_tid, NULL);
+
+ /* Shut down the checkpoint thread */
+ lprintf(CTDL_INFO, "Waiting for the checkpoint thread to shut down\n");
+ pthread_join(checkpoint_thread_tid, NULL);
+
/* Close databases */
lprintf(CTDL_INFO, "Closing databases\n");
close_databases();
lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
logout(con);
- unlink(con->temp);
lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
/* If the client is still connected, blow 'em away. */
cprintf("%s\n", config.c_fqdn);
cprintf("%s\n", CITADEL);
cprintf("%d\n", REV_LEVEL);
- cprintf("%s\n", config.c_bbs_city);
+ cprintf("%s\n", config.c_site_location);
cprintf("%s\n", config.c_sysadm);
cprintf("%d\n", SERVER_TYPE);
cprintf("%s\n", config.c_moreprompt);
static time_t pc_timestamp = 0;
static char public_clients[SIZ];
+#ifndef HAVE_ETC
#define PUBLIC_CLIENTS "./public_clients"
+#else
+#define PUBLIC_CLIENTS ETC_DIR"/public_clients"
+#endif
/*
* Check the time stamp on the public_clients file. If it's been
strcat(public_clients, addrbuf);
}
- fp = fopen("public_clients", "r");
+ fp = fopen(
+#ifndef HAVE_ETC
+ "."
+#else
+ ETC_DIR
+#endif
+ "/public_clients", "r");
if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
for (i=0; i<strlen(buf); ++i) {
if (buf[i] == '#') buf[i] = 0;
char buf[256];
char buf2[256];
char *dirs[2];
+ DIR *dp;
+ struct dirent *d;
extract_token(buf, mname, 0, '|', sizeof buf);
+#ifdef HAVE_DATA_DIR
+ dirs[0] = strdup(DATA_DIR "/messages");
+#else
dirs[0] = strdup("messages");
+#endif
+
+#ifdef HAVE_DATA_DIR
+ dirs[1] = strdup(DATA_DIR "/help");
+#else
dirs[1] = strdup("help");
- snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp);
- mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
- if (strlen(targ) == 0) {
- snprintf(buf2, sizeof buf2, "%s.%d", buf, CC->cs_clientdev);
+#endif
+
+ snprintf(buf2, sizeof buf2, "%s.%d.%d",
+ buf, CC->cs_clientdev, CC->cs_clienttyp);
+
+ /* If the client requested "?" then produce a listing */
+ if (!strcmp(buf, "?")) {
+ cprintf("%d %s\n",LISTING_FOLLOWS,buf);
+ dp = opendir(dirs[1]);
+ if (dp != NULL) {
+ while (d = readdir(dp), d != NULL) {
+ if (d->d_name[0] != '.') {
+ cprintf(" %s\n", d->d_name);
+ }
+ }
+ closedir(dp);
+ }
+ cprintf("000\n");
+ }
+
+ /* Otherwise, look for the requested file by name. */
+ else {
mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
if (strlen(targ) == 0) {
- mesg_locate(targ, sizeof targ, buf, 2, (const char **)dirs);
- }
+ snprintf(buf2, sizeof buf2, "%s.%d",
+ buf, CC->cs_clientdev);
+ mesg_locate(targ, sizeof targ, buf2, 2,
+ (const char **)dirs);
+ if (strlen(targ) == 0) {
+ mesg_locate(targ, sizeof targ, buf, 2,
+ (const char **)dirs);
+ }
+ }
}
+
free(dirs[0]);
free(dirs[1]);
if (buf[a] == '/') buf[a] = '.';
}
+#ifdef HAVE_DATA_DIR
+ dirs[0] = strdup(DATA_DIR "/messages");
+#else
dirs[0] = strdup("messages");
+#endif
+
+#ifdef HAVE_DATA_DIR
+ dirs[1] = strdup(DATA_DIR "/help");
+#else
dirs[1] = strdup("help");
+#endif
+
mesg_locate(targ, sizeof targ, buf, 2, (const char**)dirs);
free(dirs[0]);
free(dirs[1]);
if (strlen(targ)==0) {
- snprintf(targ, sizeof targ, "./help/%s", buf);
+ snprintf(targ, sizeof targ,
+#ifndef HAVE_DATA_DIR
+ "."
+#else
+ DATA_DIR
+#endif
+ "/help/%s", buf);
}
mfp = fopen(targ,"w");
strcpy(con->lastcmdname, " ");
strcpy(con->cs_clientname, "(unknown)");
strcpy(con->curr_user, NLI);
- strcpy(con->net_node,"");
+ strcpy(con->net_node, "");
strcpy(con->fake_username, "");
strcpy(con->fake_postname, "");
strcpy(con->fake_hostname, "");
strcpy(con->fake_roomname, "");
generate_nonce(con);
- safestrncpy(con->temp, tmpnam(NULL), sizeof con->temp);
safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
con->cs_host[sizeof con->cs_host - 1] = 0;
* This loop recognizes all server commands.
*/
void do_command_loop(void) {
- char cmdbuf[1024];
+ char cmdbuf[SIZ];
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
- lprintf(CTDL_ERR, "Client socket is broken; ending session\n");
+ lprintf(CTDL_ERR, "Client disconnected: ending session.\n");
CC->kill_me = 1;
return;
}
cmd_rdir();
}
+ else if (!strncasecmp(cmdbuf,"EUID",4)) {
+ cmd_euid(&cmdbuf[5]);
+ }
+
else if (!strncasecmp(cmdbuf,"MSG0",4)) {
cmd_msg0(&cmdbuf[5]);
}
}
else if (!strncasecmp(cmdbuf,"LIST",4)) {
- cmd_list();
+ cmd_list(&cmdbuf[5]);
}
else if (!strncasecmp(cmdbuf,"CHEK",4)) {