From: Michael Hampton Date: Fri, 27 Feb 2004 17:23:22 +0000 (+0000) Subject: * Use syslog-compatible logging levels in lprintf(); the loglevel chosen X-Git-Tag: v7.86~5569 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=2e5bfef2c1708874507a51c9469b2c181b5523f4 * Use syslog-compatible logging levels in lprintf(); the loglevel chosen is passed directly to syslog(). The available levels are docuemnted in sysdep_decls.h. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 93db6cf78..19fb88317 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $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 @@ -5420,4 +5425,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.h b/citadel/citadel.h index d0d961d99..71f000266 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -306,7 +306,7 @@ enum { #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 diff --git a/citadel/citserver.c b/citadel/citserver.c index 826e00d2b..ae36d036b 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -77,10 +77,10 @@ void master_startup(void) { 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) { @@ -89,7 +89,7 @@ void master_startup(void) { 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); @@ -101,7 +101,7 @@ void master_startup(void) { 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); @@ -113,12 +113,12 @@ void master_startup(void) { } 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"); } @@ -136,14 +136,14 @@ void master_cleanup(void) { } /* 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); } @@ -158,7 +158,7 @@ void deallocate_user_data(struct CitContext *con) 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); @@ -181,16 +181,16 @@ void RemoveContext (struct CitContext *con) 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; @@ -209,7 +209,7 @@ void RemoveContext (struct CitContext *con) 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; } @@ -224,17 +224,17 @@ void RemoveContext (struct CitContext *con) 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. */ @@ -242,7 +242,7 @@ void RemoveContext (struct CitContext *con) /* Free up the memory used by this context */ phree(con); - lprintf(9, "Done with RemoveContext()\n"); + lprintf(CTDL_DEBUG, "Done with RemoveContext()\n"); } @@ -264,7 +264,7 @@ void *CtdlGetUserData(unsigned long requested_sym) 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; } @@ -277,7 +277,7 @@ void CtdlAllocUserData(unsigned long requested_sym, size_t num_bytes) { 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) { @@ -297,7 +297,7 @@ void CtdlAllocUserData(unsigned long requested_sym, size_t num_bytes) 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); } @@ -315,7 +315,7 @@ void CtdlReallocUserData(unsigned long requested_sym, size_t num_bytes) } } - lprintf(2, "CtdlReallocUserData() ERROR: symbol %ld not found!\n", + lprintf(CTDL_ERR, "CtdlReallocUserData() ERROR: symbol %ld not found!\n", requested_sym); } @@ -408,13 +408,13 @@ int is_public_client(void) */ 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) { @@ -443,18 +443,18 @@ int is_public_client(void) 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; ics_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); } @@ -498,7 +498,7 @@ void cmd_iden(char *argbuf) } 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, @@ -510,7 +510,7 @@ void cmd_iden(char *argbuf) } } - 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), @@ -701,7 +701,7 @@ void cmd_term(char *cmdbuf) 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) { @@ -778,7 +778,7 @@ void cmd_ipgm(char *argbuf) 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; } @@ -902,7 +902,7 @@ void begin_session(struct CitContext *con) 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); @@ -934,11 +934,11 @@ void do_command_loop(void) { 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 diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index 83e915cb2..89682ccc4 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -55,7 +55,7 @@ int sock_connect(char *host, char *service, char *protocol) 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); } @@ -63,12 +63,12 @@ int sock_connect(char *host, char *service, char *protocol) 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); } @@ -80,12 +80,12 @@ int sock_connect(char *host, char *service, char *protocol) 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); @@ -117,13 +117,13 @@ int sock_read_to(int sock, char *buf, int bytes, int timeout) 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); } diff --git a/citadel/control.c b/citadel/control.c index 86533a8ee..973c10fd4 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -80,7 +80,7 @@ void get_control(void) } } if (control_fp == NULL) { - lprintf(1, "ERROR opening citadel.control: %s\n", + lprintf(CTDL_ALERT, "ERROR opening citadel.control: %s\n", strerror(errno)); return; } diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index 6a2f0be62..3a5a04ee8 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -80,7 +80,7 @@ static void txabort(DB_TXN *tid) { 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(); } } @@ -92,7 +92,7 @@ static void txcommit(DB_TXN *tid) { 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(); } } @@ -104,7 +104,7 @@ static void txbegin(DB_TXN **tid) { 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(); } } @@ -113,7 +113,7 @@ static void cclose(DBC *cursor) { 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(); } } @@ -125,7 +125,7 @@ static void bailIfCursor(DBC **cursors, const char *msg) 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(); } } @@ -137,7 +137,7 @@ static void check_handles(void *arg) { 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(); } } @@ -204,20 +204,20 @@ static void cdb_cull_logs(void) { 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), @@ -235,7 +235,7 @@ static void cdb_cull_logs(void) { free(list); } - lprintf(5, "Database log file cull ended.\n"); + lprintf(CTDL_INFO, "Database log file cull ended.\n"); } @@ -252,7 +252,7 @@ static void cdb_checkpoint(void) { 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(); } @@ -282,11 +282,11 @@ void open_databases(void) 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 /* @@ -295,11 +295,11 @@ void open_databases(void) */ 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"); @@ -310,35 +310,35 @@ void open_databases(void) */ 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); } @@ -358,19 +358,19 @@ void open_databases(void) , 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"); } @@ -386,15 +386,15 @@ void close_databases(void) 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(); } @@ -403,7 +403,7 @@ void close_databases(void) /* 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(); } } @@ -440,7 +440,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) { compressed_data, sourceLen ) != Z_OK) { - lprintf(1, "uncompress() error\n"); + lprintf(CTDL_EMERG, "uncompress() error\n"); abort(); } @@ -498,7 +498,7 @@ int cdb_store(int cdb, (uLongf) cdatalen, 1 ) != Z_OK) { - lprintf(1, "compress2() error\n"); + lprintf(CTDL_EMERG, "compress2() error\n"); abort(); } zheader.compressed_len = (size_t) destLen; @@ -519,8 +519,7 @@ int cdb_store(int cdb, 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 @@ -549,8 +548,7 @@ int cdb_store(int cdb, } 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(); } } @@ -585,8 +583,7 @@ int cdb_delete(int cdb, void *key, int keylen) 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(); } @@ -608,8 +605,7 @@ int cdb_delete(int cdb, void *key, int keylen) } 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(); } } @@ -633,7 +629,7 @@ static DBC *localcursor(int cdb) if (ret) { - lprintf(1, "localcursor: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "localcursor: %s\n", db_strerror(ret)); abort(); } @@ -683,7 +679,7 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) 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(); } @@ -692,7 +688,7 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) 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(); } @@ -740,7 +736,7 @@ void cdb_rewind(int cdb) */ 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(); } } @@ -766,7 +762,7 @@ struct cdbdata *cdb_next_item(int cdb) 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(); } @@ -797,7 +793,7 @@ void cdb_begin_transaction(void) { if (MYTID != NULL) { - lprintf(1, "cdb_begin_transaction: ERROR: nested transaction\n"); + lprintf(CTDL_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n"); abort(); } @@ -809,14 +805,14 @@ void cdb_end_transaction(void) { 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 @@ -836,7 +832,7 @@ void cdb_trunc(int cdb) 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 @@ -858,8 +854,7 @@ void cdb_trunc(int cdb) } 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(); } } diff --git a/citadel/domain.c b/citadel/domain.c index 94d93d407..8af3bc37b 100644 --- a/citadel/domain.c +++ b/citadel/domain.c @@ -168,7 +168,7 @@ int getmx(char *mxbuf, char *dest) { 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); } } diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 9942479c3..3a4478749 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -101,7 +101,7 @@ int network_talking_to(char *nodename, int operation) { 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); } diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 55d40e3d1..c60bcbf94 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -72,14 +72,15 @@ void terminate_idle_sessions(void) { } } 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; } } @@ -105,7 +106,7 @@ void check_ref_counts(void) { struct floor flbuf; int a; - lprintf(7, "Checking floor reference counts\n"); + lprintf(CTDL_DEBUG, "Checking floor reference counts\n"); for (a=0; a') 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; } diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 2dbb473f7..f1b977184 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -255,7 +255,7 @@ void imap_append(int num_parms, char *parms[]) { } /* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */ - lprintf(9, "Converting newline format\n"); + lprintf(CTDL_DEBUG, "Converting newline format\n"); for (i=0; itransmitted_message[i], "\r\n", 2)) { strcpy(&IMAP->transmitted_message[i], @@ -264,7 +264,7 @@ void imap_append(int num_parms, char *parms[]) { } } - 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; diff --git a/citadel/imap_search.c b/citadel/imap_search.c index 351d16f9d..894a96e95 100644 --- a/citadel/imap_search.c +++ b/citadel/imap_search.c @@ -389,7 +389,7 @@ void imap_do_search(int num_items, char **itemlist, int is_uid) { CtdlFreeMessage(msg); } else { - lprintf(1, "SEARCH internal error\n"); + lprintf(CTDL_ERR, "SEARCH internal error\n"); } } cprintf("\r\n"); diff --git a/citadel/imap_tools.c b/citadel/imap_tools.c index 4c86dcfe4..11b5e38a2 100644 --- a/citadel/imap_tools.c +++ b/citadel/imap_tools.c @@ -208,7 +208,7 @@ int imap_roomname(char *rbuf, int bufsize, char *foldername) } ***/ - lprintf(9, "(That translates to \"%s\")\n", rbuf); + lprintf(CTDL_DEBUG, "(That translates to \"%s\")\n", rbuf); return(ret); } diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 7ebb31915..e2940f9d9 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -333,7 +333,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { 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); @@ -357,7 +357,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { 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) { @@ -406,7 +406,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { 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; @@ -474,7 +474,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { 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; } @@ -552,7 +552,7 @@ void directory_key(char *key, char *addr) { } key[keylen++] = 0; - lprintf(9, "Directory key is <%s>\n", key); + lprintf(CTDL_DEBUG, "Directory key is <%s>\n", key); } @@ -568,14 +568,14 @@ int IsDirectory(char *addr) { 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); } } @@ -595,7 +595,7 @@ void CtdlDirectoryInit(void) { 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; diff --git a/citadel/locate_host.c b/citadel/locate_host.c index 31d65c9af..09aef6545 100644 --- a/citadel/locate_host.c +++ b/citadel/locate_host.c @@ -35,7 +35,7 @@ void locate_host(char *tbuf, size_t n, 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); @@ -83,7 +83,7 @@ bad_dns: #endif tbuf[63] = 0; - lprintf(9, "locate_host() exiting\n"); + lprintf(CTDL_DEBUG, "locate_host() exiting\n"); } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index f1c3f773c..b2f6f4228 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -175,14 +175,14 @@ int alias(char *name) 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\n", name); + lprintf(CTDL_INFO, "Changed to <%s>\n", name); } } } @@ -335,7 +335,7 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) { 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; iuser, &CC->room); } @@ -798,7 +798,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum) */ 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; } @@ -850,7 +850,7 @@ int is_valid_message(struct CtdlMessage *msg) { 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; @@ -890,7 +890,7 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp, 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; @@ -905,7 +905,7 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp, 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; @@ -924,14 +924,14 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp, 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; @@ -1047,7 +1047,7 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ 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; @@ -1127,7 +1127,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, 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); } @@ -1601,7 +1601,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { 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); @@ -1620,7 +1620,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { 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); } @@ -1628,7 +1628,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { 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); } } @@ -1637,7 +1637,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { 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); } @@ -1649,7 +1649,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { } 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); @@ -1675,7 +1675,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { (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; @@ -1745,7 +1745,7 @@ long send_message(struct CtdlMessage *msg, /* pointer to buffer */ /* 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; @@ -1790,7 +1790,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ 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; @@ -1807,7 +1807,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ 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; @@ -1822,7 +1822,7 @@ void check_repl(long msgnum, void *userdata) { 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) { @@ -1832,10 +1832,10 @@ void check_repl(long msgnum, void *userdata) { 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, ""); @@ -1854,11 +1854,11 @@ int ReplicationChecks(struct CtdlMessage *msg) { 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']); @@ -1878,7 +1878,7 @@ int ReplicationChecks(struct CtdlMessage *msg) { } CtdlFreeMessage(template); - lprintf(9, "ReplicationChecks() returning %d\n", abort_this); + lprintf(CTDL_DEBUG, "ReplicationChecks() returning %d\n", abort_this); return(abort_this); } @@ -1910,14 +1910,14 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); } @@ -1939,7 +1939,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* 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; acm_fields['P']); ++a) { @@ -1961,9 +1961,9 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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); } @@ -1997,7 +1997,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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) { @@ -2005,7 +2005,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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) { @@ -2019,7 +2019,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); } @@ -2032,15 +2032,15 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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); @@ -2048,7 +2048,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ * 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; @@ -2056,7 +2056,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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 @@ -2064,7 +2064,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ */ 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); } } @@ -2080,12 +2080,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (recps->num_room > 0) for (i=0; irecp_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); @@ -2097,7 +2097,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (recps->num_local > 0) for (i=0; irecp_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); @@ -2105,13 +2105,13 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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 @@ -2154,7 +2154,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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); @@ -2165,7 +2165,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ */ 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" @@ -2292,7 +2292,7 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ } 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); } } @@ -2504,7 +2504,7 @@ struct recptypes *validate_recipients(char *recipients) { if (num_recps > 0) for (i=0; i\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); @@ -2621,12 +2621,12 @@ struct recptypes *validate_recipients(char *recipients) { 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); } @@ -2802,12 +2802,12 @@ int CtdlDeleteMessages(char *room_name, /* which room */ 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 */ } @@ -2870,7 +2870,7 @@ int CtdlDeleteMessages(char *room_name, /* which room */ /* 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); } @@ -3028,7 +3028,7 @@ void PutMetaData(struct MetaData *smibuf) /* 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, @@ -3053,19 +3053,19 @@ void AdjRefCount(long msgnum, int incr) */ 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)); @@ -3104,19 +3104,19 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ 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); @@ -3161,7 +3161,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ 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; @@ -3185,7 +3185,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ * 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 */ diff --git a/citadel/room_ops.c b/citadel/room_ops.c index e4a66b7e9..2b80cabae 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -824,7 +824,7 @@ void usergoto(char *where, int display_result, int transiently, 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 ); @@ -934,7 +934,7 @@ void cmd_goto(char *gargs) ((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)); @@ -1101,7 +1101,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) { 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) { @@ -1192,11 +1192,11 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) { 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!" */ @@ -1450,7 +1450,7 @@ void delete_room(struct ctdlroom *qrbuf) 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"); @@ -1580,9 +1580,9 @@ unsigned create_room(char *new_room_name, 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 */ } @@ -1783,9 +1783,9 @@ void cmd_einf(char *ok) 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)); diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c index f8e2807e2..beca84454 100644 --- a/citadel/serv_calendar.c +++ b/citadel/serv_calendar.c @@ -52,7 +52,7 @@ icalcomponent *icalcomponent_new_citadel_vcalendar(void) { 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; } @@ -209,13 +209,13 @@ void ical_send_a_reply(icalcomponent *request, char *action) { 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; } @@ -618,13 +618,13 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { /* 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); } @@ -643,7 +643,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { 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 */ } @@ -670,7 +670,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { 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); } @@ -1158,7 +1158,7 @@ void ical_freebusy(char *who) { } /* 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", @@ -1168,7 +1168,7 @@ void ical_freebusy(char *who) { 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 ); @@ -1184,7 +1184,7 @@ void ical_freebusy(char *who) { */ /* 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); @@ -1195,11 +1195,11 @@ void ical_freebusy(char *who) { } /* 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. */ @@ -1294,7 +1294,7 @@ void ical_create_room(void) /* 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; @@ -1311,7 +1311,7 @@ void ical_create_room(void) /* 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; @@ -1346,7 +1346,7 @@ void ical_send_out_invitations(icalcomponent *cal) { 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; } @@ -1364,7 +1364,7 @@ void ical_send_out_invitations(icalcomponent *cal) { /* 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; } @@ -1400,7 +1400,7 @@ void ical_send_out_invitations(icalcomponent *cal) { } } - 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! @@ -1413,7 +1413,7 @@ void ical_send_out_invitations(icalcomponent *cal) { /* 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; @@ -1660,7 +1660,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg) } /* 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; } @@ -1737,7 +1737,7 @@ int ical_obj_aftersave(struct CtdlMessage *msg) } /* 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; } diff --git a/citadel/serv_crypto.c b/citadel/serv_crypto.c index fdfffc5a3..b8d278a5e 100644 --- a/citadel/serv_crypto.c +++ b/citadel/serv_crypto.c @@ -63,7 +63,7 @@ static int ctdl_install_certificate(SSL_CTX * ctx, 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); } @@ -71,14 +71,14 @@ static int ctdl_install_certificate(SSL_CTX * ctx, 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); } @@ -103,14 +103,14 @@ void init_ssl(void) 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 { @@ -119,7 +119,7 @@ void init_ssl(void) 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); @@ -135,12 +135,12 @@ void init_ssl(void) 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; @@ -158,21 +158,21 @@ void init_ssl(void) /* 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; @@ -191,13 +191,13 @@ void init_ssl(void) * 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) { @@ -212,7 +212,7 @@ void init_ssl(void) 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); } @@ -226,7 +226,7 @@ void init_ssl(void) * 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 @@ -279,7 +279,7 @@ void init_ssl(void) /* 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. */ @@ -299,7 +299,7 @@ void init_ssl(void) } else { - lprintf(3, "Unable to read private key.\n"); + lprintf(CTDL_CRIT, "Unable to read private key.\n"); } } @@ -309,7 +309,7 @@ void init_ssl(void) * 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. @@ -348,7 +348,7 @@ void init_ssl(void) /* 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. */ @@ -375,7 +375,7 @@ void init_ssl(void) 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())); } @@ -401,8 +401,7 @@ void client_write_ssl(char *buf, int nbytes) 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 = @@ -416,9 +415,9 @@ void client_write_ssl(char *buf, int nbytes) 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; @@ -464,8 +463,7 @@ int client_read_ssl(char *buf, int bytes, int timeout) #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); @@ -478,7 +476,7 @@ int client_read_ssl(char *buf, int bytes, int timeout) 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)); @@ -504,13 +502,13 @@ void CtdlStartTLS(char *ok_response, char *nosup_response, 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; @@ -528,7 +526,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response, 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; @@ -538,7 +536,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response, 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); @@ -598,7 +596,7 @@ void cmd_gtls(char *params) */ void endtls(void) { - lprintf(7, "Ending SSL/TLS\n"); + lprintf(CTDL_INFO, "Ending SSL/TLS\n"); if (!CC->ssl) { CC->redirect_ssl = 0; diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index f3de34e25..2c7249da4 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -216,12 +216,12 @@ void DoPurgeMessages(FILE *purgelist) { 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; } @@ -288,7 +288,7 @@ void DoPurgeRooms(struct ctdlroom *qrbuf, void *data) { 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 */ @@ -310,7 +310,7 @@ int PurgeRooms(void) { 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 @@ -347,7 +347,7 @@ int PurgeRooms(void) { 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); } @@ -365,7 +365,7 @@ void do_user_purge(struct ctdluser *us, void *data) { 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); */ @@ -422,7 +422,7 @@ int PurgeUsers(void) { 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); } @@ -444,7 +444,7 @@ int PurgeUsers(void) { 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); } @@ -559,7 +559,7 @@ int PurgeUseTable(void) { 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) { @@ -581,7 +581,7 @@ int PurgeUseTable(void) { } /* 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; @@ -589,7 +589,7 @@ int PurgeUseTable(void) { 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); } @@ -609,24 +609,24 @@ void purge_databases(void) { 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 */ } diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index 3ff6d2c28..7415203db 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -61,7 +61,7 @@ void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc) 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); } @@ -74,7 +74,7 @@ void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd) 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) { @@ -139,7 +139,7 @@ void CtdlRegisterLogHook(void (*fcn_ptr) (char *), int loglevel) newfcn->loglevel = loglevel; LogHookTable = newfcn; - lprintf(5, "Registered a new logging function\n"); + lprintf(CTDL_INFO, "Registered a new logging function\n"); } @@ -152,7 +152,7 @@ void CtdlUnregisterLogHook(void (*fcn_ptr) (char *), int loglevel) 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; @@ -175,7 +175,7 @@ void CtdlRegisterCleanupHook(void (*fcn_ptr) (void)) 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"); } @@ -187,7 +187,7 @@ void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void)) /* 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; @@ -211,7 +211,7 @@ void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType) 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); } @@ -225,7 +225,7 @@ void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int 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) { @@ -250,7 +250,7 @@ void CtdlRegisterUserHook(void (*fcn_ptr) (char *, long), int EventType) 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); } @@ -264,7 +264,7 @@ void CtdlUnregisterUserHook(void (*fcn_ptr) (char *, long), int 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) { @@ -290,7 +290,7 @@ void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *), 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); } @@ -305,7 +305,7 @@ void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *), 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) { @@ -328,7 +328,7 @@ void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ) newfcn->h_function_pointer = handler; NetprocHookTable = newfcn; - lprintf(5, "Registered a new netproc function\n"); + lprintf(CTDL_INFO, "Registered a new netproc function\n"); } @@ -340,7 +340,7 @@ void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ) /* 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; @@ -362,7 +362,7 @@ void CtdlRegisterDeleteHook(void (*handler)(char *, long) ) newfcn->h_function_pointer = handler; DeleteHookTable = newfcn; - lprintf(5, "Registered a new netproc function\n"); + lprintf(CTDL_INFO, "Registered a new netproc function\n"); } @@ -374,7 +374,7 @@ void CtdlUnregisterDeleteHook(void (*handler)(char *, long) ) /* 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; @@ -397,7 +397,7 @@ void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order) 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); } @@ -410,7 +410,7 @@ void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int 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) { @@ -444,7 +444,7 @@ void CtdlRegisterServiceHook(int tcp_port, 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; } @@ -456,11 +456,11 @@ void CtdlRegisterServiceHook(int tcp_port, 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); } } @@ -482,12 +482,12 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath, 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) { @@ -540,11 +540,11 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType) /* 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); } diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index 1a11cd705..58de3561e 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -170,7 +170,7 @@ void imap_load_msgids(void) { if (IMAP->selected == 0) { - lprintf(5, + lprintf(CTDL_ERR, "imap_load_msgids() can't run; no room selected\n"); return; } @@ -181,7 +181,7 @@ void imap_load_msgids(void) 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); } @@ -202,7 +202,7 @@ void imap_rescan_msgids(void) if (IMAP->selected == 0) { - lprintf(5, + lprintf(CTDL_ERR, "imap_load_msgids() can't run; no room selected\n"); return; } @@ -305,10 +305,10 @@ void imap_cleanup_function(void) 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"); } @@ -548,7 +548,7 @@ int imap_do_expunge(void) 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); @@ -558,10 +558,10 @@ int imap_do_expunge(void) 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]); } } @@ -774,7 +774,7 @@ void imap_create(int num_parms, char *parms[]) 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); @@ -1156,7 +1156,7 @@ void imap_rename(int num_parms, char *parms[]) 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; @@ -1183,12 +1183,12 @@ void imap_command_loop(void) 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, " "); diff --git a/citadel/serv_ldap.c b/citadel/serv_ldap.c index dca6b9c2f..c4ff284e1 100644 --- a/citadel/serv_ldap.c +++ b/citadel/serv_ldap.c @@ -57,7 +57,7 @@ void serv_ldap_cleanup(void) { if (!dirserver) return; - lprintf(7, "Unbinding from directory server\n"); + lprintf(CTDL_INFO, "Unbinding from directory server\n"); ldap_unbind(dirserver); dirserver = NULL; } @@ -101,13 +101,13 @@ void CtdlCreateLdapRoot(void) { 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); } } @@ -144,14 +144,14 @@ void CtdlCreateHostOU(char *host) { 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); } */ @@ -168,12 +168,12 @@ void CtdlConnectToLdap(void) { 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)); @@ -182,14 +182,14 @@ void CtdlConnectToLdap(void) { 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; } @@ -251,12 +251,12 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { /* 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; @@ -414,7 +414,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { ||(!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) { @@ -505,7 +505,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { 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); @@ -515,18 +515,18 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { 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\n", node); + lprintf(CTDL_ERR, "Invalid node name <%s>\n", node); return(-1); } @@ -429,10 +429,10 @@ void network_spool_msg(long msgnum, void *userdata) { /* * 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(); } @@ -533,13 +533,13 @@ void network_spool_msg(long msgnum, void *userdata) { /* 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'], @@ -641,10 +641,10 @@ void network_deliver_digest(struct SpoolControl *sc) { /* * 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(); } @@ -693,7 +693,7 @@ void network_spoolout_room(char *room_to_spool) { 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; } @@ -709,7 +709,7 @@ void network_spoolout_room(char *room_to_spool) { 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; @@ -801,7 +801,7 @@ void network_spoolout_room(char *room_to_spool) { /* 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 { @@ -873,7 +873,7 @@ int network_sync_to(char *target_node) { /* 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); } @@ -953,7 +953,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { static int serialnum = 0; size_t size; - lprintf(9, "entering network_bounce()\n"); + lprintf(CTDL_DEBUG, "entering network_bounce()\n"); if (msg == NULL) return; @@ -1038,7 +1038,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { /* Clean up */ if (valid != NULL) phree(valid); CtdlFreeMessage(msg); - lprintf(9, "leaving network_bounce()\n"); + lprintf(CTDL_DEBUG, "leaving network_bounce()\n"); } @@ -1068,7 +1068,7 @@ void network_process_buffer(char *buffer, long size) { 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; } @@ -1240,12 +1240,12 @@ void network_process_file(char *filename) { 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) { @@ -1340,7 +1340,7 @@ void receive_spool(int sock, char *remote_nodename) { 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; } @@ -1349,7 +1349,7 @@ void receive_spool(int sock, char *remote_nodename) { 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; } @@ -1390,7 +1390,7 @@ void receive_spool(int sock, char *remote_nodename) { 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); @@ -1412,7 +1412,7 @@ void transmit_spool(int sock, char *remote_nodename) 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; } @@ -1421,9 +1421,9 @@ void transmit_spool(int sock, char *remote_nodename) 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; @@ -1458,7 +1458,7 @@ ABORTUPL: 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); } @@ -1475,27 +1475,27 @@ void network_poll_node(char *node, char *secret, char *host, char *port) { 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. */ @@ -1606,10 +1606,10 @@ void network_do_queue(void) { * 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; @@ -1618,7 +1618,7 @@ void network_do_queue(void) { } } - 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 */ @@ -1630,7 +1630,7 @@ void network_do_queue(void) { 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); diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index 86ad7fc54..e04e60b92 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -75,7 +75,7 @@ void pop3_cleanup_function(void) { /* 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; inum_msgs; ++i) { if (POP3->msgs[i].temp != NULL) { @@ -85,7 +85,7 @@ void pop3_cleanup_function(void) { } if (POP3->msgs != NULL) phree(POP3->msgs); - lprintf(9, "Finished POP3 cleanup hook\n"); + lprintf(CTDL_DEBUG, "Finished POP3 cleanup hook\n"); } @@ -119,7 +119,7 @@ void pop3_user(char *argbuf) { 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); } @@ -135,7 +135,7 @@ void pop3_user(char *argbuf) { */ 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)); @@ -191,7 +191,7 @@ void pop3_login(void) 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"); @@ -263,7 +263,7 @@ void pop3_pass(char *argbuf) { 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(); } @@ -365,7 +365,7 @@ void pop3_retr(char *argbuf) { 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"); } @@ -568,11 +568,11 @@ void pop3_command_loop(void) { 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)) { diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index dfea49ab8..25e2e5d6c 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -152,7 +152,7 @@ void lmtp_greeting(void) { */ 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; } @@ -237,7 +237,7 @@ void smtp_get_user(char *argbuf) { 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); @@ -257,7 +257,7 @@ void smtp_get_pass(char *argbuf) { 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(); } @@ -633,7 +633,7 @@ void smtp_data(void) { 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 @@ -741,11 +741,11 @@ void smtp_command_loop(void) { 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) { @@ -855,7 +855,7 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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 */ @@ -920,7 +920,7 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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); @@ -930,10 +930,10 @@ void smtp_try(const char *key, const char *addr, int *status, sock = (-1); for (mx=0; (mx\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)); } @@ -948,7 +948,7 @@ void smtp_try(const char *key, const char *addr, int *status, 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; @@ -966,14 +966,14 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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; @@ -990,14 +990,14 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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; @@ -1014,14 +1014,14 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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; @@ -1037,14 +1037,14 @@ void smtp_try(const char *key, const char *addr, int *status, /* 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; @@ -1068,8 +1068,8 @@ void smtp_try(const char *key, const char *addr, int *status, 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]); } @@ -1079,7 +1079,7 @@ void smtp_try(const char *key, const char *addr, int *status, 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; @@ -1097,10 +1097,12 @@ void smtp_try(const char *key, const char *addr, int *status, 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); @@ -1132,7 +1134,7 @@ void smtp_do_bounce(char *instr) { 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'); @@ -1187,7 +1189,7 @@ void smtp_do_bounce(char *instr) { 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")) { @@ -1208,7 +1210,7 @@ void smtp_do_bounce(char *instr) { ++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__); } @@ -1226,13 +1228,13 @@ void smtp_do_bounce(char *instr) { } /* 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); } @@ -1257,7 +1259,7 @@ void smtp_do_bounce(char *instr) { } CtdlFreeMessage(bmsg); - lprintf(9, "Done processing bounces\n"); + lprintf(CTDL_DEBUG, "Done processing bounces\n"); } @@ -1331,11 +1333,11 @@ void smtp_do_procmsg(long msgnum, void *userdata) { 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; } @@ -1380,7 +1382,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { * 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; } @@ -1390,7 +1392,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { * 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; } @@ -1420,7 +1422,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { --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) { @@ -1510,16 +1512,16 @@ void smtp_do_queue(void) { /* * 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; } diff --git a/citadel/serv_spam.c b/citadel/serv_spam.c index 1bc8a775b..fd14ad0ac 100644 --- a/citadel/serv_spam.c +++ b/citadel/serv_spam.c @@ -118,9 +118,9 @@ int spam_assassin(struct CtdlMessage *msg) { /* Try them one by one until we get a working one */ for (sa=0; sa\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) { @@ -131,7 +131,7 @@ int spam_assassin(struct CtdlMessage *msg) { } /* 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)); @@ -146,18 +146,18 @@ int spam_assassin(struct CtdlMessage *msg) { 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; } diff --git a/citadel/serv_test.c b/citadel/serv_test.c index caf9af73b..3e05b9065 100644 --- a/citadel/serv_test.c +++ b/citadel/serv_test.c @@ -44,25 +44,25 @@ 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); } diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index 8a8c49213..47396e1b8 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -72,14 +72,14 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) { 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); } @@ -94,7 +94,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) { * 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; @@ -127,7 +127,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) { 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); } @@ -144,7 +144,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) { * 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; @@ -177,13 +177,14 @@ void update_config(void) { 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; @@ -192,7 +193,8 @@ void check_server_upgrades(void) { 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); } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 252a4f122..640fa5ef1 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -231,7 +231,7 @@ void artv_export_messages(void) { 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) { @@ -240,7 +240,7 @@ void artv_export_messages(void) { } } fclose(artv_global_message_list); - lprintf(7, "Exported %d messages.\n", count); + lprintf(CTDL_INFO, "Exported %d messages.\n", count); } @@ -314,9 +314,9 @@ void artv_do_export(void) { 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); @@ -331,7 +331,7 @@ void artv_import_config(void) { 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); @@ -355,7 +355,7 @@ void artv_import_config(void) { 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"); } @@ -363,14 +363,14 @@ void artv_import_config(void) { 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"); } @@ -418,7 +418,7 @@ void artv_import_room(void) { 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. */ @@ -426,7 +426,7 @@ void artv_import_room(void) { CtdlSaveMsgPointerInRoom(qrbuf.QRname, msgnum, 0); ++msgcount; } - lprintf(7, "(%d messages)\n", msgcount); + lprintf(CTDL_INFO, "(%d messages)\n", msgcount); } @@ -442,7 +442,7 @@ void artv_import_floor(void) { 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); } @@ -467,7 +467,7 @@ void artv_import_visit(void) { 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); } @@ -488,7 +488,7 @@ void artv_import_message(void) { 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)); @@ -502,7 +502,7 @@ void artv_import_message(void) { 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"); @@ -515,7 +515,7 @@ void artv_import_message(void) { unlink(tempfile); PutMetaData(&smi); - lprintf(7, "Imported message %ld\n", msgnum); + lprintf(CTDL_INFO, "Imported message %ld\n", msgnum); } @@ -529,13 +529,13 @@ void artv_do_import(void) { 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 ((versionREV_LEVEL)) { - lprintf(7, "Version mismatch - aborting\n"); + lprintf(CTDL_ERR, "Version mismatch in ARTV import; aborting\n"); break; } } @@ -549,7 +549,7 @@ void artv_do_import(void) { 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")) ;; } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index c1c30c670..800dfcabb 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -146,18 +146,19 @@ void vcard_directory_add_user(char *internet_addr, char *citadel_addr) { * 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); } @@ -778,7 +779,7 @@ void vcard_create_room(void) /* 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; diff --git a/citadel/server_main.c b/citadel/server_main.c index 9d06152f5..0b8fa20e9 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) /* any other parameter makes it crash and burn */ else { - lprintf(1, "citserver: usage: " + lprintf(CTDL_EMERG, "citserver: usage: " "citserver [-tTraceFile] " "[-lLogFacility] " "[-d] [-f]" @@ -138,18 +138,20 @@ int main(int argc, char **argv) } /* 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(); @@ -181,7 +183,7 @@ int main(int argc, char **argv) /* * 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(); @@ -192,7 +194,7 @@ int main(int argc, char **argv) * 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); } @@ -204,18 +206,18 @@ int main(int argc, char **argv) */ 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)); } } @@ -225,7 +227,7 @@ int main(int argc, char **argv) /* * 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(); @@ -237,7 +239,7 @@ int main(int argc, char **argv) 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) { @@ -247,7 +249,7 @@ int main(int argc, char **argv) /* 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); } diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 1bc35fae2..7ebdec079 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -37,8 +37,9 @@ /* * 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 diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 04ad3c325..061b9fee7 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -101,7 +101,7 @@ int syslog_facility = (-1); * 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]; @@ -117,7 +117,7 @@ void lprintf(int loglevel, const char *format, ...) { snprintf(buf, 6, "[%3d]", CC->cs_pid); buf[5] = ' '; } - syslog(LOG_NOTICE, buf); + syslog(loglevel, buf); } } else if (loglevel <= verbosity) { @@ -163,7 +163,7 @@ void *tracked_malloc(size_t tsize, char *tfile, int tline) { 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); } @@ -277,7 +277,7 @@ void init_sysdep(void) { * 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)); } /* @@ -303,7 +303,7 @@ void init_sysdep(void) { */ 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(); @@ -315,7 +315,7 @@ void begin_critical_section(int which_one) */ 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]); } @@ -343,7 +343,7 @@ int ig_tcp_server(int port_number, int queue_len) 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); } @@ -352,14 +352,14 @@ int ig_tcp_server(int port_number, int queue_len) 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); } @@ -384,7 +384,7 @@ int ig_uds_server(char *sockpath, int queue_len) 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); } @@ -395,19 +395,19 @@ int ig_uds_server(char *sockpath, int queue_len) 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); } @@ -444,7 +444,7 @@ struct CitContext *CreateNewContext(void) { 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)); @@ -568,7 +568,7 @@ void client_write(char *buf, int nbytes) 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; @@ -631,7 +631,7 @@ int client_read_to(char *buf, int bytes, int timeout) 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); @@ -699,11 +699,11 @@ void sysdep_master_cleanup(void) { 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); @@ -788,13 +788,13 @@ void create_worker(void) { 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; } @@ -802,7 +802,7 @@ void create_worker(void) { /* 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; } @@ -810,7 +810,7 @@ void create_worker(void) { 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)); } @@ -851,7 +851,7 @@ void dead_session_purge(void) { * 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); } @@ -942,25 +942,25 @@ void init_master_fdset(void) { 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); } @@ -1041,7 +1041,7 @@ SETUP_FD: memcpy(&readfds, &masterfds, sizeof masterfds); */ 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; @@ -1056,11 +1056,12 @@ SETUP_FD: memcpy(&readfds, &masterfds, sizeof masterfds); 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); diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index 37ee0769f..a83c14816 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -4,11 +4,31 @@ #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 @@ -50,6 +70,5 @@ extern struct worker_node { struct worker_node *next; } *worker_list; - extern int SyslogFacility(char *name); extern int syslog_facility; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 7da967bc5..78e2c46cd 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -436,7 +436,7 @@ void session_startup(void) { 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); @@ -549,13 +549,13 @@ static int validpw(uid_t uid, const char *pass) 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]); @@ -583,7 +583,7 @@ static int validpw(uid_t uid, const char *pass) 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; @@ -607,19 +607,19 @@ int CtdlTryPassword(char *password) 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); @@ -656,7 +656,7 @@ int CtdlTryPassword(char *password) 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; } } @@ -705,7 +705,7 @@ int purge_user(char pname[]) 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 @@ -721,12 +721,12 @@ int purge_user(char pname[]) } 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); @@ -841,7 +841,7 @@ int create_user(char *newusername, int become_user) } } - lprintf(3, "New user <%s> created\n", username); + lprintf(CTDL_NOTICE, "New user <%s> created\n", username); return (0); } @@ -928,7 +928,7 @@ void cmd_setp(char *new_pw) 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); }