$Log$
+ Revision 614.55 2004/02/27 17:23:21 error
+ * Use syslog-compatible logging levels in lprintf(); the loglevel chosen
+ is passed directly to syslog(). The available levels are docuemnted in
+ sysdep_decls.h.
+
Revision 614.54 2004/02/27 04:29:00 ajc
* Fixed a bug in PLAIN authentication
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
#define FILTERLIST "application/x-citadel-filter-list"
#define SPAMSTRINGS "application/x-citadel-spam-strings"
-#define TRACE lprintf(9, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
+#define TRACE lprintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
#ifndef LONG_MAX
#define LONG_MAX 2147483647L
FILE *urandom;
struct ctdlroom qrbuf;
- lprintf(9, "master_startup() started\n");
+ lprintf(CTDL_DEBUG, "master_startup() started\n");
time(&server_startup_time);
- lprintf(7, "Opening databases\n");
+ lprintf(CTDL_INFO, "Opening databases\n");
open_databases();
if (do_defrag) {
check_ref_counts();
- lprintf(7, "Creating base rooms (if necessary)\n");
+ lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
create_room(BASEROOM, 0, "", 0, 1, 0);
create_room(AIDEROOM, 3, "", 0, 1, 0);
create_room(SYSCONFIGROOM, 3, "", 0, 1, 0);
lputroom(&qrbuf);
}
- lprintf(7, "Seeding the pseudo-random number generator...\n");
+ lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
urandom = fopen("/dev/urandom", "r");
if (urandom != NULL) {
fread(&seed, sizeof seed, 1, urandom);
}
srandom(seed);
- lprintf(7, "Initializing ipgm secret\n");
+ lprintf(CTDL_INFO, "Initializing ipgm secret\n");
get_config();
config.c_ipgm_secret = rand();
put_config();
- lprintf(9, "master_startup() finished\n");
+ lprintf(CTDL_DEBUG, "master_startup() finished\n");
}
}
/* Close databases */
- lprintf(7, "Closing databases\n");
+ lprintf(CTDL_INFO, "Closing databases\n");
close_databases();
/* Do system-dependent stuff */
sysdep_master_cleanup();
/* Now go away. */
- lprintf(3, "citserver: exiting.\n");
+ lprintf(CTDL_NOTICE, "citserver: exiting.\n");
fflush(stdout); fflush(stderr);
exit(0);
}
begin_critical_section(S_SESSION_TABLE);
while (con->FirstSessData != NULL) {
- lprintf(9, "Deallocating user data symbol %ld\n",
+ lprintf(CTDL_DEBUG, "Deallocating user data symbol %ld\n",
con->FirstSessData->sym_id);
if (con->FirstSessData->sym_data != NULL)
phree(con->FirstSessData->sym_data);
struct CitContext *ToFree = NULL;
if (con==NULL) {
- lprintf(5, "WARNING: RemoveContext() called with NULL!\n");
+ lprintf(CTDL_ERR, "WARNING: RemoveContext() called with NULL!\n");
return;
}
- lprintf(9, "RemoveContext() called\n");
+ lprintf(CTDL_DEBUG, "RemoveContext() called\n");
/* Remove the context from the global context list. This needs
* to get done FIRST to avoid concurrency problems. It is *vitally*
* important to keep num_sessions accurate!!
*/
- lprintf(7, "Removing context for session %d\n", con->cs_pid);
+ lprintf(CTDL_DEBUG, "Removing context for session %d\n", con->cs_pid);
begin_critical_section(S_SESSION_TABLE);
if (ContextList == con) {
ToFree = ContextList;
end_critical_section(S_SESSION_TABLE);
if (ToFree == NULL) {
- lprintf(9, "RemoveContext() found nothing to remove\n");
+ lprintf(CTDL_DEBUG, "RemoveContext() found nothing to remove\n");
return;
}
become_session(NULL);
/* Now handle all of the administrivia. */
- lprintf(7, "Calling logout(%d)\n", con->cs_pid);
+ lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
logout(con);
unlink(con->temp);
- lprintf(3, "Session %d: ended.\n", con->cs_pid);
+ lprintf(CTDL_NOTICE, "Session %d: ended.\n", con->cs_pid);
/* Deallocate any user-data attached to this session */
deallocate_user_data(con);
/* If the client is still connected, blow 'em away. */
- lprintf(7, "Closing socket %d\n", con->client_socket);
+ lprintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
close(con->client_socket);
/* This is where we used to check for scheduled shutdowns. */
/* Free up the memory used by this context */
phree(con);
- lprintf(9, "Done with RemoveContext()\n");
+ lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
}
if (ptr->sym_id == requested_sym)
return(ptr->sym_data);
- lprintf(2, "ERROR! CtdlGetUserData(%ld) symbol not allocated\n",
+ lprintf(CTDL_ERR, "ERROR! CtdlGetUserData(%ld) symbol not allocated\n",
requested_sym);
return NULL;
}
{
struct CtdlSessData *ptr;
- lprintf(9, "CtdlAllocUserData(%ld) called\n", requested_sym);
+ lprintf(CTDL_DEBUG, "CtdlAllocUserData(%ld) called\n", requested_sym);
/* Fail silently if the symbol is already registered. */
for (ptr = CC->FirstSessData; ptr != NULL; ptr = ptr->next) {
CC->FirstSessData = ptr;
end_critical_section(S_SESSION_TABLE);
- lprintf(9, "CtdlAllocUserData(%ld) finished\n", requested_sym);
+ lprintf(CTDL_DEBUG, "CtdlAllocUserData(%ld) finished\n", requested_sym);
}
}
}
- lprintf(2, "CtdlReallocUserData() ERROR: symbol %ld not found!\n",
+ lprintf(CTDL_ERR, "CtdlReallocUserData() ERROR: symbol %ld not found!\n",
requested_sym);
}
*/
if (stat(PUBLIC_CLIENTS, &statbuf) != 0) {
/* No public_clients file exists, so bail out */
- lprintf(5, "Warning: '%s' does not exist\n", PUBLIC_CLIENTS);
+ lprintf(CTDL_WARNING, "Warning: '%s' does not exist\n", PUBLIC_CLIENTS);
return(0);
}
if (statbuf.st_mtime > pc_timestamp) {
begin_critical_section(S_PUBLIC_CLIENTS);
- lprintf(7, "Loading %s\n", PUBLIC_CLIENTS);
+ lprintf(CTDL_INFO, "Loading %s\n", PUBLIC_CLIENTS);
strcpy(public_clients, "127.0.0.1");
if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
end_critical_section(S_PUBLIC_CLIENTS);
}
- lprintf(9, "Checking whether %s is a local or public client\n",
+ lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
CC->cs_addr);
for (i=0; i<num_parms(public_clients); ++i) {
extract(addrbuf, public_clients, i);
if (!strcasecmp(CC->cs_addr, addrbuf)) {
- lprintf(9, "... yes it is.\n");
+ lprintf(CTDL_DEBUG, "... yes it is.\n");
return(1);
}
}
/* No hits. This is not a public client. */
- lprintf(9, "... no it isn't.\n");
+ lprintf(CTDL_DEBUG, "... no it isn't.\n");
return(0);
}
}
if (do_lookup) {
- lprintf(9, "Looking up hostname '%s'\n", from_host);
+ lprintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
if ((addr.s_addr = inet_addr(from_host)) != -1) {
locate_host(CC->cs_host, sizeof CC->cs_host,
NULL, 0,
}
}
- lprintf(3,"Client %d/%d/%01d.%02d (%s) from %s\n",
+ lprintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
dev_code,
cli_code,
(rev_level / 100),
return;
}
- lprintf(9, "Locating session to kill\n");
+ lprintf(CTDL_DEBUG, "Locating session to kill\n");
begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
if (session_num == ccptr->cs_pid) {
else {
sleep(5);
cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED);
- lprintf(3, "Warning: ipgm authentication failed.\n");
+ lprintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
CC->kill_me = 1;
}
if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions))
con->nologin = 1;
- lprintf(3, "Session started.\n");
+ lprintf(CTDL_NOTICE, "Session started.\n");
/* Run any session startup routines registered by loadable modules */
PerformSessionHooks(EVT_START);
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_gets(cmdbuf) < 1) {
- lprintf(3, "Client socket is broken. Ending session.\n");
+ lprintf(CTDL_ERR, "Client socket is broken. Ending session.\n");
CC->kill_me = 1;
return;
}
- lprintf(5, "Citadel: %s\n", cmdbuf);
+ lprintf(CTDL_INFO, "Citadel: %s\n", cmdbuf);
/*
* Let other clients see the last command we executed, and
if (pse) {
sin.sin_port = pse->s_port;
} else if ((sin.sin_port = htons((u_short) atoi(service))) == 0) {
- lprintf(3, "Can't get %s service entry: %s\n",
+ lprintf(CTDL_CRIT, "Can't get %s service entry: %s\n",
service, strerror(errno));
return(-1);
}
if (phe) {
memcpy(&sin.sin_addr, phe->h_addr, phe->h_length);
} else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
- lprintf(3, "Can't get %s host entry: %s\n",
+ lprintf(CTDL_ERR, "Can't get %s host entry: %s\n",
host, strerror(errno));
return(-1);
}
if ((ppe = getprotobyname(protocol)) == 0) {
- lprintf(3, "Can't get %s protocol entry: %s\n",
+ lprintf(CTDL_CRIT, "Can't get %s protocol entry: %s\n",
protocol, strerror(errno));
return(-1);
}
s = socket(PF_INET, type, ppe->p_proto);
if (s < 0) {
- lprintf(3, "Can't create socket: %s\n", strerror(errno));
+ lprintf(CTDL_CRIT, "Can't create socket: %s\n", strerror(errno));
return(-1);
}
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- lprintf(3, "Can't connect to %s:%s: %s\n",
+ lprintf(CTDL_ERR, "Can't connect to %s:%s: %s\n",
host, service, strerror(errno));
close(s);
return(-1);
retval = select(sock+1, &rfds, NULL, NULL, &tv);
if (FD_ISSET(sock, &rfds) == 0) { /* timed out */
- lprintf(9, "sock_read() timed out.\n");
+ lprintf(CTDL_ERR, "sock_read() timed out.\n");
return(-1);
}
rlen = read(sock, &buf[len], bytes-len);
if (rlen<1) {
- lprintf(2, "sock_read() failed: %s\n",
+ lprintf(CTDL_ERR, "sock_read() failed: %s\n",
strerror(errno));
return(-1);
}
}
}
if (control_fp == NULL) {
- lprintf(1, "ERROR opening citadel.control: %s\n",
+ lprintf(CTDL_ALERT, "ERROR opening citadel.control: %s\n",
strerror(errno));
return;
}
ret = tid->abort(tid);
if (ret) {
- lprintf(1, "cdb_*: txn_abort: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: txn_abort: %s\n", db_strerror(ret));
abort();
}
}
ret = tid->commit(tid, 0);
if (ret) {
- lprintf(1, "cdb_*: txn_commit: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: txn_commit: %s\n", db_strerror(ret));
abort();
}
}
ret = dbenv->txn_begin(dbenv, NULL, tid, 0);
if (ret) {
- lprintf(1, "cdb_*: txn_begin: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: txn_begin: %s\n", db_strerror(ret));
abort();
}
}
int ret;
if ((ret = cursor->c_close(cursor))) {
- lprintf(1, "cdb_*: c_close: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: c_close: %s\n", db_strerror(ret));
abort();
}
}
for (i = 0; i < MAXCDB; i++)
if (cursors[i] != NULL)
{
- lprintf(1, "cdb_*: cursor still in progress on cdb %d: %s\n", i, msg);
+ lprintf(CTDL_EMERG, "cdb_*: cursor still in progress on cdb %d: %s\n", i, msg);
abort();
}
}
bailIfCursor(tsd->cursors, "in check_handles");
if (tsd->tid != NULL) {
- lprintf(1, "cdb_*: transaction still in progress!");
+ lprintf(CTDL_EMERG, "cdb_*: transaction still in progress!");
abort();
}
}
char **file, **list;
char errmsg[SIZ];
- lprintf(5, "Database log file cull started.\n");
+ lprintf(CTDL_INFO, "Database log file cull started.\n");
flags = DB_ARCH_ABS;
/* Get the list of names. */
if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) {
- lprintf(1, "cdb_cull_logs: %s\n", db_strerror(ret));
+ lprintf(CTDL_ERR, "cdb_cull_logs: %s\n", db_strerror(ret));
return;
}
/* Print the list of names. */
if (list != NULL) {
for (file = list; *file != NULL; ++file) {
- lprintf(9, "Deleting log: %s\n", *file);
+ lprintf(CTDL_DEBUG, "Deleting log: %s\n", *file);
ret = unlink(*file);
if (ret != 0) {
snprintf(errmsg, sizeof(errmsg),
free(list);
}
- lprintf(5, "Database log file cull ended.\n");
+ lprintf(CTDL_INFO, "Database log file cull ended.\n");
}
0);
if (ret != 0) {
- lprintf(1, "cdb_checkpoint: txn_checkpoint: %s\n",
+ lprintf(CTDL_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n",
db_strerror(ret));
abort();
}
getcwd(dbdirname, sizeof dbdirname);
strcat(dbdirname, "/data");
- lprintf(9, "cdb_*: open_databases() starting\n");
- lprintf(9, "Compiled db: %s\n", DB_VERSION_STRING);
- lprintf(5, " Linked db: %s\n", db_version(NULL, NULL, NULL));
+ lprintf(CTDL_DEBUG, "cdb_*: open_databases() starting\n");
+ lprintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
+ lprintf(CTDL_INFO, " Linked db: %s\n", db_version(NULL, NULL, NULL));
#ifdef HAVE_ZLIB
- lprintf(5, "Linked zlib: %s\n", zlibVersion());
+ lprintf(CTDL_INFO, "Linked zlib: %s\n", zlibVersion());
#endif
/*
*/
mkdir(dbdirname, 0700);
- lprintf(9, "cdb_*: Setting up DB environment\n");
+ lprintf(CTDL_DEBUG, "cdb_*: Setting up DB environment\n");
db_env_set_func_yield(sched_yield);
ret = db_env_create(&dbenv, 0);
if (ret) {
- lprintf(1, "cdb_*: db_env_create: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: db_env_create: %s\n", db_strerror(ret));
exit(ret);
}
dbenv->set_errpfx(dbenv, "citserver");
*/
ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0);
if (ret) {
- lprintf(1, "cdb_*: set_cachesize: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: set_cachesize: %s\n", db_strerror(ret));
dbenv->close(dbenv, 0);
exit(ret);
}
if ((ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT))) {
- lprintf(1, "cdb_*: set_lk_detect: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: set_lk_detect: %s\n", db_strerror(ret));
dbenv->close(dbenv, 0);
exit(ret);
}
flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE|DB_INIT_TXN|
DB_INIT_LOCK|DB_THREAD;
- lprintf(9, "dbenv->open(dbenv, %s, %d, 0)\n", dbdirname, flags);
+ lprintf(CTDL_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", dbdirname, flags);
ret = dbenv->open(dbenv, dbdirname, flags, 0);
if (ret) {
- lprintf(1, "cdb_*: dbenv->open: %s\n", db_strerror(ret));
+ lprintf(CTDL_DEBUG, "cdb_*: dbenv->open: %s\n", db_strerror(ret));
dbenv->close(dbenv, 0);
exit(ret);
}
- lprintf(7, "cdb_*: Starting up DB\n");
+ lprintf(CTDL_INFO, "cdb_*: Starting up DB\n");
for (i = 0; i < MAXCDB; ++i) {
/* Create a database handle */
ret = db_create(&dbp[i], dbenv, 0);
if (ret) {
- lprintf(1, "cdb_*: db_create: %s\n", db_strerror(ret));
+ lprintf(CTDL_DEBUG, "cdb_*: db_create: %s\n", db_strerror(ret));
exit(ret);
}
,
0600);
if (ret) {
- lprintf(1, "cdb_*: db_open[%d]: %s\n", i, db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: db_open[%d]: %s\n", i, db_strerror(ret));
exit(ret);
}
}
if ((ret = pthread_key_create(&tsdkey, dest_tsd))) {
- lprintf(1, "cdb_*: pthread_key_create: %s\n", strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: pthread_key_create: %s\n", strerror(ret));
exit(1);
}
cdb_allocate_tsd();
CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER);
- lprintf(9, "cdb_*: open_databases() finished\n");
+ lprintf(CTDL_DEBUG, "cdb_*: open_databases() finished\n");
}
cdb_free_tsd();
if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) {
- lprintf(1, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret));
abort();
}
for (a = 0; a < MAXCDB; ++a) {
- lprintf(7, "cdb_*: Closing database %d\n", a);
+ lprintf(CTDL_INFO, "cdb_*: Closing database %d\n", a);
ret = dbp[a]->close(dbp[a], 0);
if (ret) {
- lprintf(1, "cdb_*: db_close: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: db_close: %s\n", db_strerror(ret));
abort();
}
/* Close the handle. */
ret = dbenv->close(dbenv, 0);
if (ret) {
- lprintf(1, "cdb_*: DBENV->close: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_*: DBENV->close: %s\n", db_strerror(ret));
abort();
}
}
compressed_data,
sourceLen
) != Z_OK) {
- lprintf(1, "uncompress() error\n");
+ lprintf(CTDL_EMERG, "uncompress() error\n");
abort();
}
(uLongf) cdatalen,
1
) != Z_OK) {
- lprintf(1, "compress2() error\n");
+ lprintf(CTDL_EMERG, "compress2() error\n");
abort();
}
zheader.compressed_len = (size_t) destLen;
0); /* flags */
if (ret)
{
- lprintf(1, "cdb_store(%d): %s\n", cdb,
- db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
abort();
}
#ifdef HAVE_ZLIB
}
else
{
- lprintf(1, "cdb_store(%d): %s\n", cdb,
- db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
abort();
}
}
ret = dbp[cdb]->del(dbp[cdb], MYTID, &dkey, 0);
if (ret)
{
- lprintf(1, "cdb_delete(%d): %s\n", cdb,
- db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
if (ret != DB_NOTFOUND)
abort();
}
}
else
{
- lprintf(1, "cdb_delete(%d): %s\n", cdb,
- db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
abort();
}
}
if (ret)
{
- lprintf(1, "localcursor: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "localcursor: %s\n", db_strerror(ret));
abort();
}
if ((ret != 0) && (ret != DB_NOTFOUND))
{
- lprintf(1, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
abort();
}
if (tempcdb == NULL)
{
- lprintf(2, "cdb_fetch: Cannot allocate memory for tempcdb\n");
+ lprintf(CTDL_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n");
abort();
}
*/
ret = dbp[cdb]->cursor(dbp[cdb], MYTID, &MYCURSORS[cdb], 0);
if (ret) {
- lprintf(1, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
abort();
}
}
if (ret) {
if (ret != DB_NOTFOUND) {
- lprintf(1, "cdb_next_item(%d): %s\n",
+ lprintf(CTDL_EMERG, "cdb_next_item(%d): %s\n",
cdb, db_strerror(ret));
abort();
}
if (MYTID != NULL)
{
- lprintf(1, "cdb_begin_transaction: ERROR: nested transaction\n");
+ lprintf(CTDL_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n");
abort();
}
for (i = 0; i < MAXCDB; i++)
if (MYCURSORS[i] != NULL) {
- lprintf(1, "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n", i);
+ lprintf(CTDL_WARNING, "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n", i);
cclose(MYCURSORS[i]);
MYCURSORS[i] = NULL;
}
if (MYTID == NULL)
{
- lprintf(1, "cdb_end_transaction: ERROR: txcommit(NULL) !!\n");
+ lprintf(CTDL_EMERG, "cdb_end_transaction: ERROR: txcommit(NULL) !!\n");
abort();
}
else
if (MYTID != NULL)
{
- lprintf(1, "cdb_trunc must not be called in a transaction.\n");
+ lprintf(CTDL_EMERG, "cdb_trunc must not be called in a transaction.\n");
abort();
}
else
}
else
{
- lprintf(1, "cdb_truncate(%d): %s\n", cdb,
- db_strerror(ret));
+ lprintf(CTDL_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret));
abort();
}
}
for (qdcount = ntohs(answer.header.qdcount); qdcount--; ptr += ret + QFIXEDSZ) {
if ((ret = dn_skipname(ptr, endptr)) < 0) {
- lprintf(9, "dn_skipname error\n");
+ lprintf(CTDL_DEBUG, "dn_skipname error\n");
return(0);
}
}
break;
}
- if (nttlist != NULL) lprintf(9, "nttlist=<%s>\n", nttlist);
+ if (nttlist != NULL) lprintf(CTDL_DEBUG, "nttlist=<%s>\n", nttlist);
end_critical_section(S_NTTLIST);
return(retval);
}
}
}
end_critical_section(S_SESSION_TABLE);
- lprintf(9, "Terminated %d idle sessions\n", killed);
+ if (killed > 0)
+ lprintf(CTDL_INFO, "Terminated %d idle sessions\n", killed);
}
void check_sched_shutdown(void) {
if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
- lprintf(3, "Scheduled shutdown initiating.\n");
+ lprintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n");
time_to_die = 1;
}
}
struct floor flbuf;
int a;
- lprintf(7, "Checking floor reference counts\n");
+ lprintf(CTDL_DEBUG, "Checking floor reference counts\n");
for (a=0; a<MAXFLOORS; ++a) {
getfloor(&flbuf, a);
flbuf.f_ref_count = 0;
tmp = tmpfile();
if (tmp == NULL) {
- lprintf(1, "Cannot open temp file: %s\n",
- strerror(errno));
+ lprintf(CTDL_CRIT, "Cannot open temp file: %s\n",
+ strerror(errno));
return;
}
HEADERS_ALL, 0, 1);
CtdlRedirectOutput(NULL, -1);
if (!is_valid_message(msg)) {
- lprintf(1, "WARNING: output clobbered the message!\n");
+ lprintf(CTDL_ERR, "WARNING: output clobbered the message!\n");
}
/*
for (i=0; i<strlen(section); ++i) {
if (section[i]==']') section[i] = 0;
}
- lprintf(9, "Section is %s\n", section);
+ lprintf(CTDL_DEBUG, "Section is %s\n", section);
/* extract partial */
strcpy(partial, item);
if (partial[i]=='>') partial[i] = 0;
}
if (is_partial == 0) strcpy(partial, "");
- if (strlen(partial) > 0) lprintf(9, "Partial is %s\n", partial);
+ if (strlen(partial) > 0) lprintf(CTDL_DEBUG, "Partial is %s\n", partial);
tmp = tmpfile();
if (tmp == NULL) {
- lprintf(1, "Cannot open temp file: %s\n", strerror(errno));
+ lprintf(CTDL_CRIT, "Cannot open temp file: %s\n", strerror(errno));
return;
}
}
/* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */
- lprintf(9, "Converting newline format\n");
+ lprintf(CTDL_DEBUG, "Converting newline format\n");
for (i=0; i<literal_length; ++i) {
if (!strncmp(&IMAP->transmitted_message[i], "\r\n", 2)) {
strcpy(&IMAP->transmitted_message[i],
}
}
- lprintf(9, "Converting message format\n");
+ lprintf(CTDL_DEBUG, "Converting message format\n");
msg = convert_internet_message(IMAP->transmitted_message);
IMAP->transmitted_message = NULL;
IMAP->transmitted_length = 0;
CtdlFreeMessage(msg);
}
else {
- lprintf(1, "SEARCH internal error\n");
+ lprintf(CTDL_ERR, "SEARCH internal error\n");
}
}
cprintf("\r\n");
}
***/
- lprintf(9, "(That translates to \"%s\")\n", rbuf);
+ lprintf(CTDL_DEBUG, "(That translates to \"%s\")\n", rbuf);
return(ret);
}
else if (!strcasecmp(key, "From")) {
process_rfc822_addr(value, user, node, name);
- lprintf(9, "Converted to <%s@%s> (%s)\n", user, node, name);
+ lprintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
snprintf(addr, sizeof addr, "%s@%s", user, node);
if (msg->cm_fields['A'] == NULL)
msg->cm_fields['A'] = strdoop(name);
else if (!strcasecmp(key, "Message-ID")) {
if (msg->cm_fields['I'] != NULL) {
- lprintf(5, "duplicate message id\n");
+ lprintf(CTDL_WARNING, "duplicate message id\n");
}
if (msg->cm_fields['I'] == NULL) {
msg->cm_format_type = FMT_RFC822; /* internet message */
msg->cm_fields['M'] = rfc822;
- lprintf(9, "Unconverted RFC822 message length = %ld\n", (long)strlen(rfc822));
+ lprintf(CTDL_DEBUG, "Unconverted RFC822 message length = %ld\n", (long)strlen(rfc822));
pos = 0;
done = 0;
msg->cm_fields['T'] = strdoop(buf);
}
- lprintf(9, "RFC822 length remaining after conversion = %ld\n",
+ lprintf(CTDL_DEBUG, "RFC822 length remaining after conversion = %ld\n",
(long)strlen(rfc822));
return msg;
}
}
key[keylen++] = 0;
- lprintf(9, "Directory key is <%s>\n", key);
+ lprintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
}
striplt(domain);
h = CtdlHostAlias(domain);
- lprintf(9, "IsDirectory(%s)\n", domain);
+ lprintf(CTDL_DEBUG, "IsDirectory(%s)\n", domain);
if ( (h == hostalias_localhost) || (h == hostalias_directory) ) {
- lprintf(9, " ...yes\n");
+ lprintf(CTDL_DEBUG, " ...yes\n");
return(1);
}
else {
- lprintf(9, " ...no\n");
+ lprintf(CTDL_DEBUG, " ...no\n");
return(0);
}
}
void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
char key[SIZ];
- lprintf(9, "Dir: %s --> %s\n",
+ lprintf(CTDL_DEBUG, "Dir: %s --> %s\n",
internet_addr, citadel_addr);
if (IsDirectory(internet_addr) == 0) return;
int a1, a2, a3, a4;
char address_string[SIZ];
- lprintf(9, "locate_host() called\n");
+ lprintf(CTDL_DEBUG, "locate_host() called\n");
#ifdef HAVE_NONREENTRANT_NETDB
begin_critical_section(S_NETDB);
#endif
tbuf[63] = 0;
- lprintf(9, "locate_host() exiting\n");
+ lprintf(CTDL_DEBUG, "locate_host() exiting\n");
}
strcpy(name, aaa);
}
- lprintf(7, "Mail is being forwarded to %s\n", name);
+ lprintf(CTDL_INFO, "Mail is being forwarded to %s\n", name);
/* Change "user @ xxx" to "user" if xxx is an alias for this host */
for (a=0; a<strlen(name); ++a) {
if (name[a] == '@') {
if (CtdlHostAlias(&name[a+1]) == hostalias_localhost) {
name[a] = 0;
- lprintf(7, "Changed to <%s>\n", name);
+ lprintf(CTDL_INFO, "Changed to <%s>\n", name);
}
}
}
if (which_set == ctdlsetseen_seen) strcpy(vset, vbuf.v_seen);
if (which_set == ctdlsetseen_answered) strcpy(vset, vbuf.v_answered);
- lprintf(9, "before optimize: %s\n", vset);
+ lprintf(CTDL_DEBUG, "before optimize: %s\n", vset);
strcpy(newseen, "");
for (i=0; i<num_msgs; ++i) {
if (which_set == ctdlsetseen_seen) strcpy(vbuf.v_seen, newseen);
if (which_set == ctdlsetseen_answered) strcpy(vbuf.v_answered, newseen);
- lprintf(9, " after optimize: %s\n", newseen);
+ lprintf(CTDL_DEBUG, " after optimize: %s\n", newseen);
phree(msglist);
CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
}
*/
ch = *mptr++;
if (ch != 255) {
- lprintf(5, "Message %ld appears to be corrupted.\n", msgnum);
+ lprintf(CTDL_ERR, "Message %ld appears to be corrupted.\n", msgnum);
cdb_free(dmsgtext);
return NULL;
}
if (msg == NULL)
return 0;
if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
- lprintf(7, "is_valid_message() -- self-check failed\n");
+ lprintf(CTDL_WARNING, "is_valid_message() -- self-check failed\n");
return 0;
}
return 1;
void *content, char *cbtype, size_t length, char *encoding,
void *cbuserdata)
{
- lprintf(9, "fixed_output_pre() type=<%s>\n", cbtype);
+ lprintf(CTDL_DEBUG, "fixed_output_pre() type=<%s>\n", cbtype);
if (!strcasecmp(cbtype, "multipart/alternative")) {
++ma->is_ma;
ma->did_print = 0;
void *content, char *cbtype, size_t length, char *encoding,
void *cbuserdata)
{
- lprintf(9, "fixed_output_post() type=<%s>\n", cbtype);
+ lprintf(CTDL_DEBUG, "fixed_output_post() type=<%s>\n", cbtype);
if (!strcasecmp(cbtype, "multipart/alternative")) {
--ma->is_ma;
ma->did_print = 0;
char *wptr;
size_t wlen;
- lprintf(9, "fixed_output() type=<%s>\n", cbtype);
+ lprintf(CTDL_DEBUG, "fixed_output() type=<%s>\n", cbtype);
/*
* If we're in the middle of a multipart/alternative scope and
* we've already printed another section, skip this one.
*/
if ( (ma->is_ma == 1) && (ma->did_print == 1) ) {
- lprintf(9, "Skipping part %s (%s)\n", partnum, cbtype);
+ lprintf(CTDL_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
return;
}
ma->did_print = 1;
struct CtdlMessage *TheMessage;
int retcode;
- lprintf(7, "CtdlOutputMsg() msgnum=%ld, mode=%d\n",
+ lprintf(CTDL_DEBUG, "CtdlOutputMsg() msgnum=%ld, mode=%d\n",
msg_num, mode);
TheMessage = NULL;
nl = (crlf ? "\r\n" : "\n");
if (!is_valid_message(TheMessage)) {
- lprintf(1, "ERROR: invalid preloaded message for output\n");
+ lprintf(CTDL_ERR, "ERROR: invalid preloaded message for output\n");
return(om_no_such_msg);
}
long highest_msg = 0L;
struct CtdlMessage *msg = NULL;
- lprintf(9, "CtdlSaveMsgPointerInRoom(%s, %ld, %d)\n",
+ lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom(%s, %ld, %d)\n",
roomname, msgid, flags);
strcpy(hold_rm, CC->room.QRname);
if (getroom(&CC->room,
((roomname != NULL) ? roomname : CC->room.QRname) )
!= 0) {
- lprintf(9, "No such room <%s>\n", roomname);
+ lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
if (msg != NULL) CtdlFreeMessage(msg);
return(ERROR + ROOM_NOT_FOUND);
}
if (ReplicationChecks(msg) != 0) {
getroom(&CC->room, hold_rm);
if (msg != NULL) CtdlFreeMessage(msg);
- lprintf(9, "Did replication, and newer exists\n");
+ lprintf(CTDL_DEBUG, "Did replication, and newer exists\n");
return(0);
}
}
if (lgetroom(&CC->room,
((roomname != NULL) ? roomname : CC->room.QRname) )
!= 0) {
- lprintf(9, "No such room <%s>\n", roomname);
+ lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
if (msg != NULL) CtdlFreeMessage(msg);
return(ERROR + ROOM_NOT_FOUND);
}
} else {
msglist = mallok(cdbfr->len);
if (msglist == NULL)
- lprintf(3, "ERROR malloc msglist!\n");
+ lprintf(CTDL_ALERT, "ERROR malloc msglist!\n");
num_msgs = cdbfr->len / sizeof(long);
memcpy(msglist, cdbfr->ptr, cdbfr->len);
cdb_free(cdbfr);
(num_msgs * sizeof(long)));
if (msglist == NULL) {
- lprintf(3, "ERROR: can't realloc message list!\n");
+ lprintf(CTDL_ALERT, "ERROR: can't realloc message list!\n");
}
msglist[num_msgs - 1] = msgid;
/* Write our little bundle of joy into the message base */
if (cdb_store(CDB_MSGMAIN, &newmsgid, sizeof(long),
smr.ser, smr.len) < 0) {
- lprintf(2, "Can't store message\n");
+ lprintf(CTDL_ERR, "Can't store message\n");
retval = 0L;
} else {
retval = newmsgid;
ret->len = ret->len +
strlen(msg->cm_fields[(int)forder[i]]) + 2;
- lprintf(9, "serialize_message() calling malloc(%ld)\n", (long)ret->len);
+ lprintf(CTDL_DEBUG, "serialize_message() calling malloc(%ld)\n", (long)ret->len);
ret->ser = mallok(ret->len);
if (ret->ser == NULL) {
ret->len = 0;
strcpy(&ret->ser[wlen], msg->cm_fields[(int)forder[i]]);
wlen = wlen + strlen(msg->cm_fields[(int)forder[i]]) + 1;
}
- if (ret->len != wlen) lprintf(3, "ERROR: len=%ld wlen=%ld\n",
+ if (ret->len != wlen) lprintf(CTDL_ERR, "ERROR: len=%ld wlen=%ld\n",
(long)ret->len, (long)wlen);
return;
struct CtdlMessage *msg;
time_t timestamp = (-1L);
- lprintf(9, "check_repl() found message %ld\n", msgnum);
+ lprintf(CTDL_DEBUG, "check_repl() found message %ld\n", msgnum);
msg = CtdlFetchMessage(msgnum);
if (msg == NULL) return;
if (msg->cm_fields['T'] != NULL) {
if (timestamp > msg_repl->highest) {
msg_repl->highest = timestamp; /* newer! */
- lprintf(9, "newer!\n");
+ lprintf(CTDL_DEBUG, "newer!\n");
return;
}
- lprintf(9, "older!\n");
+ lprintf(CTDL_DEBUG, "older!\n");
/* Existing isn't newer? Then delete the old one(s). */
CtdlDeleteMessages(CC->room.QRname, msgnum, "");
struct CtdlMessage *template;
int abort_this = 0;
- lprintf(9, "ReplicationChecks() started\n");
+ lprintf(CTDL_DEBUG, "ReplicationChecks() started\n");
/* No extended id? Don't do anything. */
if (msg->cm_fields['E'] == NULL) return 0;
if (strlen(msg->cm_fields['E']) == 0) return 0;
- lprintf(9, "Extended ID: <%s>\n", msg->cm_fields['E']);
+ lprintf(CTDL_DEBUG, "Extended ID: <%s>\n", msg->cm_fields['E']);
CtdlAllocUserData(SYM_REPL, sizeof(struct repl));
strcpy(msg_repl->extended_id, msg->cm_fields['E']);
}
CtdlFreeMessage(template);
- lprintf(9, "ReplicationChecks() returning %d\n", abort_this);
+ lprintf(CTDL_DEBUG, "ReplicationChecks() returning %d\n", abort_this);
return(abort_this);
}
struct ser_ret smr;
char *hold_R, *hold_D;
- lprintf(9, "CtdlSubmitMsg() called\n");
+ lprintf(CTDL_DEBUG, "CtdlSubmitMsg() called\n");
if (is_valid_message(msg) == 0) return(-1); /* self check */
/* If this message has no timestamp, we take the liberty of
* giving it one, right now.
*/
if (msg->cm_fields['T'] == NULL) {
- lprintf(9, "Generating timestamp\n");
+ lprintf(CTDL_DEBUG, "Generating timestamp\n");
snprintf(aaa, sizeof aaa, "%ld", (long)time(NULL));
msg->cm_fields['T'] = strdoop(aaa);
}
/* If this message has no path, we generate one.
*/
if (msg->cm_fields['P'] == NULL) {
- lprintf(9, "Generating path\n");
+ lprintf(CTDL_DEBUG, "Generating path\n");
if (msg->cm_fields['A'] != NULL) {
msg->cm_fields['P'] = strdoop(msg->cm_fields['A']);
for (a=0; a<strlen(msg->cm_fields['P']); ++a) {
}
/* Learn about what's inside, because it's what's inside that counts */
- lprintf(9, "Learning what's inside\n");
+ lprintf(CTDL_DEBUG, "Learning what's inside\n");
if (msg->cm_fields['M'] == NULL) {
- lprintf(1, "ERROR: attempt to save message with NULL body\n");
+ lprintf(CTDL_ERR, "ERROR: attempt to save message with NULL body\n");
return(-1);
}
}
/* Goto the correct room */
- lprintf(9, "Selected room %s\n", (recps) ? CC->room.QRname : SENTITEMS);
+ lprintf(CTDL_DEBUG, "Selected room %s\n", (recps) ? CC->room.QRname : SENTITEMS);
strcpy(hold_rm, CC->room.QRname);
strcpy(actual_rm, CC->room.QRname);
if (recps != NULL) {
}
/* If the user is a twit, move to the twit room for posting */
- lprintf(9, "Handling twit stuff: %s\n",
+ lprintf(CTDL_DEBUG, "Handling twit stuff: %s\n",
(CC->user.axlevel == 2) ? config.c_twitroom : "OK");
if (TWITDETECT) {
if (CC->user.axlevel == 2) {
strcpy(actual_rm, force_room);
}
- lprintf(9, "Final selection: %s\n", actual_rm);
+ lprintf(CTDL_DEBUG, "Final selection: %s\n", actual_rm);
if (strcasecmp(actual_rm, CC->room.QRname)) {
getroom(&CC->room, actual_rm);
}
}
/* Perform "before save" hooks (aborting if any return nonzero) */
- lprintf(9, "Performing before-save hooks\n");
+ lprintf(CTDL_DEBUG, "Performing before-save hooks\n");
if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-1);
/* If this message has an Extended ID, perform replication checks */
- lprintf(9, "Performing replication checks\n");
+ lprintf(CTDL_DEBUG, "Performing replication checks\n");
if (ReplicationChecks(msg) > 0) return(-1);
/* Save it to disk */
- lprintf(9, "Saving to disk\n");
+ lprintf(CTDL_DEBUG, "Saving to disk\n");
newmsgid = send_message(msg, NULL);
if (newmsgid <= 0L) return(-1);
* be a critical section because nobody else knows about this message
* yet.
*/
- lprintf(9, "Creating MetaData record\n");
+ lprintf(CTDL_DEBUG, "Creating MetaData record\n");
memset(&smi, 0, sizeof(struct MetaData));
smi.meta_msgnum = newmsgid;
smi.meta_refcount = 0;
PutMetaData(&smi);
/* Now figure out where to store the pointers */
- lprintf(9, "Storing pointers\n");
+ lprintf(CTDL_DEBUG, "Storing pointers\n");
/* If this is being done by the networker delivering a private
* message, we want to BYPASS saving the sender's copy (because there
*/
if ((!CC->internal_pgm) || (recps == NULL)) {
if (CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0) != 0) {
- lprintf(3, "ERROR saving message pointer!\n");
+ lprintf(CTDL_ERR, "ERROR saving message pointer!\n");
CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0);
}
}
if (recps->num_room > 0)
for (i=0; i<num_tokens(recps->recp_room, '|'); ++i) {
extract(recipient, recps->recp_room, i);
- lprintf(9, "Delivering to local room <%s>\n", recipient);
+ lprintf(CTDL_DEBUG, "Delivering to local room <%s>\n", recipient);
CtdlSaveMsgPointerInRoom(recipient, newmsgid, 0);
}
/* Bump this user's messages posted counter. */
- lprintf(9, "Updating user\n");
+ lprintf(CTDL_DEBUG, "Updating user\n");
lgetuser(&CC->user, CC->curr_user);
CC->user.posted = CC->user.posted + 1;
lputuser(&CC->user);
if (recps->num_local > 0)
for (i=0; i<num_tokens(recps->recp_local, '|'); ++i) {
extract(recipient, recps->recp_local, i);
- lprintf(9, "Delivering private local mail to <%s>\n",
+ lprintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
recipient);
if (getuser(&userbuf, recipient) == 0) {
MailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM);
BumpNewMailCounter(userbuf.usernum);
}
else {
- lprintf(9, "No user <%s>\n", recipient);
+ lprintf(CTDL_DEBUG, "No user <%s>\n", recipient);
CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0);
}
}
/* Perform "after save" hooks */
- lprintf(9, "Performing after-save hooks\n");
+ lprintf(CTDL_DEBUG, "Performing after-save hooks\n");
PerformMessageHooks(msg, EVT_AFTERSAVE);
/* For IGnet mail, we have to save a new copy into the spooler for
}
/* Go back to the room we started from */
- lprintf(9, "Returning to original room %s\n", hold_rm);
+ lprintf(CTDL_DEBUG, "Returning to original room %s\n", hold_rm);
if (strcasecmp(hold_rm, CC->room.QRname))
getroom(&CC->room, hold_rm);
*/
if (recps != NULL)
if (recps->num_internet > 0) {
- lprintf(9, "Generating delivery instructions\n");
+ lprintf(CTDL_DEBUG, "Generating delivery instructions\n");
instr = mallok(SIZ * 2);
snprintf(instr, SIZ * 2,
"Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
} else {
buffer_len = (buffer_len * 2);
m = ptr;
- lprintf(9, "buffer_len is now %ld\n", (long)buffer_len);
+ lprintf(CTDL_DEBUG, "buffer_len is now %ld\n", (long)buffer_len);
}
}
if (num_recps > 0) for (i=0; i<num_recps; ++i) {
extract_token(this_recp, recipients, i, ',');
striplt(this_recp);
- lprintf(9, "Evaluating recipient #%d <%s>\n", i, this_recp);
+ lprintf(CTDL_DEBUG, "Evaluating recipient #%d <%s>\n", i, this_recp);
mailtype = alias(this_recp);
mailtype = alias(this_recp);
mailtype = alias(this_recp);
strcpy(ret->errormsg, "No recipients specified.");
}
- lprintf(9, "validate_recipients()\n");
- lprintf(9, " local: %d <%s>\n", ret->num_local, ret->recp_local);
- lprintf(9, " room: %d <%s>\n", ret->num_room, ret->recp_room);
- lprintf(9, " inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
- lprintf(9, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
- lprintf(9, " error: %d <%s>\n", ret->num_error, ret->errormsg);
+ lprintf(CTDL_DEBUG, "validate_recipients()\n");
+ lprintf(CTDL_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
+ lprintf(CTDL_DEBUG, " room: %d <%s>\n", ret->num_room, ret->recp_room);
+ lprintf(CTDL_DEBUG, " inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
+ lprintf(CTDL_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
+ lprintf(CTDL_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
return(ret);
}
int delete_this;
struct MetaData smi;
- lprintf(9, "CtdlDeleteMessages(%s, %ld, %s)\n",
+ lprintf(CTDL_DEBUG, "CtdlDeleteMessages(%s, %ld, %s)\n",
room_name, dmsgnum, content_type);
/* get room record, obtaining a lock... */
if (lgetroom(&qrbuf, room_name) != 0) {
- lprintf(7, "CtdlDeleteMessages(): Room <%s> not found\n",
+ lprintf(CTDL_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
room_name);
return (0); /* room not found */
}
/* Now free the memory we used, and go away. */
if (msglist != NULL) phree(msglist);
if (dellist != NULL) phree(dellist);
- lprintf(9, "%d message(s) deleted.\n", num_deleted);
+ lprintf(CTDL_DEBUG, "%d message(s) deleted.\n", num_deleted);
return (num_deleted);
}
/* Use the negative of the message number for the metadata db index */
TheIndex = (0L - smibuf->meta_msgnum);
- lprintf(9, "PutMetaData(%ld) - ref count is %d\n",
+ lprintf(CTDL_DEBUG, "PutMetaData(%ld) - ref count is %d\n",
smibuf->meta_msgnum, smibuf->meta_refcount);
cdb_store(CDB_MSGMAIN,
*/
begin_critical_section(S_SUPPMSGMAIN);
GetMetaData(&smi, msgnum);
- lprintf(9, "Ref count for message <%ld> before write is <%d>\n",
+ lprintf(CTDL_DEBUG, "Ref count for message <%ld> before write is <%d>\n",
msgnum, smi.meta_refcount);
smi.meta_refcount += incr;
PutMetaData(&smi);
end_critical_section(S_SUPPMSGMAIN);
- lprintf(9, "Ref count for message <%ld> after write is <%d>\n",
+ lprintf(CTDL_DEBUG, "Ref count for message <%ld> after write is <%d>\n",
msgnum, smi.meta_refcount);
/* If the reference count is now zero, delete the message
* (and its supplementary record as well).
*/
if (smi.meta_refcount == 0) {
- lprintf(9, "Deleting message <%ld>\n", msgnum);
+ lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
delnum = msgnum;
cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
MailboxName(roomname, sizeof roomname, is_mailbox, req_room);
else
safestrncpy(roomname, req_room, sizeof(roomname));
- lprintf(9, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags);
+ lprintf(CTDL_DEBUG, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags);
fp = fopen(tempfilename, "rb");
if (fp == NULL) {
- lprintf(5, "Cannot open %s: %s\n",
+ lprintf(CTDL_CRIT, "Cannot open %s: %s\n",
tempfilename, strerror(errno));
return;
}
fseek(fp, 0L, SEEK_END);
raw_length = ftell(fp);
rewind(fp);
- lprintf(9, "Raw length is %ld\n", (long)raw_length);
+ lprintf(CTDL_DEBUG, "Raw length is %ld\n", (long)raw_length);
raw_message = mallok((size_t)raw_length + 2);
fread(raw_message, (size_t)raw_length, 1, fp);
phree(raw_message);
- lprintf(9, "Allocating\n");
+ lprintf(CTDL_DEBUG, "Allocating\n");
msg = mallok(sizeof(struct CtdlMessage));
memset(msg, 0, sizeof(struct CtdlMessage));
msg->cm_magic = CTDLMESSAGE_MAGIC;
* other objects of this type that are currently in the room.
*/
if (is_unique) {
- lprintf(9, "Deleted %d other msgs of this type\n",
+ lprintf(CTDL_DEBUG, "Deleted %d other msgs of this type\n",
CtdlDeleteMessages(roomname, 0L, content_type));
}
/* Now write the data */
if (retmsgs != NULL) *retmsgs = total_messages;
if (retnew != NULL) *retnew = new_messages;
- lprintf(9, "<%s> %d new of %d total messages\n",
+ lprintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
CC->room.QRname,
new_messages, total_messages
);
((ra & UA_KNOWN) == 0) &&
(CC->user.axlevel < 6)
) {
- lprintf(9, "Failed to acquire private room\n");
+ lprintf(CTDL_DEBUG, "Failed to acquire private room\n");
} else {
memcpy(&CC->room, &QRscratch,
sizeof(struct ctdlroom));
long owner = 0L;
char actual_old_name[SIZ];
- lprintf(9, "CtdlRenameRoom(%s, %s, %d)\n",
+ lprintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
old_name, new_name, new_floor);
if (new_floor >= 0) {
lgetfloor(&flbuf, old_floor);
--flbuf.f_ref_count;
lputfloor(&flbuf, old_floor);
- lprintf(9, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
+ lprintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
lgetfloor(&flbuf, new_floor);
++flbuf.f_ref_count;
lputfloor(&flbuf, new_floor);
- lprintf(9, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
+ lprintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
}
/* ...and everybody say "YATTA!" */
struct floor flbuf;
char filename[100];
- lprintf(9, "Deleting room <%s>\n", qrbuf->QRname);
+ lprintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
/* Delete the info file */
assoc_file_name(filename, sizeof filename, qrbuf, "info");
struct floor flbuf;
struct visit vbuf;
- lprintf(9, "create_room(%s)\n", new_room_name);
+ lprintf(CTDL_DEBUG, "create_room(%s)\n", new_room_name);
if (getroom(&qrbuf, new_room_name) == 0) {
- lprintf(9, "%s already exists.\n", new_room_name);
+ lprintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
return (0); /* already exists */
}
return;
}
assoc_file_name(infofilename, sizeof infofilename, &CC->room, "info");
- lprintf(9, "opening\n");
+ lprintf(CTDL_DEBUG, "opening\n");
fp = fopen(infofilename, "w");
- lprintf(9, "checking\n");
+ lprintf(CTDL_DEBUG, "checking\n");
if (fp == NULL) {
cprintf("%d Cannot open %s: %s\n",
ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
encaps = icalcomponent_new_vcalendar();
if (encaps == NULL) {
- lprintf(3, "Error at %s:%d - could not allocate component!\n",
+ lprintf(CTDL_CRIT, "Error at %s:%d - could not allocate component!\n",
__FILE__, __LINE__);
return NULL;
}
strcpy(summary_string, "Calendar item");
if (request == NULL) {
- lprintf(3, "ERROR: trying to reply to NULL event?\n");
+ lprintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
return;
}
the_reply = icalcomponent_new_clone(request);
if (the_reply == NULL) {
- lprintf(3, "ERROR: cannot clone request\n");
+ lprintf(CTDL_ERR, "ERROR: cannot clone request\n");
return;
}
/* Figure out just what event it is we're dealing with */
strcpy(uid, "--==<< InVaLiD uId >>==--");
ical_learn_uid_of_reply(uid, cal);
- lprintf(9, "UID of event being replied to is <%s>\n", uid);
+ lprintf(CTDL_DEBUG, "UID of event being replied to is <%s>\n", uid);
strcpy(hold_rm, CC->room.QRname); /* save current room */
if (getroom(&CC->room, USERCALENDARROOM) != 0) {
getroom(&CC->room, hold_rm);
- lprintf(3, "cannot get user calendar room\n");
+ lprintf(CTDL_CRIT, "cannot get user calendar room\n");
return(2);
}
CtdlFreeMessage(template);
getroom(&CC->room, hold_rm); /* return to saved room */
- lprintf(9, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
+ lprintf(CTDL_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
if (msgnum_being_replaced == 0) {
return(1); /* no calendar event found */
}
original_event = oec.c;
if (original_event == NULL) {
- lprintf(3, "ERROR: Original_component is NULL.\n");
+ lprintf(CTDL_ERR, "ERROR: Original_component is NULL.\n");
return(2);
}
}
/* Create a VFREEBUSY subcomponent */
- lprintf(9, "Creating VFREEBUSY component\n");
+ lprintf(CTDL_DEBUG, "Creating VFREEBUSY component\n");
fb = icalcomponent_new_vfreebusy();
if (fb == NULL) {
cprintf("%d Internal error: cannot allocate memory.\n",
return;
}
- lprintf(9, "Adding busy time from events\n");
+ lprintf(CTDL_DEBUG, "Adding busy time from events\n");
CtdlForEachMessage(MSGS_ALL, 0, "text/calendar",
NULL, ical_freebusy_backend, (void *)fb
);
*/
/* Put the freebusy component into the calendar component */
- lprintf(9, "Encapsulating\n");
+ lprintf(CTDL_DEBUG, "Encapsulating\n");
encaps = ical_encapsulate_subcomponent(fb);
if (encaps == NULL) {
icalcomponent_free(fb);
}
/* Set the method to PUBLISH */
- lprintf(9, "Setting method\n");
+ lprintf(CTDL_DEBUG, "Setting method\n");
icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
/* Serialize it */
- lprintf(9, "Serializing\n");
+ lprintf(CTDL_DEBUG, "Serializing\n");
serialized_request = strdoop(icalcomponent_as_ical_string(encaps));
icalcomponent_free(encaps); /* Don't need this anymore. */
/* Set expiration policy to manual; otherwise objects will be lost! */
if (lgetroom(&qr, USERCALENDARROOM)) {
- lprintf(3, "Couldn't get the user calendar room!\n");
+ lprintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
/* Set expiration policy to manual; otherwise objects will be lost! */
if (lgetroom(&qr, USERTASKSROOM)) {
- lprintf(3, "Couldn't get the user calendar room!\n");
+ lprintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
icalproperty *summary = NULL;
if (cal == NULL) {
- lprintf(3, "ERROR: trying to reply to NULL event?\n");
+ lprintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
return;
}
/* Clone the event */
the_request = icalcomponent_new_clone(cal);
if (the_request == NULL) {
- lprintf(3, "ERROR: cannot clone calendar object\n");
+ lprintf(CTDL_ERR, "ERROR: cannot clone calendar object\n");
return;
}
}
}
- lprintf(9, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
+ lprintf(CTDL_DEBUG, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
/* If there are no attendees, there are no invitations to send, so...
* don't bother putting one together! Punch out, Maverick!
/* Encapsulate the VEVENT component into a complete VCALENDAR */
encaps = icalcomponent_new_vcalendar();
if (encaps == NULL) {
- lprintf(3, "Error at %s:%d - could not allocate component!\n",
+ lprintf(CTDL_DEBUG, "Error at %s:%d - could not allocate component!\n",
__FILE__, __LINE__);
icalcomponent_free(the_request);
return;
}
/* Oops! No Content-Type in this message! How'd that happen? */
- lprintf(7, "RFC822 message with no Content-Type header!\n");
+ lprintf(CTDL_ERR, "RFC822 message with no Content-Type header!\n");
return 1;
}
}
/* Oops! No Content-Type in this message! How'd that happen? */
- lprintf(7, "RFC822 message with no Content-Type header!\n");
+ lprintf(CTDL_ERR, "RFC822 message with no Content-Type header!\n");
return 1;
}
if (cert_file != NULL) {
if (SSL_CTX_use_certificate_file(ctx, cert_file,
SSL_FILETYPE_PEM) <= 0) {
- lprintf(3, "unable to get certificate from '%s'",
+ lprintf(CTDL_CRIT, "unable to get certificate from '%s'",
cert_file);
return (0);
}
key_file = cert_file;
if (SSL_CTX_use_PrivateKey_file(ctx, key_file,
SSL_FILETYPE_PEM) <= 0) {
- lprintf(3, "unable to get private key from '%s'",
+ lprintf(CTDL_CRIT, "unable to get private key from '%s'",
key_file);
return (0);
}
/* Now we know that a key and cert have been set against
* the SSL context */
if (!SSL_CTX_check_private_key(ctx)) {
- lprintf(3,
+ lprintf(CTDL_CRIT,
"Private key does not match the certificate public key");
return (0);
}
RAND_egd("/var/run/egd-pool");
if (!RAND_status()) {
- lprintf(2,
+ lprintf(CTDL_CRIT,
"PRNG not adequately seeded, won't do SSL/TLS\n");
return;
}
SSLCritters =
mallok(CRYPTO_num_locks() * sizeof(pthread_mutex_t *));
if (!SSLCritters) {
- lprintf(1, "citserver: can't allocate memory!!\n");
+ lprintf(CTDL_EMERG, "citserver: can't allocate memory!!\n");
/* Nothing's been initialized, just die */
exit(1);
} else {
for (a = 0; a < CRYPTO_num_locks(); a++) {
SSLCritters[a] = mallok(sizeof(pthread_mutex_t));
if (!SSLCritters[a]) {
- lprintf(1,
+ lprintf(CTDL_EMERG,
"citserver: can't allocate memory!!\n");
/* Nothing's been initialized, just die */
exit(1);
SSL_load_error_strings();
ssl_method = SSLv23_server_method();
if (!(ssl_ctx = SSL_CTX_new(ssl_method))) {
- lprintf(2, "SSL_CTX_new failed: %s\n",
+ lprintf(CTDL_CRIT, "SSL_CTX_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
return;
}
if (!(SSL_CTX_set_cipher_list(ssl_ctx, CIT_CIPHERS))) {
- lprintf(2, "SSL: No ciphers available\n");
+ lprintf(CTDL_CRIT, "SSL: No ciphers available\n");
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return;
/* Load DH parameters into the context */
dh = DH_new();
if (!dh) {
- lprintf(2, "init_ssl() can't allocate a DH object: %s\n",
+ lprintf(CTDL_CRIT, "init_ssl() can't allocate a DH object: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return;
}
if (!(BN_hex2bn(&(dh->p), DH_P))) {
- lprintf(2, "init_ssl() can't assign DH_P: %s\n",
+ lprintf(CTDL_CRIT, "init_ssl() can't assign DH_P: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return;
}
if (!(BN_hex2bn(&(dh->g), DH_G))) {
- lprintf(2, "init_ssl() can't assign DH_G: %s\n",
+ lprintf(CTDL_CRIT, "init_ssl() can't assign DH_G: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
* Generate a key pair if we don't have one.
*/
if (access(CTDL_KEY_PATH, R_OK) != 0) {
- lprintf(3, "Generating RSA key pair.\n");
+ lprintf(CTDL_INFO, "Generating RSA key pair.\n");
rsa = RSA_generate_key(1024, /* modulus size */
65537, /* exponent */
NULL, /* no callback */
NULL); /* no callback */
if (rsa == NULL) {
- lprintf(2, "Key generation failed: %s\n",
+ lprintf(CTDL_CRIT, "Key generation failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
}
if (rsa != NULL) {
NULL, /* no callbk */
NULL /* no callbk */
) != 1) {
- lprintf(2, "Cannot write key: %s\n",
+ lprintf(CTDL_CRIT, "Cannot write key: %s\n",
ERR_reason_error_string(ERR_get_error()));
unlink(CTDL_KEY_PATH);
}
* Generate a CSR if we don't have one.
*/
if (access(CTDL_CSR_PATH, R_OK) != 0) {
- lprintf(3, "Generating a certificate signing request.\n");
+ lprintf(CTDL_INFO, "Generating a certificate signing request.\n");
/*
* Read our key from the file. No, we don't just keep this
/* Sign the CSR */
if (!X509_REQ_sign(req, pk, EVP_md5())) {
- lprintf(3, "X509_REQ_sign(): error\n");
+ lprintf(CTDL_CRIT, "X509_REQ_sign(): error\n");
}
else {
/* Write it to disk. */
}
else {
- lprintf(3, "Unable to read private key.\n");
+ lprintf(CTDL_CRIT, "Unable to read private key.\n");
}
}
* Generate a self-signed certificate if we don't have one.
*/
if (access(CTDL_CER_PATH, R_OK) != 0) {
- lprintf(3, "Generating a self-signed certificate.\n");
+ lprintf(CTDL_INFO, "Generating a self-signed certificate.\n");
/* Same deal as before: always read the key from disk because
* it may or may not have just been generated.
/* Sign the cert */
if (!X509_sign(cer, pk, EVP_md5())) {
- lprintf(3, "X509_sign(): error\n");
+ lprintf(CTDL_CRIT, "X509_sign(): error\n");
}
else {
/* Write it to disk. */
CTDL_CER_PATH,
CTDL_KEY_PATH) != 1)
{
- lprintf(2, "Cannot install certificate: %s\n",
+ lprintf(CTDL_CRIT, "Cannot install certificate: %s\n",
ERR_reason_error_string(ERR_get_error()));
}
while (nremain > 0) {
if (SSL_want_write(CC->ssl)) {
if ((SSL_read(CC->ssl, junk, 0)) < 1) {
- lprintf(9, "SSL_read in client_write:\n");
- ERR_print_errors_fp(stderr);
+ lprintf(CTDL_DEBUG, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error()));
}
}
retval =
sleep(1);
continue;
}
- lprintf(9, "SSL_write got error %ld, ret %d\n", errval, retval);
+ lprintf(CTDL_DEBUG, "SSL_write got error %ld, ret %d\n", errval, retval);
if (retval == -1)
- lprintf(9, "errno is %d\n", errno);
+ lprintf(CTDL_DEBUG, "errno is %d\n", errno);
endtls();
client_write(&buf[nbytes - nremain], nremain);
return;
#endif
if (SSL_want_read(CC->ssl)) {
if ((SSL_write(CC->ssl, junk, 0)) < 1) {
- lprintf(9, "SSL_write in client_read:\n");
- ERR_print_errors_fp(stderr);
+ lprintf(CTDL_DEBUG, "SSL_write in client_read: %s\n", ERR_reason_error_string(ERR_get_error()));
}
}
rlen = SSL_read(CC->ssl, &buf[len], bytes - len);
sleep(1);
continue;
}
- lprintf(9, "SSL_read got error %ld\n", errval);
+ lprintf(CTDL_DEBUG, "SSL_read got error %ld\n", errval);
endtls();
return (client_read_to
(&buf[len], bytes - len, timeout));
return;
}
if (!(CC->ssl = SSL_new(ssl_ctx))) {
- lprintf(2, "SSL_new failed: %s\n",
+ lprintf(CTDL_CRIT, "SSL_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
cprintf("%s", error_response);
return;
}
if (!(SSL_set_fd(CC->ssl, CC->client_socket))) {
- lprintf(2, "SSL_set_fd failed: %s\n",
+ lprintf(CTDL_CRIT, "SSL_set_fd failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_free(CC->ssl);
CC->ssl = NULL;
long errval;
errval = SSL_get_error(CC->ssl, retval);
- lprintf(2, "SSL_accept failed: %s\n",
+ lprintf(CTDL_CRIT, "SSL_accept failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_free(CC->ssl);
CC->ssl = NULL;
bits =
SSL_CIPHER_get_bits(SSL_get_current_cipher(CC->ssl),
&alg_bits);
- lprintf(3, "SSL/TLS using %s on %s (%d of %d bits)\n",
+ lprintf(CTDL_INFO, "SSL/TLS using %s on %s (%d of %d bits)\n",
SSL_CIPHER_get_name(SSL_get_current_cipher(CC->ssl)),
SSL_CIPHER_get_version(SSL_get_current_cipher(CC->ssl)),
bits, alg_bits);
*/
void endtls(void)
{
- lprintf(7, "Ending SSL/TLS\n");
+ lprintf(CTDL_INFO, "Ending SSL/TLS\n");
if (!CC->ssl) {
CC->redirect_ssl = 0;
void PurgeMessages(void) {
FILE *purgelist;
- lprintf(5, "PurgeMessages() called\n");
+ lprintf(CTDL_DEBUG, "PurgeMessages() called\n");
messages_purged = 0;
purgelist = tmpfile();
if (purgelist == NULL) {
- lprintf(3, "Can't create purgelist temp file: %s\n",
+ lprintf(CTDL_CRIT, "Can't create purgelist temp file: %s\n",
strerror(errno));
return;
}
age = time(NULL) - (qrbuf->QRmtime);
purge_secs = (time_t)config.c_roompurge * (time_t)86400;
if (purge_secs <= (time_t)0) return;
- lprintf(9, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
+ lprintf(CTDL_DEBUG, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
if (age > purge_secs) do_purge = 1;
} /* !QR_MAILBOX */
struct ValidUser *vuptr;
char *transcript = NULL;
- lprintf(5, "PurgeRooms() called\n");
+ lprintf(CTDL_DEBUG, "PurgeRooms() called\n");
/* Load up a table full of valid user numbers so we can delete
if (num_rooms_purged > 0) aide_message(transcript);
phree(transcript);
- lprintf(5, "Purged %d rooms.\n", num_rooms_purged);
+ lprintf(CTDL_DEBUG, "Purged %d rooms.\n", num_rooms_purged);
return(num_rooms_purged);
}
MailboxName(mailboxname, us, MAILROOM);
create_room(mailboxname, 4, "", 0, 1, 1);
if (getroom(&qrbuf, mailboxname) != 0) return;
- lprintf(9, "Got %s\n", qrbuf.QRname);
+ lprintf(CTDL_DEBUG, "Got %s\n", qrbuf.QRname);
*/
int num_users_purged = 0;
char *transcript = NULL;
- lprintf(5, "PurgeUsers() called\n");
+ lprintf(CTDL_DEBUG, "PurgeUsers() called\n");
if (config.c_userpurge > 0) {
ForEachUser(do_user_purge, NULL);
}
if (num_users_purged > 0) aide_message(transcript);
phree(transcript);
- lprintf(5, "Purged %d users.\n", num_users_purged);
+ lprintf(CTDL_DEBUG, "Purged %d users.\n", num_users_purged);
return(num_users_purged);
}
struct UPurgeList *uptr;
/* Phase 1: traverse through the table, discovering old records... */
- lprintf(9, "Purge use table: phase 1\n");
+ lprintf(CTDL_DEBUG, "Purge use table: phase 1\n");
cdb_rewind(CDB_USETABLE);
while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
}
/* Phase 2: delete the records */
- lprintf(9, "Purge use table: phase 2\n");
+ lprintf(CTDL_DEBUG, "Purge use table: phase 2\n");
while (ul != NULL) {
cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key));
uptr = ul->next;
ul = uptr;
}
- lprintf(9, "Purge use table: finished (purged %d records)\n", purged);
+ lprintf(CTDL_DEBUG, "Purge use table: finished (purged %d records)\n", purged);
return(purged);
}
if (tm.tm_hour != config.c_purge_hour) return;
if ((now - last_purge) < 43200) return;
- lprintf(3, "Auto-purger: starting.\n");
+ lprintf(CTDL_INFO, "Auto-purger: starting.\n");
retval = PurgeUsers();
- lprintf(3, "Purged %d users.\n", retval);
+ lprintf(CTDL_NOTICE, "Purged %d users.\n", retval);
PurgeMessages();
- lprintf(3, "Expired %d messages.\n", messages_purged);
+ lprintf(CTDL_NOTICE, "Expired %d messages.\n", messages_purged);
retval = PurgeRooms();
- lprintf(3, "Expired %d rooms.\n", retval);
+ lprintf(CTDL_NOTICE, "Expired %d rooms.\n", retval);
retval = PurgeVisits();
- lprintf(3, "Purged %d visits.\n", retval);
+ lprintf(CTDL_NOTICE, "Purged %d visits.\n", retval);
retval = PurgeUseTable();
- lprintf(3, "Purged %d entries from the use table.\n", retval);
+ lprintf(CTDL_NOTICE, "Purged %d entries from the use table.\n", retval);
- lprintf(3, "Auto-purger: finished.\n");
+ lprintf(CTDL_INFO, "Auto-purger: finished.\n");
last_purge = now; /* So we don't do it again soon */
}
p->desc = desc;
p->next = ProtoHookList;
ProtoHookList = p;
- lprintf(5, "Registered server command %s (%s)\n", cmd, desc);
+ lprintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
}
while (cur != NULL &&
handler == cur->handler &&
!strcmp(cmd, cur->cmd)) {
- lprintf(5, "Unregistered server command %s (%s)\n",
+ lprintf(CTDL_INFO, "Unregistered server command %s (%s)\n",
cmd, cur->desc);
p = cur->next;
if (cur == ProtoHookList) {
newfcn->loglevel = loglevel;
LogHookTable = newfcn;
- lprintf(5, "Registered a new logging function\n");
+ lprintf(CTDL_INFO, "Registered a new logging function\n");
}
while (cur != NULL &&
fcn_ptr == cur->h_function_pointer &&
loglevel == cur->loglevel) {
- lprintf(5, "Unregistered logging function\n");
+ lprintf(CTDL_INFO, "Unregistered logging function\n");
p = cur->next;
if (cur == LogHookTable) {
LogHookTable = p;
newfcn->h_function_pointer = fcn_ptr;
CleanupHookTable = newfcn;
- lprintf(5, "Registered a new cleanup function\n");
+ lprintf(CTDL_INFO, "Registered a new cleanup function\n");
}
/* This will also remove duplicates if any */
while (cur != NULL &&
fcn_ptr == cur->h_function_pointer) {
- lprintf(5, "Unregistered cleanup function\n");
+ lprintf(CTDL_INFO, "Unregistered cleanup function\n");
p = cur->next;
if (cur == CleanupHookTable) {
CleanupHookTable = p;
newfcn->eventtype = EventType;
SessionHookTable = newfcn;
- lprintf(5, "Registered a new session function (type %d)\n",
+ lprintf(CTDL_INFO, "Registered a new session function (type %d)\n",
EventType);
}
while (cur != NULL &&
fcn_ptr == cur->h_function_pointer &&
EventType == cur->eventtype) {
- lprintf(5, "Unregistered session function (type %d)\n",
+ lprintf(CTDL_INFO, "Unregistered session function (type %d)\n",
EventType);
p = cur->next;
if (cur == SessionHookTable) {
newfcn->eventtype = EventType;
UserHookTable = newfcn;
- lprintf(5, "Registered a new user function (type %d)\n",
+ lprintf(CTDL_INFO, "Registered a new user function (type %d)\n",
EventType);
}
while (cur != NULL &&
fcn_ptr == cur->h_function_pointer &&
EventType == cur->eventtype) {
- lprintf(5, "Unregistered user function (type %d)\n",
+ lprintf(CTDL_INFO, "Unregistered user function (type %d)\n",
EventType);
p = cur->next;
if (cur == UserHookTable) {
newfcn->eventtype = EventType;
MessageHookTable = newfcn;
- lprintf(5, "Registered a new message function (type %d)\n",
+ lprintf(CTDL_INFO, "Registered a new message function (type %d)\n",
EventType);
}
while (cur != NULL &&
handler == cur->h_function_pointer &&
EventType == cur->eventtype) {
- lprintf(5, "Unregistered message function (type %d)\n",
+ lprintf(CTDL_INFO, "Unregistered message function (type %d)\n",
EventType);
p = cur->next;
if (cur == MessageHookTable) {
newfcn->h_function_pointer = handler;
NetprocHookTable = newfcn;
- lprintf(5, "Registered a new netproc function\n");
+ lprintf(CTDL_INFO, "Registered a new netproc function\n");
}
/* This will also remove duplicates if any */
while (cur != NULL &&
handler == cur->h_function_pointer ) {
- lprintf(5, "Unregistered netproc function\n");
+ lprintf(CTDL_INFO, "Unregistered netproc function\n");
p = cur->next;
if (cur == NetprocHookTable) {
NetprocHookTable = p;
newfcn->h_function_pointer = handler;
DeleteHookTable = newfcn;
- lprintf(5, "Registered a new netproc function\n");
+ lprintf(CTDL_INFO, "Registered a new netproc function\n");
}
/* This will also remove duplicates if any */
while (cur != NULL &&
handler == cur->h_function_pointer ) {
- lprintf(5, "Unregistered netproc function\n");
+ lprintf(CTDL_INFO, "Unregistered netproc function\n");
p = cur->next;
if (cur == DeleteHookTable) {
DeleteHookTable = p;
newfcn->order = order;
newfcn->h_function_pointer = fcn_ptr;
XmsgHookTable = newfcn;
- lprintf(5, "Registered a new x-msg function (priority %d)\n", order);
+ lprintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
}
while (cur != NULL &&
fcn_ptr == cur->h_function_pointer &&
order == cur->order) {
- lprintf(5, "Unregistered x-msg function "
+ lprintf(CTDL_INFO, "Unregistered x-msg function "
"(priority %d)\n", order);
p = cur->next;
if (cur == XmsgHookTable) {
snprintf(message, sizeof message, "Unix domain socket '%s': ", sockpath);
}
else if (tcp_port <= 0) { /* port -1 to disable */
- lprintf(7, "Service has been manually disabled, skipping\n");
+ lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n");
phree(newfcn);
return;
}
if (newfcn->msock > 0) {
ServiceHookTable = newfcn;
strcat(message, "registered.");
- lprintf(5, "%s\n", message);
+ lprintf(CTDL_INFO, "%s\n", message);
}
else {
strcat(message, "FAILED.");
- lprintf(2, "%s\n", message);
+ lprintf(CTDL_CRIT, "%s\n", message);
phree(newfcn);
}
}
tcp_port == cur->tcp_port) {
close(cur->msock);
if (sockpath) {
- lprintf(5, "Closed UNIX domain socket %s\n",
+ lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
sockpath);
} else if (tcp_port) {
- lprintf(5, "Closed TCP port %d\n", tcp_port);
+ lprintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
} else {
- lprintf(5, "Unregistered unknown service\n");
+ lprintf(CTDL_INFO, "Unregistered unknown service\n");
}
p = cur->next;
if (cur == ServiceHookTable) {
/* Other code may elect to protect this message from server-side
* handlers; if this is the case, don't do anything.
- lprintf(9, "** Event type is %d, flags are %d\n",
+ lprintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
EventType, msg->cm_flags);
*/
if (msg->cm_flags & CM_SKIP_HOOKS) {
- lprintf(9, "Skipping hooks\n");
+ lprintf(CTDL_DEBUG, "Skipping hooks\n");
return(0);
}
{
if (IMAP->selected == 0) {
- lprintf(5,
+ lprintf(CTDL_ERR,
"imap_load_msgids() can't run; no room selected\n");
return;
}
imap_add_single_msgid, NULL);
imap_set_seen_flags();
- lprintf(9, "imap_load_msgids() mapped %d messages\n",
+ lprintf(CTDL_DEBUG, "imap_load_msgids() mapped %d messages\n",
IMAP->num_msgs);
}
if (IMAP->selected == 0) {
- lprintf(5,
+ lprintf(CTDL_ERR,
"imap_load_msgids() can't run; no room selected\n");
return;
}
if (CC->h_command_function != imap_command_loop)
return;
- lprintf(9, "Performing IMAP cleanup hook\n");
+ lprintf(CTDL_DEBUG, "Performing IMAP cleanup hook\n");
imap_free_msgids();
imap_free_transmitted_message();
- lprintf(9, "Finished IMAP cleanup hook\n");
+ lprintf(CTDL_DEBUG, "Finished IMAP cleanup hook\n");
}
int i;
int num_expunged = 0;
- lprintf(9, "imap_do_expunge() called\n");
+ lprintf(CTDL_DEBUG, "imap_do_expunge() called\n");
if (IMAP->selected == 0)
return (0);
CtdlDeleteMessages(CC->room.QRname,
IMAP->msgids[i], "");
++num_expunged;
- lprintf(9, "%ld ... deleted\n",
+ lprintf(CTDL_DEBUG, "%ld ... deleted\n",
IMAP->msgids[i]);
} else {
- lprintf(9, "%ld ... not deleted\n",
+ lprintf(CTDL_DEBUG, "%ld ... not deleted\n",
IMAP->msgids[i]);
}
}
newroomtype = 0; /* public folder */
}
- lprintf(7, "Create new room <%s> on floor <%d> with type <%d>\n",
+ lprintf(CTDL_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
roomname, floornum, newroomtype);
ret = create_room(roomname, newroomtype, "", floornum, 1, 0);
irl->irl_newfloor);
if (r != crr_ok) {
/* FIXME handle error returns better */
- lprintf(5, "CtdlRenameRoom() error %d\n",
+ lprintf(CTDL_ERR, "CtdlRenameRoom() error %d\n",
r);
}
irlp = irl;
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_gets(cmdbuf) < 1) {
- lprintf(3, "IMAP socket is broken. Ending session.\r\n");
+ lprintf(CTDL_ERR, "IMAP socket is broken. Ending session.\r\n");
CC->kill_me = 1;
return;
}
- lprintf(5, "IMAP: %s\r\n", cmdbuf);
+ lprintf(CTDL_INFO, "IMAP: %s\r\n", cmdbuf);
while (strlen(cmdbuf) < 5)
strcat(cmdbuf, " ");
{
if (!dirserver) return;
- lprintf(7, "Unbinding from directory server\n");
+ lprintf(CTDL_INFO, "Unbinding from directory server\n");
ldap_unbind(dirserver);
dirserver = NULL;
}
mods[2] = NULL;
/* Perform the transaction */
- lprintf(9, "Setting up Base DN node...\n");
+ lprintf(CTDL_DEBUG, "Setting up Base DN node...\n");
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, config.c_ldap_base_dn, mods);
end_critical_section(S_LDAP);
if (i != LDAP_SUCCESS) {
- lprintf(3, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_CRIT, "ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
}
}
mods[2] = NULL;
/* Perform the transaction */
- lprintf(9, "Setting up Host OU node...\n");
+ lprintf(CTDL_DEBUG, "Setting up Host OU node...\n");
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, dn, mods);
end_critical_section(S_LDAP);
/* ignore the error -- it's ok if it already exists
if (i != LDAP_SUCCESS) {
- lprintf(3, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_ERR, "ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
}
*/
int i;
int ldap_version = 3;
- lprintf(7, "Connecting to LDAP server %s:%d...\n",
+ lprintf(CTDL_INFO, "Connecting to LDAP server %s:%d...\n",
config.c_ldap_host, config.c_ldap_port);
dirserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
if (dirserver == NULL) {
- lprintf(3, "Could not connect to %s:%d : %s\n",
+ lprintf(CTDL_CRIT, "Could not connect to %s:%d : %s\n",
config.c_ldap_host,
config.c_ldap_port,
strerror(errno));
ldap_set_option(dirserver, LDAP_OPT_PROTOCOL_VERSION, &ldap_version);
- lprintf(7, "Binding to %s\n", config.c_ldap_bind_dn);
+ lprintf(CTDL_INFO, "Binding to %s\n", config.c_ldap_bind_dn);
i = ldap_simple_bind_s(dirserver,
config.c_ldap_bind_dn,
config.c_ldap_bind_pw
);
if (i != LDAP_SUCCESS) {
- lprintf(3, "Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+ lprintf(CTDL_CRIT, "Cannot bind: %s (%d)\n", ldap_err2string(i), i);
dirserver = NULL; /* FIXME disconnect from ldap */
return;
}
/* Are we just deleting? If so, it's simple... */
if (op == V2L_DELETE) {
- lprintf(9, "Calling ldap_delete_s()\n");
+ lprintf(CTDL_DEBUG, "Calling ldap_delete_s()\n");
begin_critical_section(S_LDAP);
i = ldap_delete_s(dirserver, this_dn);
end_critical_section(S_LDAP);
if (i != LDAP_SUCCESS) {
- lprintf(3, "ldap_delete_s() failed: %s (%d)\n",
+ lprintf(CTDL_ERR, "ldap_delete_s() failed: %s (%d)\n",
ldap_err2string(i), i);
}
return;
||(!strcasecmp(v->prop[i].name, "email;internet")) ) {
++num_emails;
- lprintf(9, "email addr %d\n", num_emails);
+ lprintf(CTDL_DEBUG, "email addr %d\n", num_emails);
/* The first email address creates the 'mail' attribute */
if (num_emails == 1) {
attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) );
attrs[num_attrs - 1] = NULL;
- lprintf(9, "Calling ldap_add_s()\n");
+ lprintf(CTDL_DEBUG, "Calling ldap_add_s()\n");
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, this_dn, attrs);
end_critical_section(S_LDAP);
for (j=0; j<(num_attrs-1); ++j) {
attrs[j]->mod_op = LDAP_MOD_REPLACE;
}
- lprintf(9, "Calling ldap_modify_s()\n");
+ lprintf(CTDL_DEBUG, "Calling ldap_modify_s()\n");
begin_critical_section(S_LDAP);
i = ldap_modify_s(dirserver, this_dn, attrs);
end_critical_section(S_LDAP);
}
if (i != LDAP_SUCCESS) {
- lprintf(3, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_ERR, "ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
}
- lprintf(9, "Freeing attributes\n");
+ lprintf(CTDL_DEBUG, "Freeing attributes\n");
/* Free the attributes */
for (i=0; i<num_attrs; ++i) {
if (attrs[i] != NULL) {
}
}
phree(attrs);
- lprintf(9, "LDAP write operation complete.\n");
+ lprintf(CTDL_DEBUG, "LDAP write operation complete.\n");
}
/*
* If we get to this point, the supplied node name is bogus.
*/
- lprintf(5, "Invalid node name <%s>\n", node);
+ lprintf(CTDL_ERR, "Invalid node name <%s>\n", node);
return(-1);
}
/*
* allocate...
*/
- lprintf(9, "Generating delivery instructions\n");
+ lprintf(CTDL_DEBUG, "Generating delivery instructions\n");
instr = mallok(instr_len);
if (instr == NULL) {
- lprintf(1, "Cannot allocate %ld bytes for instr...\n",
+ lprintf(CTDL_EMERG, "Cannot allocate %ld bytes for instr...\n",
(long)instr_len);
abort();
}
/* Check for valid node name */
if (is_valid_node(NULL,NULL,nptr->name) != 0) {
- lprintf(3, "Invalid node <%s>\n",
+ lprintf(CTDL_ERR, "Invalid node <%s>\n",
nptr->name);
send = 0;
}
/* Check for split horizon */
- lprintf(9, "Path is %s\n", msg->cm_fields['P']);
+ lprintf(CTDL_DEBUG, "Path is %s\n", msg->cm_fields['P']);
bang = num_tokens(msg->cm_fields['P'], '!');
if (bang > 1) for (i=0; i<(bang-1); ++i) {
extract_token(buf, msg->cm_fields['P'],
/*
* allocate...
*/
- lprintf(9, "Generating delivery instructions\n");
+ lprintf(CTDL_DEBUG, "Generating delivery instructions\n");
instr = mallok(instr_len);
if (instr == NULL) {
- lprintf(1, "Cannot allocate %ld bytes for instr...\n",
+ lprintf(CTDL_EMERG, "Cannot allocate %ld bytes for instr...\n",
(long)instr_len);
abort();
}
int i;
if (getroom(&CC->room, room_to_spool) != 0) {
- lprintf(1, "ERROR: cannot load <%s>\n", room_to_spool);
+ lprintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
return;
}
return;
}
- lprintf(5, "Networking started for <%s>\n", CC->room.QRname);
+ lprintf(CTDL_INFO, "Networking started for <%s>\n", CC->room.QRname);
while (fgets(buf, sizeof buf, fp) != NULL) {
buf[strlen(buf)-1] = 0;
/* Now rewrite the config file */
fp = fopen(filename, "w");
if (fp == NULL) {
- lprintf(1, "ERROR: cannot open %s: %s\n",
+ lprintf(CTDL_CRIT, "ERROR: cannot open %s: %s\n",
filename, strerror(errno));
}
else {
/* Concise cleanup because we know there's only one node in the sc */
phree(sc.ignet_push_shares);
- lprintf(7, "Synchronized %d messages to <%s>\n",
+ lprintf(CTDL_INFO, "Synchronized %d messages to <%s>\n",
num_spooled, target_node);
return(num_spooled);
}
static int serialnum = 0;
size_t size;
- lprintf(9, "entering network_bounce()\n");
+ lprintf(CTDL_DEBUG, "entering network_bounce()\n");
if (msg == NULL) return;
/* Clean up */
if (valid != NULL) phree(valid);
CtdlFreeMessage(msg);
- lprintf(9, "leaving network_bounce()\n");
+ lprintf(CTDL_DEBUG, "leaving network_bounce()\n");
}
memcpy(&firstbyte, &buffer[0], 1);
memcpy(&lastbyte, &buffer[size-1], 1);
if ( (firstbyte != 255) || (lastbyte != 0) ) {
- lprintf(7, "Corrupt message! Ignoring.\n");
+ lprintf(CTDL_ERR, "Corrupt message! Ignoring.\n");
return;
}
fp = fopen(filename, "rb");
if (fp == NULL) {
- lprintf(5, "Error opening %s: %s\n",
+ lprintf(CTDL_CRIT, "Error opening %s: %s\n",
filename, strerror(errno));
return;
}
- lprintf(5, "network: processing <%s>\n", filename);
+ lprintf(CTDL_INFO, "network: processing <%s>\n", filename);
/* Look for messages in the data stream and break them out */
while (ch = getc(fp), ch >= 0) {
strcpy(tempfilename, tmpnam(NULL));
if (sock_puts(sock, "NDOP") < 0) return;
if (sock_gets(sock, buf) < 0) return;
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
return;
}
bytes_received = 0L;
fp = fopen(tempfilename, "w");
if (fp == NULL) {
- lprintf(9, "cannot open download file locally: %s\n",
+ lprintf(CTDL_CRIT, "cannot open download file locally: %s\n",
strerror(errno));
return;
}
unlink(tempfilename);
return;
}
- lprintf(9, "%s\n", buf);
+ lprintf(CTDL_DEBUG, "%s\n", buf);
snprintf(buf, sizeof buf, "mv %s ./network/spoolin/%s.%ld",
tempfilename, remote_nodename, (long) getpid());
system(buf);
if (sock_puts(sock, "NUOP") < 0) return;
if (sock_gets(sock, buf) < 0) return;
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
return;
}
fd = open(sfname, O_RDONLY);
if (fd < 0) {
if (errno == ENOENT) {
- lprintf(9, "Nothing to send.\n");
+ lprintf(CTDL_INFO, "Nothing to send.\n");
} else {
- lprintf(5, "cannot open upload file locally: %s\n",
+ lprintf(CTDL_CRIT, "cannot open upload file locally: %s\n",
strerror(errno));
}
return;
close(fd);
if (sock_puts(sock, "UCLS 1") < 0) return;
if (sock_gets(sock, buf) < 0) return;
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] == '2') {
unlink(sfname);
}
if (network_talking_to(node, NTT_CHECK)) return;
network_talking_to(node, NTT_ADD);
- lprintf(5, "Polling node <%s> at %s:%s\n", node, host, port);
+ lprintf(CTDL_INFO, "Polling node <%s> at %s:%s\n", node, host, port);
sock = sock_connect(host, port, "tcp");
if (sock < 0) {
- lprintf(7, "Could not connect: %s\n", strerror(errno));
+ lprintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
network_talking_to(node, NTT_REMOVE);
return;
}
- lprintf(9, "Connected!\n");
+ lprintf(CTDL_DEBUG, "Connected!\n");
/* Read the server greeting */
if (sock_gets(sock, buf) < 0) goto bail;
- lprintf(9, ">%s\n", buf);
+ lprintf(CTDL_DEBUG, ">%s\n", buf);
/* Identify ourselves */
snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (sock_puts(sock, buf) <0) goto bail;
if (sock_gets(sock, buf) < 0) goto bail;
- lprintf(9, ">%s\n", buf);
+ lprintf(CTDL_DEBUG, ">%s\n", buf);
if (buf[0] != '2') goto bail;
/* At this point we are authenticated. */
* Go ahead and run the queue
*/
if (full_processing) {
- lprintf(7, "network: loading outbound queue\n");
+ lprintf(CTDL_INFO, "network: loading outbound queue\n");
ForEachRoom(network_queue_room, NULL);
- lprintf(7, "network: running outbound queue\n");
+ lprintf(CTDL_INFO, "network: running outbound queue\n");
while (rplist != NULL) {
network_spoolout_room(rplist->name);
ptr = rplist;
}
}
- lprintf(7, "network: processing inbound queue\n");
+ lprintf(CTDL_INFO, "network: processing inbound queue\n");
network_do_spoolin();
/* Save the network map back to disk */
network_purge_spoolout();
- lprintf(7, "network: queue run completed\n");
+ lprintf(CTDL_INFO, "network: queue run completed\n");
if (full_processing) {
last_run = time(NULL);
/* Don't do this stuff if this is not a POP3 session! */
if (CC->h_command_function != pop3_command_loop) return;
- lprintf(9, "Performing POP3 cleanup hook\n");
+ lprintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
if (POP3->num_msgs > 0) for (i=0; i<POP3->num_msgs; ++i) {
if (POP3->msgs[i].temp != NULL) {
}
if (POP3->msgs != NULL) phree(POP3->msgs);
- lprintf(9, "Finished POP3 cleanup hook\n");
+ lprintf(CTDL_DEBUG, "Finished POP3 cleanup hook\n");
}
strcpy(username, argbuf);
striplt(username);
- lprintf(9, "Trying <%s>\n", username);
+ lprintf(CTDL_DEBUG, "Trying <%s>\n", username);
if (CtdlLoginExistingUser(username) == login_ok) {
cprintf("+OK Password required for %s\r\n", username);
}
*/
void pop3_add_message(long msgnum, void *userdata) {
FILE *fp;
- lprintf(9, "in pop3_add_message()\n");
+ lprintf(CTDL_DEBUG, "in pop3_add_message()\n");
++POP3->num_msgs;
if (POP3->num_msgs < 2) POP3->msgs = mallok(sizeof(struct pop3msg));
if (msgs >= 0) {
cprintf("+OK %s is logged in (%d messages)\r\n",
CC->user.fullname, msgs);
- lprintf(9, "POP3 password login successful\n");
+ lprintf(CTDL_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
}
else {
cprintf("-ERR Can't open your mailbox\r\n");
strcpy(password, argbuf);
striplt(password);
- lprintf(9, "Trying <%s>\n", password);
+ lprintf(CTDL_DEBUG, "Trying <%s>\n", password);
if (CtdlTryPassword(password) == pass_ok) {
pop3_login();
}
cprintf("%c", ch);
}
if (ch != 10) {
- lprintf(5, "Problem: message ends with 0x%2x, not 0x0a\n", ch);
+ lprintf(CTDL_WARNING, "Problem: message ends with 0x%2x, not 0x0a\n", ch);
}
cprintf(".\r\n");
}
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_gets(cmdbuf) < 1) {
- lprintf(3, "POP3 socket is broken. Ending session.\r\n");
+ lprintf(CTDL_ERR, "POP3 socket is broken. Ending session.\r\n");
CC->kill_me = 1;
return;
}
- lprintf(5, "POP3: %s\r\n", cmdbuf);
+ lprintf(CTDL_INFO, "POP3: %s\r\n", cmdbuf);
while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
if (!strncasecmp(cmdbuf, "NOOP", 4)) {
*/
void smtp_auth_greeting(void) {
cprintf("235 2.0.0 Hello, %s\r\n", CC->user.fullname);
- lprintf(9, "SMTP authenticated login successful\n");
+ lprintf(CTDL_NOTICE, "SMTP authenticated %s\n", CC->user.fullname);
CC->internal_pgm = 0;
CC->cs_flags &= ~CS_STEALTH;
}
char username[SIZ];
CtdlDecodeBase64(username, argbuf, SIZ);
- lprintf(9, "Trying <%s>\n", username);
+ lprintf(CTDL_DEBUG, "Trying <%s>\n", username);
if (CtdlLoginExistingUser(username) == login_ok) {
CtdlEncodeBase64(buf, "Password:", 9);
cprintf("334 %s\r\n", buf);
char password[SIZ];
CtdlDecodeBase64(password, argbuf, SIZ);
- lprintf(9, "Trying <%s>\n", password);
+ lprintf(CTDL_DEBUG, "Trying <%s>\n", password);
if (CtdlTryPassword(password) == pass_ok) {
smtp_auth_greeting();
}
return;
}
- lprintf(9, "Converting message...\n");
+ lprintf(CTDL_DEBUG, "Converting message...\n");
msg = convert_internet_message(body);
/* If the user is locally authenticated, FORCE the From: header to
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_gets(cmdbuf) < 1) {
- lprintf(3, "SMTP socket is broken. Ending session.\n");
+ lprintf(CTDL_CRIT, "SMTP socket is broken. Ending session.\n");
CC->kill_me = 1;
return;
}
- lprintf(5, "SMTP: %s\n", cmdbuf);
+ lprintf(CTDL_INFO, "SMTP: %s\n", cmdbuf);
while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
if (SMTP->command_state == smtp_user) {
/* Parse out the host portion of the recipient address */
process_rfc822_addr(addr, user, node, name);
- lprintf(9, "Attempting SMTP delivery to <%s> @ <%s> (%s)\n",
+ lprintf(CTDL_DEBUG, "Attempting SMTP delivery to <%s> @ <%s> (%s)\n",
user, node, name);
/* Load the message out of the database into a temp file */
/* Figure out what mail exchanger host we have to connect to */
num_mxhosts = getmx(mxhosts, node);
- lprintf(9, "Number of MX hosts for <%s> is %d\n", node, num_mxhosts);
+ lprintf(CTDL_DEBUG, "Number of MX hosts for <%s> is %d\n", node, num_mxhosts);
if (num_mxhosts < 1) {
*status = 5;
snprintf(dsn, SIZ, "No MX hosts found for <%s>", node);
sock = (-1);
for (mx=0; (mx<num_mxhosts && sock < 0); ++mx) {
extract(buf, mxhosts, mx);
- lprintf(9, "Trying <%s>\n", buf);
+ lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
sock = sock_connect(buf, "25", "tcp");
snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
- if (sock >= 0) lprintf(9, "Connected!\n");
+ if (sock >= 0) lprintf(CTDL_DEBUG, "Connected!\n");
if (sock < 0) snprintf(dsn, SIZ, "%s", strerror(errno));
}
strcpy(dsn, "Connection broken during SMTP conversation");
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
if (buf[0] == '4') {
*status = 4;
/* Do a HELO command */
snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
- lprintf(9, ">%s", buf);
+ lprintf(CTDL_DEBUG, ">%s", buf);
sock_write(sock, buf, strlen(buf));
if (ml_sock_gets(sock, buf) < 0) {
*status = 4;
strcpy(dsn, "Connection broken during SMTP HELO");
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
if (buf[0] == '4') {
*status = 4;
/* HELO succeeded, now try the MAIL From: command */
snprintf(buf, sizeof buf, "MAIL From: <%s>\r\n", mailfrom);
- lprintf(9, ">%s", buf);
+ lprintf(CTDL_DEBUG, ">%s", buf);
sock_write(sock, buf, strlen(buf));
if (ml_sock_gets(sock, buf) < 0) {
*status = 4;
strcpy(dsn, "Connection broken during SMTP MAIL");
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
if (buf[0] == '4') {
*status = 4;
/* MAIL succeeded, now try the RCPT To: command */
snprintf(buf, sizeof buf, "RCPT To: <%s>\r\n", addr);
- lprintf(9, ">%s", buf);
+ lprintf(CTDL_DEBUG, ">%s", buf);
sock_write(sock, buf, strlen(buf));
if (ml_sock_gets(sock, buf) < 0) {
*status = 4;
strcpy(dsn, "Connection broken during SMTP RCPT");
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
if (buf[0] == '4') {
*status = 4;
/* RCPT succeeded, now try the DATA command */
- lprintf(9, ">DATA\n");
+ lprintf(CTDL_DEBUG, ">DATA\n");
sock_write(sock, "DATA\r\n", 6);
if (ml_sock_gets(sock, buf) < 0) {
*status = 4;
strcpy(dsn, "Connection broken during SMTP DATA");
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '3') {
if (buf[0] == '4') {
*status = 3;
msg_size -= blocksize;
}
if (buf[blocksize-1] != 10) {
- lprintf(5, "Possible problem: message did not correctly "
- "terminate. (expecting 0x10, got 0x%02x)\n",
+ lprintf(CTDL_WARNING, "Possible problem: message did not "
+ "correctly terminate. (expecting 0x10, got 0x%02x)\n",
buf[blocksize-1]);
}
strcpy(dsn, "Connection broken during SMTP message transmit");
goto bail;
}
- lprintf(9, "%s\n", buf);
+ lprintf(CTDL_DEBUG, "%s\n", buf);
if (buf[0] != '2') {
if (buf[0] == '4') {
*status = 4;
safestrncpy(dsn, &buf[4], 1023);
*status = 2;
- lprintf(9, ">QUIT\n");
+ lprintf(CTDL_DEBUG, ">QUIT\n");
sock_write(sock, "QUIT\r\n", 6);
ml_sock_gets(sock, buf);
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
+ lprintf(CTDL_INFO, "SMTP delivery to <%s> @ <%s> (%s) succeeded\n",
+ user, node, name);
bail: if (msg_fp != NULL) fclose(msg_fp);
sock_close(sock);
struct recptypes *valid;
int successful_bounce = 0;
- lprintf(9, "smtp_do_bounce() called\n");
+ lprintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
strcpy(bounceto, "");
lines = num_tokens(instr, '\n');
extract(dsn, buf, 3);
bounce_this = 0;
- lprintf(9, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
+ lprintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
key, addr, status, dsn);
if (!strcasecmp(key, "bounceto")) {
++num_bounces;
if (bmsg->cm_fields['M'] == NULL) {
- lprintf(2, "ERROR ... M field is null "
+ lprintf(CTDL_ERR, "ERROR ... M field is null "
"(%s:%d)\n", __FILE__, __LINE__);
}
}
/* Deliver the bounce if there's anything worth mentioning */
- lprintf(9, "num_bounces = %d\n", num_bounces);
+ lprintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
if (num_bounces > 0) {
/* First try the user who sent the message */
- lprintf(9, "bounce to user? <%s>\n", bounceto);
+ lprintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto);
if (strlen(bounceto) == 0) {
- lprintf(7, "No bounce address specified\n");
+ lprintf(CTDL_ERR, "No bounce address specified\n");
bounce_msgid = (-1L);
}
}
CtdlFreeMessage(bmsg);
- lprintf(9, "Done processing bounces\n");
+ lprintf(CTDL_DEBUG, "Done processing bounces\n");
}
time_t last_attempted = 0L;
time_t retry = SMTP_RETRY_INTERVAL;
- lprintf(9, "smtp_do_procmsg(%ld)\n", msgnum);
+ lprintf(CTDL_DEBUG, "smtp_do_procmsg(%ld)\n", msgnum);
msg = CtdlFetchMessage(msgnum);
if (msg == NULL) {
- lprintf(3, "SMTP: tried %ld but no such message!\n", msgnum);
+ lprintf(CTDL_ERR, "SMTP: tried %ld but no such message!\n", msgnum);
return;
}
* Postpone delivery if we've already tried recently.
*/
if (((time(NULL) - last_attempted) < retry) && (run_queue_now == 0)) {
- lprintf(7, "Retry time not yet reached.\n");
+ lprintf(CTDL_DEBUG, "Retry time not yet reached.\n");
phree(instr);
return;
}
* Bail out if there's no actual message associated with this
*/
if (text_msgid < 0L) {
- lprintf(3, "SMTP: no 'msgid' directive found!\n");
+ lprintf(CTDL_ERR, "SMTP: no 'msgid' directive found!\n");
phree(instr);
return;
}
--i;
--lines;
- lprintf(9, "SMTP: Trying <%s>\n", addr);
+ lprintf(CTDL_DEBUG, "SMTP: Trying <%s>\n", addr);
smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid);
if (status != 2) {
if (results == NULL) {
/*
* Go ahead and run the queue
*/
- lprintf(7, "SMTP: processing outbound queue\n");
+ lprintf(CTDL_INFO, "SMTP: processing outbound queue\n");
if (getroom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
- lprintf(3, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
+ lprintf(CTDL_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
return;
}
CtdlForEachMessage(MSGS_ALL, 0L,
SPOOLMIME, NULL, smtp_do_procmsg, NULL);
- lprintf(7, "SMTP: queue run completed\n");
+ lprintf(CTDL_INFO, "SMTP: queue run completed\n");
run_queue_now = 0;
doing_queue = 0;
}
/* Try them one by one until we get a working one */
for (sa=0; sa<num_sahosts; ++sa) {
extract(buf, sahosts, sa);
- lprintf(9, "Connecting to SpamAssassin at <%s>\n", buf);
+ lprintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
- if (sock >= 0) lprintf(9, "Connected!\n");
+ if (sock >= 0) lprintf(CTDL_DEBUG, "Connected!\n");
}
if (sock < 0) {
}
/* Command */
- lprintf(9, "Transmitting command\n");
+ lprintf(CTDL_DEBUG, "Transmitting command\n");
sprintf(buf, "CHECK SPAMC/1.2\r\n\r\n");
sock_write(sock, buf, strlen(buf));
sock_shutdown(sock, SHUT_WR);
/* Response */
- lprintf(9, "Awaiting response\n");
+ lprintf(CTDL_DEBUG, "Awaiting response\n");
if (sock_gets(sock, buf) < 0) {
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (strncasecmp(buf, "SPAMD", 5)) {
goto bail;
}
if (sock_gets(sock, buf) < 0) {
goto bail;
}
- lprintf(9, "<%s\n", buf);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
if (!strncasecmp(buf, "Spam: True", 10)) {
is_spam = 1;
}
extern struct CitContext *ContextList;
void CleanupTest(void) {
- lprintf(9, "--- test of adding an unload hook --- \n");
+ lprintf(CTDL_DEBUG, "--- test of adding an unload hook --- \n");
}
void NewRoomTest(void) {
- lprintf(9, "--- test module was told we're now in a new room ---\n");
+ lprintf(CTDL_DEBUG, "--- test module was told we're now in a new room ---\n");
}
void SessionStartTest(void) {
- lprintf(9, "--- starting up session %d ---\n",
+ lprintf(CTDL_DEBUG, "--- starting up session %d ---\n",
CC->cs_pid);
}
void SessionStopTest(void) {
- lprintf(9, "--- ending session %d ---\n",
+ lprintf(CTDL_DEBUG, "--- ending session %d ---\n",
CC->cs_pid);
}
void LoginTest(void) {
- lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
+ lprintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
}
while (rplist != NULL) {
if (lgetroom(&qr, rplist->name) == 0) {
- lprintf(9, "Processing <%s>...\n", rplist->name);
+ lprintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
if ( (qr.QRflags & QR_MAILBOX) == 0) {
- lprintf(9, " -- not a mailbox\n");
+ lprintf(CTDL_DEBUG, " -- not a mailbox\n");
}
else {
qr.QRgen = time(NULL);
- lprintf(9, " -- fixed!\n");
+ lprintf(CTDL_DEBUG, " -- fixed!\n");
}
lputroom(&qr);
}
* quick fix to bump mailbox generation numbers
*/
void bump_mailbox_generation_numbers(void) {
- lprintf(5, "Applying security fix to mailbox rooms\n");
+ lprintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
ForEachRoom(cmd_bmbx_backend, NULL);
cmd_bmbx_backend(NULL, NULL);
return;
while (uplist != NULL) {
if (lgetuser(&us, uplist->user) == 0) {
- lprintf(9, "Processing <%s>...\n", uplist->user);
+ lprintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
if (us.uid == BBSUID) {
us.uid = (-1);
}
* quick fix to change all BBSUID users to (-1)
*/
void convert_bbsuid_to_minusone(void) {
- lprintf(5, "Applying uid changes\n");
+ lprintf(CTDL_WARNING, "Applying uid changes\n");
ForEachUser(cbtm_backend, NULL);
cbtm_backend(NULL, NULL);
return;
void check_server_upgrades(void) {
get_control();
- lprintf(5, "Server-hosted upgrade level is %d.%02d\n",
+ lprintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
(CitControl.version / 100),
(CitControl.version % 100) );
if (CitControl.version < REV_LEVEL) {
- lprintf(5, "Server hosted updates need to be processed at "
- "this time. Please wait...\n");
+ lprintf(CTDL_WARNING,
+ "Server hosted updates need to be processed at "
+ "this time. Please wait...\n");
}
else {
return;
update_config();
if ((CitControl.version > 000) && (CitControl.version < 555)) {
- lprintf(1, "Your data files are from a version of Citadel\n"
+ lprintf(CTDL_EMERG,
+ "Your data files are from a version of Citadel\n"
"that is too old to be upgraded. Sorry.\n");
exit(EXIT_FAILURE);
}
int count = 0;
artv_global_message_list = fopen(artv_tempfilename1, "r");
- lprintf(7, "Opened %s\n", artv_tempfilename1);
+ lprintf(CTDL_INFO, "Opened %s\n", artv_tempfilename1);
while (fgets(buf, sizeof(buf), artv_global_message_list) != NULL) {
msgnum = atol(buf);
if (msgnum > 0L) {
}
}
fclose(artv_global_message_list);
- lprintf(7, "Exported %d messages.\n", count);
+ lprintf(CTDL_INFO, "Exported %d messages.\n", count);
}
void artv_import_config(void) {
char buf[SIZ];
- lprintf(9, "Importing config file\n");
+ lprintf(CTDL_DEBUG, "Importing config file\n");
client_gets(config.c_nodename);
- lprintf(9, "c_nodename = %s\n", config.c_nodename);
+ lprintf(CTDL_DEBUG, "c_nodename = %s\n", config.c_nodename);
client_gets(config.c_fqdn);
client_gets(config.c_humannode);
client_gets(config.c_phonenum);
client_gets(buf); config.c_restrict = atoi(buf);
client_gets(config.c_bbs_city);
client_gets(config.c_sysadm);
- lprintf(9, "c_sysadm = %s\n", config.c_sysadm);
+ lprintf(CTDL_DEBUG, "c_sysadm = %s\n", config.c_sysadm);
client_gets(buf); config.c_setup_level = atoi(buf);
client_gets(buf); config.c_maxsessions = atoi(buf);
client_gets(buf); config.c_port_number = atoi(buf);
client_gets(config.c_ldap_bind_dn);
client_gets(config.c_ldap_bind_pw);
put_config();
- lprintf(7, "Imported config file\n");
+ lprintf(CTDL_INFO, "Imported config file\n");
}
void artv_import_control(void) {
char buf[SIZ];
- lprintf(9, "Importing control file\n");
+ lprintf(CTDL_DEBUG, "Importing control file\n");
client_gets(buf); CitControl.MMhighest = atol(buf);
client_gets(buf); CitControl.MMflags = atoi(buf);
client_gets(buf); CitControl.MMnextuser = atol(buf);
client_gets(buf); CitControl.MMnextroom = atol(buf);
client_gets(buf); CitControl.version = atoi(buf);
put_control();
- lprintf(7, "Imported control file\n");
+ lprintf(CTDL_INFO, "Imported control file\n");
}
client_gets(buf); qrbuf.QRflags2 = atoi(buf);
client_gets(buf); qrbuf.QRdefaultview = atoi(buf);
putroom(&qrbuf);
- lprintf(7, "Imported room <%s>\n", qrbuf.QRname);
+ lprintf(CTDL_INFO, "Imported room <%s>\n", qrbuf.QRname);
/* format of message list export is all message numbers output
* one per line terminated by a 0.
*/
CtdlSaveMsgPointerInRoom(qrbuf.QRname, msgnum, 0);
++msgcount;
}
- lprintf(7, "(%d messages)\n", msgcount);
+ lprintf(CTDL_INFO, "(%d messages)\n", msgcount);
}
client_gets(buf); flbuf.f_ep.expire_mode = atoi(buf);
client_gets(buf); flbuf.f_ep.expire_value = atoi(buf);
putfloor(&flbuf, i);
- lprintf(7, "Imported floor #%d (%s)\n", i, flbuf.f_name);
+ lprintf(CTDL_INFO, "Imported floor #%d (%s)\n", i, flbuf.f_name);
}
client_gets(buf); vbuf.v_flags = atoi(buf);
client_gets(buf); vbuf.v_view = atoi(buf);
put_visit(&vbuf);
- lprintf(7, "Imported visit %ld/%ld/%ld\n",
+ lprintf(CTDL_INFO, "Imported visit %ld/%ld/%ld\n",
vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
}
client_gets(buf); smi.meta_refcount = atoi(buf);
client_gets(smi.meta_content_type);
- lprintf(7, "message #%ld\n", msgnum);
+ lprintf(CTDL_INFO, "message #%ld\n", msgnum);
/* decode base64 message text */
strcpy(tempfile, tmpnam(NULL));
fseek(fp, 0L, SEEK_END);
msglen = ftell(fp);
fclose(fp);
- lprintf(9, "msglen = %ld\n", msglen);
+ lprintf(CTDL_DEBUG, "msglen = %ld\n", msglen);
mbuf = mallok(msglen);
fp = fopen(tempfile, "rb");
unlink(tempfile);
PutMetaData(&smi);
- lprintf(7, "Imported message %ld\n", msgnum);
+ lprintf(CTDL_INFO, "Imported message %ld\n", msgnum);
}
cprintf("%d sock it to me\n", SEND_LISTING);
while (client_gets(buf), strcmp(buf, "000")) {
- lprintf(9, "import keyword: <%s>\n", buf);
+ lprintf(CTDL_DEBUG, "import keyword: <%s>\n", buf);
if (!strcasecmp(buf, "version")) {
client_gets(s_version);
version = atoi(s_version);
if ((version<EXPORT_REV_MIN) || (version>REV_LEVEL)) {
- lprintf(7, "Version mismatch - aborting\n");
+ lprintf(CTDL_ERR, "Version mismatch in ARTV import; aborting\n");
break;
}
}
else break;
}
- lprintf(7, "Invalid keyword <%s>. Flushing input.\n", buf);
+ lprintf(CTDL_INFO, "Invalid keyword <%s>. Flushing input.\n", buf);
while (client_gets(buf), strcmp(buf, "000")) ;;
}
* probably just the networker or something.
*/
if (CC->logged_in) {
- lprintf(9, "Checking for <%s>...\n", internet_addr);
+ lprintf(CTDL_DEBUG, "Checking for <%s>...\n", internet_addr);
if (CtdlDirectoryLookup(buf, internet_addr) == 0) {
if (strcasecmp(buf, citadel_addr)) {
/* This address belongs to someone else.
* Bail out silently without saving.
*/
- lprintf(9, "DOOP!\n");
+ lprintf(CTDL_DEBUG, "DOOP!\n");
return;
}
}
}
- lprintf(9, "ADDING!\n");
+ lprintf(CTDL_INFO, "Adding %s (%s) to directory\n",
+ citadel_addr, internet_addr);
CtdlDirectoryAddUser(internet_addr, citadel_addr);
}
/* Set expiration policy to manual; otherwise objects will be lost! */
if (lgetroom(&qr, USERCONTACTSROOM)) {
- lprintf(3, "Couldn't get the user CONTACTS room!\n");
+ lprintf(CTDL_ERR, "Couldn't get the user CONTACTS room!\n");
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
/* any other parameter makes it crash and burn */
else {
- lprintf(1, "citserver: usage: "
+ lprintf(CTDL_EMERG, "citserver: usage: "
"citserver [-tTraceFile] "
"[-lLogFacility] "
"[-d] [-f]"
}
/* Tell 'em who's in da house */
- lprintf(1, "\n");
- lprintf(1, "\n");
- lprintf(1,"*** Citadel/UX messaging server engine v%d.%02d ***\n",
- (REV_LEVEL/100),
- (REV_LEVEL%100) );
- lprintf(1,"Copyright (C) 1987-2003 by the Citadel/UX development team.\n");
- lprintf(1,"This program is distributed under the terms of the GNU ");
- lprintf(1,"General Public License.\n");
- lprintf(1, "\n");
+ lprintf(CTDL_NOTICE, "\n");
+ lprintf(CTDL_NOTICE, "\n");
+ lprintf(CTDL_NOTICE,
+ "*** Citadel/UX messaging server engine v%d.%02d ***\n",
+ (REV_LEVEL/100), (REV_LEVEL%100));
+ lprintf(CTDL_NOTICE,
+ "Copyright (C) 1987-2003 by the Citadel/UX development team.\n");
+ lprintf(CTDL_NOTICE,
+ "This program is distributed under the terms of the GNU "
+ "General Public License.\n");
+ lprintf(CTDL_NOTICE, "\n");
/* Load site-specific parameters, and set the ipgm secret */
- lprintf(7, "Loading citadel.config\n");
+ lprintf(CTDL_INFO, "Loading citadel.config\n");
get_config();
config.c_ipgm_secret = rand();
put_config();
/*
* Load any server-side extensions available here.
*/
- lprintf(7, "Initializing server extensions\n");
+ lprintf(CTDL_INFO, "Initializing server extensions\n");
size = strlen(bbs_home_directory) + 9;
initialize_server_extensions();
* to get back on that list.
*/
if (pipe(rescan)) {
- lprintf(1, "Can't create rescan pipe!\n");
+ lprintf(CTDL_EMERG, "Can't create rescan pipe!\n");
exit(errno);
}
*/
if (drop_root_perms) {
if ((pw = getpwuid(BBSUID)) == NULL)
- lprintf(1, "WARNING: getpwuid(%ld): %s\n"
+ lprintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
"Group IDs will be incorrect.\n", (long)BBSUID,
strerror(errno));
else {
initgroups(pw->pw_name, pw->pw_gid);
if (setgid(pw->pw_gid))
- lprintf(3, "setgid(%ld): %s\n", (long)pw->pw_gid,
+ lprintf(CTDL_CRIT, "setgid(%ld): %s\n", (long)pw->pw_gid,
strerror(errno));
}
- lprintf(7, "Changing uid to %ld\n", (long)BBSUID);
+ lprintf(CTDL_INFO, "Changing uid to %ld\n", (long)BBSUID);
if (setuid(BBSUID) != 0) {
- lprintf(3, "setuid() failed: %s\n", strerror(errno));
+ lprintf(CTDL_CRIT, "setuid() failed: %s\n", strerror(errno));
}
}
/*
* Now create a bunch of worker threads.
*/
- lprintf(9, "Starting %d worker threads\n", config.c_min_workers-1);
+ lprintf(CTDL_DEBUG, "Starting %d worker threads\n", config.c_min_workers-1);
begin_critical_section(S_WORKER_LIST);
for (i=0; i<(config.c_min_workers-1); ++i) {
create_worker();
worker_thread(NULL);
/* Server is exiting. Wait for workers to shutdown. */
- lprintf(7, "Waiting for worker threads to shut down\n");
+ lprintf(CTDL_INFO, "Waiting for worker threads to shut down\n");
begin_critical_section(S_WORKER_LIST);
while (worker_list != NULL) {
/* avoid deadlock with an exiting thread */
end_critical_section(S_WORKER_LIST);
if ((i = pthread_join(wnp->tid, NULL)))
- lprintf(1, "pthread_join: %s\n", strerror(i));
+ lprintf(CTDL_CRIT, "pthread_join: %s\n", strerror(i));
phree(wnp);
begin_critical_section(S_WORKER_LIST);
}
/*
* Logging level to use if none is specified on the command line.
+ * Note that this will suppress messages before they even get to syslog().
*/
-#define DEFAULT_VERBOSITY 9
+#define DEFAULT_VERBOSITY 7
* Note: the variable "buf" below needs to be large enough to handle any
* log data sent through this function. BE CAREFUL!
*/
-void lprintf(int loglevel, const char *format, ...) {
+void lprintf(enum LogLevel loglevel, const char *format, ...) {
va_list arg_ptr;
char buf[SIZ];
snprintf(buf, 6, "[%3d]", CC->cs_pid);
buf[5] = ' ';
}
- syslog(LOG_NOTICE, buf);
+ syslog(loglevel, buf);
}
}
else if (loglevel <= verbosity) {
ptr = malloc(tsize);
if (ptr == NULL) {
- lprintf(3, "DANGER! mallok(%d) at %s:%d failed!\n",
+ lprintf(CTDL_ALERT, "DANGER! mallok(%d) at %s:%d failed!\n",
tsize, tfile, tline);
return(NULL);
}
* session to which the calling thread is currently bound.
*/
if (pthread_key_create(&MyConKey, NULL) != 0) {
- lprintf(1, "Can't create TSD key!! %s\n", strerror(errno));
+ lprintf(CTDL_CRIT, "Can't create TSD key!! %s\n", strerror(errno));
}
/*
*/
void begin_critical_section(int which_one)
{
- /* lprintf(9, "begin_critical_section(%d)\n", which_one); */
+ /* lprintf(CTDL_DEBUG, "begin_critical_section(%d)\n", which_one); */
/* ensure nobody ever tries to do a critical section within a
transaction; this could lead to deadlock. */
cdb_check_handles();
*/
void end_critical_section(int which_one)
{
- /* lprintf(9, "end_critical_section(%d)\n", which_one); */
+ /* lprintf(CTDL_DEBUG, "end_critical_section(%d)\n", which_one); */
pthread_mutex_unlock(&Critters[which_one]);
}
s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s < 0) {
- lprintf(1, "citserver: Can't create a socket: %s\n",
+ lprintf(CTDL_EMERG, "citserver: Can't create a socket: %s\n",
strerror(errno));
return(-1);
}
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- lprintf(1, "citserver: Can't bind: %s\n",
+ lprintf(CTDL_EMERG, "citserver: Can't bind: %s\n",
strerror(errno));
close(s);
return(-1);
}
if (listen(s, actual_queue_len) < 0) {
- lprintf(1, "citserver: Can't listen: %s\n", strerror(errno));
+ lprintf(CTDL_EMERG, "citserver: Can't listen: %s\n", strerror(errno));
close(s);
return(-1);
}
i = unlink(sockpath);
if (i != 0) if (errno != ENOENT) {
- lprintf(1, "citserver: can't unlink %s: %s\n",
+ lprintf(CTDL_EMERG, "citserver: can't unlink %s: %s\n",
sockpath, strerror(errno));
return(-1);
}
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
- lprintf(1, "citserver: Can't create a socket: %s\n",
+ lprintf(CTDL_EMERG, "citserver: Can't create a socket: %s\n",
strerror(errno));
return(-1);
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- lprintf(1, "citserver: Can't bind: %s\n",
+ lprintf(CTDL_EMERG, "citserver: Can't bind: %s\n",
strerror(errno));
return(-1);
}
if (listen(s, actual_queue_len) < 0) {
- lprintf(1, "citserver: Can't listen: %s\n", strerror(errno));
+ lprintf(CTDL_EMERG, "citserver: Can't listen: %s\n", strerror(errno));
return(-1);
}
me = (struct CitContext *) mallok(sizeof(struct CitContext));
if (me == NULL) {
- lprintf(1, "citserver: can't allocate memory!!\n");
+ lprintf(CTDL_ALERT, "citserver: can't allocate memory!!\n");
return NULL;
}
memset(me, 0, sizeof(struct CitContext));
retval = write(sock, &buf[bytes_written],
nbytes - bytes_written);
if (retval < 1) {
- lprintf(2, "client_write() failed: %s\n",
+ lprintf(CTDL_ERR, "client_write() failed: %s\n",
strerror(errno));
if (sock == CC->client_socket) CC->kill_me = 1;
return;
rlen = read(CC->client_socket, &buf[len], bytes-len);
if (rlen<1) {
- lprintf(2, "client_read() failed: %s\n",
+ lprintf(CTDL_ERR, "client_read() failed: %s\n",
strerror(errno));
CC->kill_me = 1;
return(-1);
serviceptr = serviceptr->next ) {
if (serviceptr->tcp_port > 0)
- lprintf(3, "Closing listener on port %d\n",
+ lprintf(CTDL_INFO, "Closing listener on port %d\n",
serviceptr->tcp_port);
if (serviceptr->sockpath != NULL)
- lprintf(3, "Closing listener on '%s'\n",
+ lprintf(CTDL_INFO, "Closing listener on '%s'\n",
serviceptr->sockpath);
close(serviceptr->msock);
n = mallok(sizeof(struct worker_node));
if (n == NULL) {
- lprintf(1, "can't allocate worker_node, exiting\n");
+ lprintf(CTDL_EMERG, "can't allocate worker_node, exiting\n");
time_to_die = -1;
return;
}
if ((ret = pthread_attr_init(&attr))) {
- lprintf(1, "pthread_attr_init: %s\n", strerror(ret));
+ lprintf(CTDL_EMERG, "pthread_attr_init: %s\n", strerror(ret));
time_to_die = -1;
return;
}
/* we seem to need something bigger than FreeBSD's default 64k stack */
if ((ret = pthread_attr_setstacksize(&attr, 128 * 1024))) {
- lprintf(1, "pthread_attr_setstacksize: %s\n", strerror(ret));
+ lprintf(CTDL_EMERG, "pthread_attr_setstacksize: %s\n", strerror(ret));
time_to_die = -1;
return;
}
if ((ret = pthread_create(&n->tid, &attr, worker_thread, NULL) != 0))
{
- lprintf(1, "Can't create worker thread: %s\n",
+ lprintf(CTDL_ALERT, "Can't create worker thread: %s\n",
strerror(ret));
}
* section, so we have to do it like this.
*/
if (rem != NULL) {
- lprintf(9, "Purging session %d\n", rem->cs_pid);
+ lprintf(CTDL_DEBUG, "Purging session %d\n", rem->cs_pid);
RemoveContext(rem);
}
struct ServiceFunctionHook *serviceptr;
int m;
- lprintf(9, "Initializing master fdset\n");
+ lprintf(CTDL_DEBUG, "Initializing master fdset\n");
FD_ZERO(&masterfds);
masterhighest = 0;
- lprintf(9, "Will listen on rescan pipe %d\n", rescan[0]);
+ lprintf(CTDL_DEBUG, "Will listen on rescan pipe %d\n", rescan[0]);
FD_SET(rescan[0], &masterfds);
if (rescan[0] > masterhighest) masterhighest = rescan[0];
for (serviceptr = ServiceHookTable; serviceptr != NULL;
serviceptr = serviceptr->next ) {
m = serviceptr->msock;
- lprintf(9, "Will listen on master socket %d\n", m);
+ lprintf(CTDL_DEBUG, "Will listen on master socket %d\n", m);
FD_SET(m, &masterfds);
if (m > masterhighest) {
masterhighest = m;
}
}
- lprintf(9, "masterhighest = %d\n", masterhighest);
+ lprintf(CTDL_DEBUG, "masterhighest = %d\n", masterhighest);
}
*/
if (retval < 0) {
if (errno != EINTR) {
- lprintf(9, "Exiting (%s)\n", strerror(errno));
+ lprintf(CTDL_EMERG, "Exiting (%s)\n", strerror(errno));
time_to_die = 1;
} else if (!time_to_die)
goto do_select;
if (FD_ISSET(serviceptr->msock, &readfds)) {
ssock = accept(serviceptr->msock, NULL, 0);
if (ssock < 0) {
- lprintf(2, "citserver: accept(): %s\n",
+ lprintf(CTDL_CRIT,
+ "citserver: accept(): %s\n",
strerror(errno));
}
else {
- lprintf(7, "citserver: "
+ lprintf(CTDL_NOTICE,
"New client socket %d\n",
ssock);
#include "sysdep.h"
#include "server.h"
+/* Logging levels - correspond to syslog(3) */
+enum LogLevel {
+ /* When about to exit the server for an unrecoverable error */
+ CTDL_EMERG, /* system is unusable */
+ /* Manual intervention is required to avoid an abnormal exit */
+ CTDL_ALERT, /* action must be taken immediately */
+ /* The server can continue to run with degraded functionality */
+ CTDL_CRIT, /* critical conditions */
+ /* An error occurs but the server continues to run normally */
+ CTDL_ERR, /* error conditions */
+ /* An abnormal condition was detected; server will continue normally */
+ CTDL_WARNING, /* warning conditions */
+ /* Normal messages (login/out, activity, etc.) */
+ CTDL_NOTICE, /* normal but significant condition */
+ /* Unimportant progress messages, etc. */
+ CTDL_INFO, /* informational */
+ /* Debugging messages */
+ CTDL_DEBUG, /* debug-level messages */
+};
+
#ifdef __GNUC__
-void lprintf (int loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
+void lprintf (enum LogLevel loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
#else
-void lprintf (int loglevel, const char *format, ...);
+void lprintf (enum LogLevel loglevel, const char *format, ...);
void cprintf (const char *format, ...);
#endif
struct worker_node *next;
} *worker_list;
-
extern int SyslogFacility(char *name);
extern int syslog_facility;
{
int i;
- lprintf(3, "<%s> logged in\n", CC->curr_user);
+ lprintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
lgetuser(&CC->user, CC->curr_user);
++(CC->user.timescalled);
char buf[24];
if (pipe(pipev)) {
- lprintf(1, "pipe failed (%s): denying autologin access for "
+ lprintf(CTDL_ERROR, "pipe failed (%s): denying autologin access for "
"uid %ld\n", strerror(errno), (long)uid);
return 0;
}
switch (pid = fork()) {
case -1:
- lprintf(1, "fork failed (%s): denying autologin access for "
+ lprintf(CTDL_ERROR, "fork failed (%s): denying autologin access for "
"uid %ld\n", strerror(errno), (long)uid);
close(pipev[0]);
close(pipev[1]);
while (waitpid(pid, &status, 0) == -1)
if (errno != EINTR) {
- lprintf(1, "waitpid failed (%s): denying autologin "
+ lprintf(CTDL_ERROR, "waitpid failed (%s): denying autologin "
"access for uid %ld\n",
strerror(errno), (long)uid);
return 0;
int code;
if ((CC->logged_in)) {
- lprintf(5, "CtdlTryPassword: already logged in\n");
+ lprintf(CTDL_WARNING, "CtdlTryPassword: already logged in\n");
return pass_already_logged_in;
}
if (!strcmp(CC->curr_user, NLI)) {
- lprintf(5, "CtdlTryPassword: no user selected\n");
+ lprintf(CTDL_WARNING, "CtdlTryPassword: no user selected\n");
return pass_no_user;
}
if (getuser(&CC->user, CC->curr_user)) {
- lprintf(5, "CtdlTryPassword: internal error\n");
+ lprintf(CTDL_ERR, "CtdlTryPassword: internal error\n");
return pass_internal_error;
}
if (password == NULL) {
- lprintf(5, "CtdlTryPassword: NULL password string supplied\n");
+ lprintf(CTDL_INFO, "CtdlTryPassword: NULL password string supplied\n");
return pass_wrong_password;
}
code = (-1);
do_login();
return pass_ok;
} else {
- lprintf(3, "Bad password specified for <%s>\n", CC->curr_user);
+ lprintf(CTDL_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
return pass_wrong_password;
}
}
makeuserkey(usernamekey, pname);
if (getuser(&usbuf, pname) != 0) {
- lprintf(5, "Cannot purge user <%s> - not found\n", pname);
+ lprintf(CTDL_ERR, "Cannot purge user <%s> - not found\n", pname);
return (ERROR + NO_SUCH_USER);
}
/* Don't delete a user who is currently logged in. Instead, just
}
end_critical_section(S_SESSION_TABLE);
if (user_is_logged_in == 1) {
- lprintf(5, "User <%s> is logged in; not deleting.\n", pname);
+ lprintf(CTDL_WARNING, "User <%s> is logged in; not deleting.\n", pname);
usbuf.axlevel = 0;
putuser(&usbuf);
return (1);
}
- lprintf(5, "Deleting user <%s>\n", pname);
+ lprintf(CTDL_NOTICE, "Deleting user <%s>\n", pname);
/* Perform any purge functions registered by server extensions */
PerformUserHooks(usbuf.fullname, usbuf.usernum, EVT_PURGEUSER);
}
}
- lprintf(3, "New user <%s> created\n", username);
+ lprintf(CTDL_NOTICE, "New user <%s> created\n", username);
return (0);
}
safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
lputuser(&CC->user);
cprintf("%d Password changed.\n", CIT_OK);
- lprintf(3, "Password changed for user <%s>\n", CC->curr_user);
+ lprintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
PerformSessionHooks(EVT_SETPASS);
}