Removed the logging facility from citserver, use syslog instead
authorArt Cancro <ajc@citadel.org>
Mon, 17 Jan 2011 17:39:59 +0000 (12:39 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Jan 2011 17:39:59 +0000 (12:39 -0500)
67 files changed:
citadel/citadel.h
citadel/citserver.c
citadel/clientsocket.c
citadel/context.c
citadel/context.h
citadel/control.c
citadel/database.c
citadel/docs/citadel.html
citadel/domain.c
citadel/ecrash.c
citadel/euidindex.c
citadel/file_ops.c
citadel/housekeeping.c
citadel/ical_dezonify.c
citadel/include/ctdl_module.h
citadel/internet_addressing.c
citadel/ldap.c
citadel/locate_host.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/checkpoint/serv_checkpoint.c
citadel/modules/clamav/serv_virus.c
citadel/modules/crypto/serv_crypto.c
citadel/modules/dspam/serv_dspam.c
citadel/modules/expire/serv_expire.c
citadel/modules/extnotify/extnotify_main.c
citadel/modules/extnotify/funambol65.c
citadel/modules/fulltext/ft_wordbreaker.c
citadel/modules/fulltext/serv_fulltext.c
citadel/modules/imap/imap_fetch.c
citadel/modules/imap/imap_list.c
citadel/modules/imap/imap_misc.c
citadel/modules/imap/imap_tools.c
citadel/modules/imap/serv_imap.c
citadel/modules/listsub/serv_listsub.c
citadel/modules/managesieve/serv_managesieve.c
citadel/modules/migrate/serv_migrate.c
citadel/modules/network/serv_network.c
citadel/modules/notes/serv_notes.c
citadel/modules/openid/serv_openid_rp.c
citadel/modules/pop3/serv_pop3.c
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/sieve/serv_sieve.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/smtp/serv_smtpclient.c
citadel/modules/spam/serv_spam.c
citadel/modules/test/serv_test.c
citadel/modules/upgrade/serv_upgrade.c
citadel/modules/vcard/serv_vcard.c
citadel/modules/wiki/serv_wiki.c
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/xmpp_presence.c
citadel/modules/xmpp/xmpp_query_namespace.c
citadel/modules/xmpp/xmpp_queue.c
citadel/msgbase.c
citadel/parsedate.c
citadel/room_ops.c
citadel/scripts/mk_module_init.sh
citadel/serv_extensions.c
citadel/server_main.c
citadel/sysdep.c
citadel/sysdep_decls.h
citadel/textclient/citadel.c
citadel/threads.c
citadel/user_ops.c
citadel/user_ops.h
webcit/webserver.c

index 24e3054c5898baf617374ee785877ebf1ea74b3b..4dd39a6499ec91becb727d9903b0e6dd9815ead5 100644 (file)
@@ -279,7 +279,7 @@ enum {
 #define SIEVECONFIG    "application/x-citadel-sieve-config"
 #define XMPPMORTUARY   "application/x-citadel-xmpp-mortuary"
 
-#define TRACE  CtdlLogPrintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
+#define TRACE  syslog(LOG_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
 
 #ifndef LONG_MAX
 #define LONG_MAX 2147483647L
index 93a02389fb06d367c75308e1e59fb72294e9a583..a8be1253fdc8a2dc0b7162b6dcf36fcab44364be 100644 (file)
@@ -1,9 +1,9 @@
 /* 
  * Main source module for the Citadel server
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -98,9 +98,9 @@ void cit_backtrace(void)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(1, "%s\n", strings[i]);
+                       syslog(LOG_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -121,9 +121,9 @@ void cit_panic_backtrace(int SigNum)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(1, "%s\n", strings[i]);
+                       syslog(LOG_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -140,10 +140,10 @@ void master_startup(void) {
        struct ctdlroom qrbuf;
        int rv;
        
-       CtdlLogPrintf(CTDL_DEBUG, "master_startup() started\n");
+       syslog(LOG_DEBUG, "master_startup() started\n");
        time(&server_startup_time);
 
-       CtdlLogPrintf(CTDL_INFO, "Opening databases\n");
+       syslog(LOG_INFO, "Opening databases\n");
        open_databases();
 
        ctdl_thread_internal_init_tsd();
@@ -152,7 +152,7 @@ void master_startup(void) {
        
        check_ref_counts();
 
-       CtdlLogPrintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
+       syslog(LOG_INFO, "Creating base rooms (if necessary)\n");
        CtdlCreateRoom(config.c_baseroom,       0, "", 0, 1, 0, VIEW_BBS);
        CtdlCreateRoom(AIDEROOM,                3, "", 0, 1, 0, VIEW_BBS);
        CtdlCreateRoom(SYSCONFIGROOM,           3, "", 0, 1, 0, VIEW_BBS);
@@ -170,7 +170,7 @@ void master_startup(void) {
                 CtdlPutRoomLock(&qrbuf);
         }
 
-       CtdlLogPrintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
+       syslog(LOG_INFO, "Seeding the pseudo-random number generator...\n");
        urandom = fopen("/dev/urandom", "r");
        if (urandom != NULL) {
                rv = fread(&seed, sizeof seed, 1, urandom);
@@ -183,12 +183,12 @@ void master_startup(void) {
        srand(seed);
        srandom(seed);
 
-       CtdlLogPrintf(CTDL_INFO, "Initializing ipgm secret\n");
+       syslog(LOG_INFO, "Initializing ipgm secret\n");
        get_config();
        config.c_ipgm_secret = rand();
        put_config();
 
-       CtdlLogPrintf(CTDL_DEBUG, "master_startup() finished\n");
+       syslog(LOG_DEBUG, "master_startup() finished\n");
 }
 
 
@@ -214,7 +214,7 @@ void master_cleanup(int exitcode) {
        sysdep_master_cleanup();
        
        /* Close databases */
-       CtdlLogPrintf(CTDL_INFO, "Closing databases\n");
+       syslog(LOG_INFO, "Closing databases\n");
        close_databases();
 
 #ifdef DEBUG_MEMORY_LEAKS
@@ -223,7 +223,7 @@ void master_cleanup(int exitcode) {
 
        /* If the operator requested a halt but not an exit, halt here. */
        if (shutdown_and_halt) {
-               CtdlLogPrintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
+               syslog(LOG_NOTICE, "citserver: Halting server without exiting.\n");
                fflush(stdout); fflush(stderr);
                while(1) {
                        sleep(32767);
@@ -233,7 +233,7 @@ void master_cleanup(int exitcode) {
        release_control();
 
        /* Now go away. */
-       CtdlLogPrintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
+       syslog(LOG_NOTICE, "citserver: Exiting with status %d\n", exitcode);
        fflush(stdout); fflush(stderr);
        
        if (restart_server != 0)
@@ -364,14 +364,14 @@ int is_public_client(void)
         */
        if (stat(public_clients_file, &statbuf) != 0) {
                /* No public_clients file exists, so bail out */
-               CtdlLogPrintf(CTDL_WARNING, "Warning: '%s' does not exist\n", 
+               syslog(LOG_WARNING, "Warning: '%s' does not exist\n", 
                                public_clients_file);
                return(0);
        }
 
        if (statbuf.st_mtime > pc_timestamp) {
                begin_critical_section(S_PUBLIC_CLIENTS);
-               CtdlLogPrintf(CTDL_INFO, "Loading %s\n", public_clients_file);
+               syslog(LOG_INFO, "Loading %s\n", public_clients_file);
 
                public_clientspos = &public_clients[0];
                public_clientsend = public_clientspos + SIZ;
@@ -417,18 +417,18 @@ int is_public_client(void)
                end_critical_section(S_PUBLIC_CLIENTS);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
+       syslog(LOG_DEBUG, "Checking whether %s is a local or public client\n",
                CC->cs_addr);
        for (i=0; i<num_parms(public_clients); ++i) {
                extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
                if (!strcasecmp(CC->cs_addr, addrbuf)) {
-                       CtdlLogPrintf(CTDL_DEBUG, "... yes it is.\n");
+                       syslog(LOG_DEBUG, "... yes it is.\n");
                        return(1);
                }
        }
 
        /* No hits.  This is not a public client. */
-       CtdlLogPrintf(CTDL_DEBUG, "... no it isn't.\n");
+       syslog(LOG_DEBUG, "... no it isn't.\n");
        return(0);
 }
 
@@ -471,7 +471,7 @@ void cmd_iden(char *argbuf)
                CC->cs_addr[0] = 0;
        }
 
-       CtdlLogPrintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
+       syslog(LOG_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
                dev_code,
                cli_code,
                (rev_level / 100),
@@ -763,7 +763,7 @@ void cmd_ipgm(char *argbuf)
        else {
                sleep(5);
                cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED);
-               CtdlLogPrintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
+               syslog(LOG_ERR, "Warning: ipgm authentication failed.\n");
                CC->kill_me = 1;
        }
 }
@@ -788,7 +788,7 @@ void cmd_down(char *argbuf) {
                }
                if ((restart_server > 0) && !running_as_daemon)
                {
-                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as daemon! Geronimooooooo!\n");
+                       syslog(LOG_ERR, "The user requested restart, but not running as daemon! Geronimooooooo!\n");
                        Reply = "%d Warning: citserver is not running in daemon mode and is therefore unlikely to restart automatically.\n";
                        state = ERROR;
                }
@@ -833,7 +833,7 @@ void cmd_scdn(char *argbuf)
                restart_server = 1;
                if (!running_as_daemon)
                {
-                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
+                       syslog(LOG_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
                        Reply = "%d %d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
                        state = ERROR;
                }
@@ -929,7 +929,7 @@ void begin_session(CitContext *con)
                        
                        /*fill in the user data structure */
                        if(getsockopt(con->client_socket, SOL_SOCKET, SO_PEERCRED, &credentials, &ucred_length)) {
-                               CtdlLogPrintf(CTDL_NOTICE, "could obtain credentials from unix domain socket");
+                               syslog(LOG_NOTICE, "could obtain credentials from unix domain socket");
                                
                        }
                        else {          
@@ -965,10 +965,10 @@ void begin_session(CitContext *con)
        }
 
        if (!CC->is_local_socket) {
-               CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started from %s (%s).\n", con->ServiceName, con->cs_host, con->cs_addr);
+               syslog(LOG_NOTICE, "Session (%s) started from %s (%s).\n", con->ServiceName, con->cs_host, con->cs_addr);
        }
        else {
-               CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started via local socket UID:%d.\n", con->ServiceName, con->cs_UDSclientUID);
+               syslog(LOG_NOTICE, "Session (%s) started via local socket UID:%d.\n", con->ServiceName, con->cs_UDSclientUID);
        }
 
        /* Run any session startup routines registered by loadable modules */
@@ -1030,7 +1030,7 @@ void do_command_loop(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                CtdlThreadName(old_name);
                return;
@@ -1038,10 +1038,10 @@ void do_command_loop(void) {
 
        /* Log the server command, but don't show passwords... */
        if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) {
-               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
+               syslog(LOG_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
+               syslog(LOG_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
        }
 
        buffer_output();
index 594b5eb9664d969e8f8b2988e66a2909b9e99439..f8a25f3e4fcb99b686e53cd00552c2c615f1dcbe 100644 (file)
@@ -4,7 +4,7 @@
  * sockets for the Citadel client; for that you must look in ipc_c_tcp.c
  * (which, uncoincidentally, bears a striking similarity to this file).
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
 #include <pwd.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -85,7 +86,7 @@ int sock_connect(char *host, char *service)
 
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
-               CtdlLogPrintf(CTDL_ERR, "%s: %s\n", host, gai_strerror(rc));
+               syslog(LOG_ERR, "%s: %s\n", host, gai_strerror(rc));
                return(-1);
        }
 
@@ -95,7 +96,7 @@ int sock_connect(char *host, char *service)
        for (ai = res; ai != NULL; ai = ai->ai_next) {
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
-                       CtdlLogPrintf(CTDL_ERR, "socket() failed: %s\n", strerror(errno));
+                       syslog(LOG_ERR, "socket() failed: %s\n", strerror(errno));
                        freeaddrinfo(res);
                        return(-1);
                }
@@ -105,7 +106,7 @@ int sock_connect(char *host, char *service)
                        return(sock);
                }
                else {
-                       CtdlLogPrintf(CTDL_ERR, "connect() failed: %s\n", strerror(errno));
+                       syslog(LOG_ERR, "connect() failed: %s\n", strerror(errno));
                        close(sock);
                }
        }
@@ -140,7 +141,7 @@ int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout)
                                        &CCC->sPos,
                                        Socket, 1, bytes, O_TERM, &Error);
        if (retval < 0) {
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                              "%s failed: %s\n", __FUNCTION__, Error);
        }
        return retval;
@@ -159,7 +160,7 @@ int CtdlSockGetLine(int *sock, StrBuf * Target, int nSec)
                                               &CCC->sPos,
                                               sock, nSec, 1, &Error);
        if ((rc < 0) && (Error != NULL))
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                              "%s failed: %s\n", __FUNCTION__, Error);
        return rc;
 }
index 5d29ce6f6d2e6fa60469c3d81a34871d61e08680..84244401d41dd55401c967ec7444b576edb689ae 100644 (file)
@@ -159,7 +159,7 @@ int CtdlTerminateOtherSession (int session_num)
                return TERM_NOTALLOWED;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Locating session to kill\n");
+       syslog(LOG_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) {
@@ -301,9 +301,9 @@ void terminate_idle_sessions(void)
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
-               CtdlLogPrintf(CTDL_INFO, "Terminated %d idle sessions\n", killed);
+               syslog(LOG_INFO, "Terminated %d idle sessions\n", killed);
        if (longrunners > 0)
-               CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
+               syslog(LOG_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
 }
 
 void terminate_stuck_sessions(void)
@@ -322,7 +322,7 @@ void terminate_stuck_sessions(void)
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
-               CtdlLogPrintf(CTDL_INFO, "Flushed %d stuck sessions\n", killed);
+               syslog(LOG_INFO, "Flushed %d stuck sessions\n", killed);
 }
 
 
@@ -333,11 +333,11 @@ void terminate_stuck_sessions(void)
 void RemoveContext (CitContext *con)
 {
        if (con==NULL) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "WARNING: RemoveContext() called with NULL!\n");
                return;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
+       syslog(LOG_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
 
        /* Run any cleanup routines registered by loadable modules.
         * Note: We have to "become_session()" because the cleanup functions
@@ -348,10 +348,10 @@ void RemoveContext (CitContext *con)
        PerformSessionHooks(EVT_STOP);
        become_session(NULL);
 
-       CtdlLogPrintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
+       syslog(LOG_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
 
        /* If the client is still connected, blow 'em away. */
-       CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
+       syslog(LOG_DEBUG, "Closing socket %d\n", con->client_socket);
        close(con->client_socket);
 
        /* If using AUTHMODE_LDAP, free the DN */
@@ -362,7 +362,7 @@ void RemoveContext (CitContext *con)
 
        FreeStrBuf(&con->MigrateBuf);
        FreeStrBuf(&con->ReadBuf);
-       CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
+       syslog(LOG_DEBUG, "Done with RemoveContext()\n");
 }
 
 
@@ -380,7 +380,7 @@ CitContext *CreateNewContext(void) {
 
        me = (CitContext *) malloc(sizeof(CitContext));
        if (me == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "citserver: can't allocate memory!!\n");
+               syslog(LOG_ALERT, "citserver: can't allocate memory!!\n");
                return NULL;
        }
        memset(me, 0, sizeof(CitContext));
@@ -468,7 +468,7 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        if (context->user.usernum == 0)
        {       /* old system user with number 0, upgrade it */
                context->user.usernum = get_new_user_number();
-               CtdlLogPrintf(CTDL_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %ld\n", context->user.fullname, context->user.usernum);
+               syslog(LOG_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %ld\n", context->user.fullname, context->user.usernum);
                /* add user to the database */
                CtdlPutUser(&(context->user));
                cdb_store(CDB_USERSBYNUMBER, &(context->user.usernum), sizeof(long), context->user.fullname, strlen(context->user.fullname)+1);
@@ -512,7 +512,7 @@ void context_cleanup(void)
                rem = ptr->next;
                --num_sessions;
                
-               CtdlLogPrintf(CTDL_DEBUG, "Purging session %d\n", ptr->cs_pid);
+               syslog(LOG_DEBUG, "Purging session %d\n", ptr->cs_pid);
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;
@@ -589,7 +589,7 @@ void dead_session_purge(int force) {
         * is allocated privately on this thread's stack.
         */
        while (rem != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Purging session %d\n", rem->cs_pid);
+               syslog(LOG_DEBUG, "Purging session %d\n", rem->cs_pid);
                RemoveContext(rem);
                ptr = rem;
                rem = rem->next;
@@ -620,7 +620,7 @@ void InitializeMasterCC(void) {
  */
 void set_async_waiting(struct CitContext *ccptr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid);
+       syslog(LOG_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid);
        if (ccptr->is_async) {
                ccptr->async_waiting++;
                if (ccptr->state == CON_IDLE) {
index 3b05a2b0d8a7dd1659cdea2eeae93685f0208669..29ab30e3636afc668127a6eee0a3f77b256a63a2 100644 (file)
@@ -181,7 +181,7 @@ static INLINE void become_session(CitContext *which_con) {
 */
        citthread_setspecific(MyConKey, (void *)which_con );
 /*
-       CtdlLogPrintf(CTDL_DEBUG, "[%d]: Now doing %s\n", 
+       syslog(LOG_DEBUG, "[%d]: Now doing %s\n", 
                      (int) tid, 
                      ((which_con != NULL) && (which_con->ServiceName != NULL)) ? 
                      which_con->ServiceName:"");
index 1779633faff7bd13976d23803509977498ecdc58..242cac8163cf97c247c5ebeff6e3b2d14bbd4967 100644 (file)
@@ -77,8 +77,8 @@ void lock_control(void)
 {
 #if defined(LOCK_EX) && defined(LOCK_NB)
        if (flock(fileno(control_fp), (LOCK_EX | LOCK_NB))) {
-               CtdlLogPrintf(CTDL_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
-               CtdlLogPrintf(CTDL_EMERG, "Is another citserver already running?\n");
+               syslog(LOG_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
+               syslog(LOG_EMERG, "Is another citserver already running?\n");
                exit(CTDLEXIT_CONTROL);
        }
 #endif
@@ -127,9 +127,9 @@ void control_find_highest(struct ctdlroom *qrbuf, void *data)
        }
        cdb_free(cdbfr);
        if (room_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed room counter\n");
+               syslog(LOG_INFO, "Control record checking....Fixed room counter\n");
        if (message_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed message count\n");
+               syslog(LOG_INFO, "Control record checking....Fixed message count\n");
        return;
 }
 
@@ -148,7 +148,7 @@ void control_find_user (struct ctdluser *EachUser, void *out_data)
                user_fixed = 1;
        }
        if(user_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed user count\n");
+               syslog(LOG_INFO, "Control record checking....Fixed user count\n");
 }
 
 
@@ -191,7 +191,7 @@ void get_control(void)
                }
        }
        if (control_fp == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR opening %s: %s\n", file_citadel_control, strerror(errno));
+               syslog(LOG_ALERT, "ERROR opening %s: %s\n", file_citadel_control, strerror(errno));
                return;
        }
 
@@ -222,7 +222,7 @@ void put_control(void)
  */
 void check_control(void)
 {
-       CtdlLogPrintf(CTDL_INFO, "Checking/re-building control record\n");
+       syslog(LOG_INFO, "Checking/re-building control record\n");
        get_control();
        // Find highest room number and message number.
        CtdlForEachRoom(control_find_highest, NULL);
index 95c69476e7e4be641a13ca4c3696f27e82845f5f..d0aab07300d56305ba0c4203c74445b03c1317ad 100644 (file)
@@ -1,21 +1,21 @@
 /*
  * This is a data store backend for the Citadel server which uses Berkeley DB.
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  */
 
@@ -42,6 +42,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <syslog.h>
 
 #ifdef HAVE_DB_H
 #include <db.h>
@@ -84,7 +85,7 @@ static DB_ENV *dbenv;         /* The DB environment (global) */
 void cdb_verbose_log(const DB_ENV *dbenv, const char *msg)
 {
        if (!IsEmptyStr(msg)) {
-               CtdlLogPrintf(CTDL_DEBUG, "DB: %s\n", msg);
+               syslog(LOG_DEBUG, "DB: %s\n", msg);
        }
 }
 
@@ -92,7 +93,7 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg)
 /* Verbose logging callback */
 void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg)
 {
-       CtdlLogPrintf(CTDL_ALERT, "DB: %s\n", msg);
+       syslog(LOG_ALERT, "DB: %s\n", msg);
 }
 
 
@@ -104,7 +105,7 @@ static void txabort(DB_TXN * tid)
        ret = tid->abort(tid);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_abort: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_abort: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -117,7 +118,7 @@ static void txcommit(DB_TXN * tid)
        ret = tid->commit(tid, 0);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_commit: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_commit: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -130,14 +131,14 @@ static void txbegin(DB_TXN ** tid)
        ret = dbenv->txn_begin(dbenv, NULL, tid, 0);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_begin: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_begin: %s\n", db_strerror(ret));
                abort();
        }
 }
 
 static void dbpanic(DB_ENV * env, int errval)
 {
-       CtdlLogPrintf(CTDL_EMERG, "bdb(): PANIC: %s\n", db_strerror(errval));
+       syslog(LOG_EMERG, "bdb(): PANIC: %s\n", db_strerror(errval));
 }
 
 static void cclose(DBC * cursor)
@@ -145,7 +146,7 @@ static void cclose(DBC * cursor)
        int ret;
 
        if ((ret = cursor->c_close(cursor))) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): c_close: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): c_close: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -156,7 +157,7 @@ static void bailIfCursor(DBC ** cursors, const char *msg)
 
        for (i = 0; i < MAXCDB; i++)
                if (cursors[i] != NULL) {
-                       CtdlLogPrintf(CTDL_EMERG,
+                       syslog(LOG_EMERG,
                                "bdb(): cursor still in progress on cdb %02x: %s\n", i, msg);
                        abort();
                }
@@ -170,7 +171,7 @@ void check_handles(void *arg)
                bailIfCursor(tsd->cursors, "in check_handles");
 
                if (tsd->tid != NULL) {
-                       CtdlLogPrintf(CTDL_EMERG, "bdb(): transaction still in progress!");
+                       syslog(LOG_EMERG, "bdb(): transaction still in progress!");
                        abort();
                }
        }
@@ -196,14 +197,14 @@ static void cdb_cull_logs(void)
 
        /* Get the list of names. */
        if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "cdb_cull_logs: %s\n", db_strerror(ret));
+               syslog(LOG_ERR, "cdb_cull_logs: %s\n", db_strerror(ret));
                return;
        }
 
        /* Print the list of names. */
        if (list != NULL) {
                for (file = list; *file != NULL; ++file) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Deleting log: %s\n", *file);
+                       syslog(LOG_DEBUG, "Deleting log: %s\n", *file);
                        ret = unlink(*file);
                        if (ret != 0) {
                                snprintf(errmsg, sizeof(errmsg),
@@ -238,11 +239,11 @@ void cdb_checkpoint(void)
 {
        int ret;
 
-       CtdlLogPrintf(CTDL_DEBUG, "-- db checkpoint --\n");
+       syslog(LOG_DEBUG, "-- db checkpoint --\n");
        ret = dbenv->txn_checkpoint(dbenv, MAX_CHECKPOINT_KBYTES, MAX_CHECKPOINT_MINUTES, 0);
 
        if (ret != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret));
                abort();
        }
 
@@ -269,19 +270,19 @@ void open_databases(void)
        int dbversion_major, dbversion_minor, dbversion_patch;
        int current_dbversion = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "bdb(): open_databases() starting\n");
-       CtdlLogPrintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
-       CtdlLogPrintf(CTDL_INFO, "  Linked db: %s\n",
+       syslog(LOG_DEBUG, "bdb(): open_databases() starting\n");
+       syslog(LOG_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
+       syslog(LOG_INFO, "  Linked db: %s\n",
                db_version(&dbversion_major, &dbversion_minor, &dbversion_patch));
 
        current_dbversion = (dbversion_major * 1000000) + (dbversion_minor * 1000) + dbversion_patch;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Calculated dbversion: %d\n", current_dbversion);
-       CtdlLogPrintf(CTDL_DEBUG, "  Previous dbversion: %d\n", CitControl.MMdbversion);
+       syslog(LOG_DEBUG, "Calculated dbversion: %d\n", current_dbversion);
+       syslog(LOG_DEBUG, "  Previous dbversion: %d\n", CitControl.MMdbversion);
 
        if ( (getenv("SUPPRESS_DBVERSION_CHECK") == NULL)
           && (CitControl.MMdbversion > current_dbversion) ) {
-               CtdlLogPrintf(CTDL_EMERG, "You are attempting to run the Citadel server using a version\n"
+               syslog(LOG_EMERG, "You are attempting to run the Citadel server using a version\n"
                                        "of Berkeley DB that is older than that which last created or\n"
                                        "updated the database.  Because this would probably cause data\n"
                                        "corruption or loss, the server is aborting execution now.\n");
@@ -292,7 +293,7 @@ void open_databases(void)
        put_control();
 
 #ifdef HAVE_ZLIB
-       CtdlLogPrintf(CTDL_INFO, "Linked zlib: %s\n", zlibVersion());
+       syslog(LOG_INFO, "Linked zlib: %s\n", zlibVersion());
 #endif
 
        /*
@@ -300,26 +301,26 @@ void open_databases(void)
         * already there, no problem.
         */
        if ((mkdir(ctdl_data_dir, 0700) != 0) && (errno != EEXIST)){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to create database directory [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
        if (chmod(ctdl_data_dir, 0700) != 0){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to set database directory accessrights [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
        if (chown(ctdl_data_dir, CTDLUID, (-1)) != 0){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to set the owner for [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
-       CtdlLogPrintf(CTDL_DEBUG, "bdb(): Setting up DB environment\n");
+       syslog(LOG_DEBUG, "bdb(): Setting up DB environment\n");
        db_env_set_func_yield((int (*)(u_long,  u_long))sched_yield);
        ret = db_env_create(&dbenv, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): db_env_create: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "bdb(): db_env_create: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
        dbenv->set_errpfx(dbenv, "citserver");
@@ -338,51 +339,51 @@ void open_databases(void)
         */
        ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): set_cachesize: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): set_cachesize: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        if ((ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT))) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): set_lk_detect: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): set_lk_detect: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        flags = DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_INIT_TXN | DB_INIT_LOCK | DB_THREAD | DB_RECOVER;
-       CtdlLogPrintf(CTDL_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", ctdl_data_dir, flags);
+       syslog(LOG_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", ctdl_data_dir, flags);
        ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        if (ret == DB_RUNRECOVERY) {
-               CtdlLogPrintf(CTDL_ALERT, "dbenv->open: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_ALERT, "Attempting recovery...\n");
+               syslog(LOG_ALERT, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_ALERT, "Attempting recovery...\n");
                flags |= DB_RECOVER;
                ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        }
        if (ret == DB_RUNRECOVERY) {
-               CtdlLogPrintf(CTDL_ALERT, "dbenv->open: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_ALERT, "Attempting catastrophic recovery...\n");
+               syslog(LOG_ALERT, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_ALERT, "Attempting catastrophic recovery...\n");
                flags &= ~DB_RECOVER;
                flags |= DB_RECOVER_FATAL;
                ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        }
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "dbenv->open: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Starting up DB\n");
+       syslog(LOG_INFO, "Starting up DB\n");
 
        for (i = 0; i < MAXCDB; ++i) {
 
                /* Create a database handle */
                ret = db_create(&dbp[i], dbenv, 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_create: %s\n", db_strerror(ret));
-                       CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+                       syslog(LOG_EMERG, "db_create: %s\n", db_strerror(ret));
+                       syslog(LOG_EMERG, "exit code %d\n", ret);
                        exit(CTDLEXIT_DB);
                }
 
@@ -401,11 +402,11 @@ void open_databases(void)
                                   0600
                );
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_open[%02x]: %s\n", i, db_strerror(ret));
+                       syslog(LOG_EMERG, "db_open[%02x]: %s\n", i, db_strerror(ret));
                        if (ret == ENOMEM) {
-                               CtdlLogPrintf(CTDL_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
+                               syslog(LOG_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
                        }
-                       CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+                       syslog(LOG_EMERG, "exit code %d\n", ret);
                        exit(CTDLEXIT_DB);
                }
        }
@@ -427,10 +428,10 @@ void cdb_chmod_data(void) {
                        if (d->d_name[0] != '.') {
                                snprintf(filename, sizeof filename,
                                         "%s/%s", ctdl_data_dir, d->d_name);
-                               CtdlLogPrintf(9, "chmod(%s, 0600) returned %d\n",
+                               syslog(LOG_DEBUG, "chmod(%s, 0600) returned %d\n",
                                        filename, chmod(filename, 0600)
                                );
-                               CtdlLogPrintf(9, "chown(%s, CTDLUID, -1) returned %d\n",
+                               syslog(LOG_DEBUG, "chown(%s, CTDLUID, -1) returned %d\n",
                                        filename, chown(filename, CTDLUID, (-1))
                                );
                        }
@@ -438,7 +439,7 @@ void cdb_chmod_data(void) {
                closedir(dp);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "open_databases() finished\n");
+       syslog(LOG_DEBUG, "open_databases() finished\n");
        CtdlRegisterProtoHook(cmd_cull, "CULL", "Cull database logs");
 }
 
@@ -455,7 +456,7 @@ void close_databases(void)
        ctdl_thread_internal_free_tsd();
        
        if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "txn_checkpoint: %s\n", db_strerror(ret));
        }
 
@@ -466,10 +467,10 @@ void close_databases(void)
 
        /* close the tables */
        for (a = 0; a < MAXCDB; ++a) {
-               CtdlLogPrintf(CTDL_INFO, "Closing database %02x\n", a);
+               syslog(LOG_INFO, "Closing database %02x\n", a);
                ret = dbp[a]->close(dbp[a], 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_close: %s\n", db_strerror(ret));
+                       syslog(LOG_EMERG, "db_close: %s\n", db_strerror(ret));
                }
 
        }
@@ -477,7 +478,7 @@ void close_databases(void)
        /* Close the handle. */
        ret = dbenv->close(dbenv, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "DBENV->close: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "DBENV->close: %s\n", db_strerror(ret));
        }
 }
 
@@ -521,7 +522,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb)
                       (uLongf *) & destLen,
                       (const Bytef *) compressed_data,
                       (uLong) sourceLen) != Z_OK) {
-               CtdlLogPrintf(CTDL_EMERG, "uncompress() error\n");
+               syslog(LOG_EMERG, "uncompress() error\n");
                abort();
        }
 
@@ -529,7 +530,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb)
        cdb->len = (size_t) destLen;
        cdb->ptr = uncompressed_data;
 #else                          /* HAVE_ZLIB */
-       CtdlLogPrintf(CTDL_EMERG, "Database contains compressed data, but this citserver was built without compression support.\n");
+       syslog(LOG_EMERG, "Database contains compressed data, but this citserver was built without compression support.\n");
        abort();
 #endif                         /* HAVE_ZLIB */
 }
@@ -575,7 +576,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                if (compress2((Bytef *) (compressed_data + sizeof(struct CtdlCompressHeader)),
                        &destLen, (Bytef *) cdata, (uLongf) cdatalen, 1) != Z_OK)
                {
-                       CtdlLogPrintf(CTDL_EMERG, "compress2() error\n");
+                       syslog(LOG_EMERG, "compress2() error\n");
                        abort();
                }
                zheader.compressed_len = (size_t) destLen;
@@ -592,7 +593,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                                    &ddata,     /* data */
                                    0); /* flags */
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
                        abort();
                }
 #ifdef HAVE_ZLIB
@@ -616,7 +617,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                                txabort(tid);
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_store(%d): %s\n",
+                               syslog(LOG_EMERG, "cdb_store(%d): %s\n",
                                        cdb, db_strerror(ret));
                                abort();
                        }
@@ -650,7 +651,7 @@ int cdb_delete(int cdb, void *key, int keylen)
        if (MYTID != NULL) {
                ret = dbp[cdb]->del(dbp[cdb], MYTID, &dkey, 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
                        if (ret != DB_NOTFOUND) {
                                abort();
                        }
@@ -667,7 +668,7 @@ int cdb_delete(int cdb, void *key, int keylen)
                                txabort(tid);
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_delete(%d): %s\n",
+                               syslog(LOG_EMERG, "cdb_delete(%d): %s\n",
                                        cdb, db_strerror(ret));
                                abort();
                        }
@@ -691,7 +692,7 @@ static DBC *localcursor(int cdb)
                                          DB_POSITION);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "localcursor: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "localcursor: %s\n", db_strerror(ret));
                abort();
        }
 
@@ -736,7 +737,7 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen)
        }
 
        if ((ret != 0) && (ret != DB_NOTFOUND)) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
                abort();
        }
 
@@ -745,7 +746,7 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen)
        tempcdb = (struct cdbdata *) malloc(sizeof(struct cdbdata));
 
        if (tempcdb == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n");
+               syslog(LOG_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n");
                abort();
        }
 
@@ -791,7 +792,7 @@ void cdb_rewind(int cdb)
        int ret = 0;
 
        if (MYCURSORS[cdb] != NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_rewind: must close cursor on database %d before reopening.\n", cdb);
                abort();
                /* cclose(MYCURSORS[cdb]); */
@@ -802,7 +803,7 @@ void cdb_rewind(int cdb)
         */
        ret = dbp[cdb]->cursor(dbp[cdb], MYTID, &MYCURSORS[cdb], 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -827,7 +828,7 @@ struct cdbdata *cdb_next_item(int cdb)
 
        if (ret) {
                if (ret != DB_NOTFOUND) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_next_item(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_next_item(%d): %s\n", cdb, db_strerror(ret));
                        abort();
                }
                cclose(MYCURSORS[cdb]);
@@ -855,7 +856,7 @@ void cdb_begin_transaction(void)
        bailIfCursor(MYCURSORS, "can't begin transaction during r/o cursor");
 
        if (MYTID != NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n");
+               syslog(LOG_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n");
                abort();
        }
 
@@ -868,7 +869,7 @@ void cdb_end_transaction(void)
 
        for (i = 0; i < MAXCDB; i++)
                if (MYCURSORS[i] != NULL) {
-                       CtdlLogPrintf(CTDL_WARNING,
+                       syslog(LOG_WARNING,
                                "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n",
                                i);
                        cclose(MYCURSORS[i]);
@@ -876,7 +877,7 @@ void cdb_end_transaction(void)
                }
 
        if (MYTID == NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_end_transaction: ERROR: txcommit(NULL) !!\n");
                abort();
        } else {
@@ -896,7 +897,7 @@ void cdb_trunc(int cdb)
        u_int32_t count;
 
        if (MYTID != NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_trunc must not be called in a transaction.\n");
                abort();
        } else {
@@ -913,9 +914,9 @@ void cdb_trunc(int cdb)
                                /* txabort(tid); */
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret));
+                               syslog(LOG_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret));
                                if (ret == ENOMEM) {
-                                       CtdlLogPrintf(CTDL_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
+                                       syslog(LOG_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
                                }
                                abort();
                        }
index 4430d299eb880288a4dcd6ffb247a66894766ec4..ce8c209425c816fbc2aac48c5d1281065df343db 100644 (file)
@@ -1127,7 +1127,7 @@ program against to set up some data files. If a directory is not
 specified, the directory
 name which was specified in the <tt>Makefile</tt> will be used.</p>
 <p><tt>-xDebugLevel</tt> - Set the verbosity of trace messages printed.
-When -x is used, it will suppress messages sent to syslog (see below).
+When -x is used, it will suppress messages sent to syslog(see below).
 In
 other words, syslog will never see certain messages if -x is used.
 Normally
index 0522c17fdf4e5a8c091aac3f16af5a7cad99e4b6..a1049537c3a446e08dab5383db92cbf39bde743f 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * DNS lookup for SMTP sender
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <stdio.h>
+#include <syslog.h>
 
 #ifdef HAVE_RESOLV_H
 #include <arpa/nameser.h>
@@ -160,7 +161,7 @@ int getmx(char *mxbuf, char *dest) {
        
                for (qdcount = ntohs(answer.header.qdcount); qdcount--; ptr += ret + QFIXEDSZ) {
                        if ((ret = dn_skipname(ptr, endptr)) < 0) {
-                               CtdlLogPrintf(CTDL_DEBUG, "dn_skipname error\n");
+                               syslog(LOG_DEBUG, "dn_skipname error\n");
                                return(0);
                        }
                }
index f93742a71fd137006f6b76aa99bca0ea50b2e5a5..2ac94574d6383c8cbf4144cea24929baad9ca370 100644 (file)
@@ -191,7 +191,7 @@ static void outputPrintf(char *format, ...)
                syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
        }
        else
-               CtdlLogPrintf(CTDL_EMERG, format, ap);
+               syslog(LOG_EMERG, format, ap);
 
 } // outputPrintf
 
@@ -216,7 +216,7 @@ static void createGlobalBacktrace( void )
                }
        else 
                for (NThread = 0; NThread < size; NThread++) 
-                       CtdlLogPrintf(1, "RAW: %p\n", stack_frames[NThread]);
+                       syslog(LOG_ALERT, "RAW: %p\n", stack_frames[NThread]);
        strings = backtrace_symbols(stack_frames, size);
        for (NThread = 0; NThread < size; NThread++) {
                if (strings != NULL) {
@@ -226,7 +226,7 @@ static void createGlobalBacktrace( void )
                                syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
                        }
                        else
-                               CtdlLogPrintf(1, "%s\n", strings[NThread]);
+                               syslog(LOG_ALERT, "%s\n", strings[NThread]);
                }
        }
 } /* createGlobalBacktrace */
@@ -242,7 +242,7 @@ static void outputRawtrace( void )
                }
        else 
                for (NThread = 0; NThread < size; NThread++) 
-                       CtdlLogPrintf(1, "RAW: %p\n", stack_frames[NThread]);
+                       syslog(LOG_ALERT, "RAW: %p\n", stack_frames[NThread]);
 } /* createGlobalBacktrace */
 
 /*!
index 9071056fa149310d836ecd73a430914f78b3a0fd..8bad12925557f072c6b713397337121624e0e7f5 100644 (file)
@@ -98,7 +98,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
        struct cdbdata *cdb_euid;
        long msgnum = (-1L);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -118,7 +118,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
                memcpy(&msgnum, cdb_euid->ptr, sizeof(long));
                cdb_free(cdb_euid);
        }
-       CtdlLogPrintf(CTDL_DEBUG, "returning msgnum = %ld\n", msgnum);
+       syslog(LOG_DEBUG, "returning msgnum = %ld\n", msgnum);
        return(msgnum);
 }
 
@@ -133,7 +133,7 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
        char *data;
        int data_len;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -191,7 +191,7 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
                if (CtdlGetRoom(&qr, rplist->name) == 0) {
                        if (DoesThisRoomNeedEuidIndexing(&qr)) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Rebuilding EUID index for <%s>\n",
                                        rplist->name);
                                CtdlUserGoto(rplist->name, 0, 0, NULL, NULL);
index 20bc03b68af2f900e6693061238a18f4901c596e..bb5e985a6c0e5c866f2207bb01db71dbd4475b9f 100644 (file)
@@ -97,7 +97,7 @@ int network_talking_to(char *nodename, int operation) {
                        break;
        }
 
-       if (nttlist != NULL) CtdlLogPrintf(CTDL_DEBUG, "nttlist=<%s>\n", nttlist);
+       if (nttlist != NULL) syslog(LOG_DEBUG, "nttlist=<%s>\n", nttlist);
        end_critical_section(S_NTTLIST);
        return(retval);
 }
@@ -601,7 +601,7 @@ void cmd_ucls(char *cmd)
                                unlink(CC->upl_path);
                        }
                        else {
-                               CtdlLogPrintf(CTDL_ALERT, "Cannot link %s to %s: %s\n",
+                               syslog(LOG_ALERT, "Cannot link %s to %s: %s\n",
                                        CC->upl_path, final_filename, strerror(errno)
                                );
                        }
index 0b2f2464d4ce8eb829ad14cfa8f60ce2f219cefc..9cce884473a0426b51cfd3ebc9c054b4c2cfc128 100644 (file)
@@ -1,5 +1,21 @@
 /*
  * This file contains miscellaneous housekeeping tasks.
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -27,6 +43,7 @@
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -45,7 +62,7 @@
 
 void check_sched_shutdown(void) {
        if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
-               CtdlLogPrintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n");
+               syslog(LOG_NOTICE, "Scheduled shutdown initiating.\n");
                CtdlThreadStopAll();
        }
 }
@@ -71,7 +88,7 @@ void check_ref_counts(void) {
 
        int new_refcounts[MAXFLOORS];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Checking floor reference counts\n");
+       syslog(LOG_DEBUG, "Checking floor reference counts\n");
        for (a=0; a<MAXFLOORS; ++a) {
                new_refcounts[a] = 0;
        }
@@ -90,7 +107,7 @@ void check_ref_counts(void) {
                        flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
                }
                lputfloor(&flbuf, a);
-               CtdlLogPrintf(CTDL_DEBUG, "Floor %d: %d rooms\n", a, new_refcounts[a]);
+               syslog(LOG_DEBUG, "Floor %d: %d rooms\n", a, new_refcounts[a]);
        }
 }      
 
index 8ec12f7e9268dd97ce5956ba5968b3b3db808d70..41c67a7e7556261649db1aac46e37e2b7f7e6d6e 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <strings.h>
+#include <syslog.h>
 #include <libical/ical.h>
 #include <libcitadel.h>
 #include "citadel.h"
@@ -40,13 +41,13 @@ icaltimezone *get_default_icaltimezone(void) {
                 zone = icaltimezone_get_builtin_timezone(default_zone_name);
         }
         if (!zone) {
-               CtdlLogPrintf(CTDL_ALERT,
+               syslog(LOG_ALERT,
                        "Unable to load '%s' time zone.  Defaulting to UTC.\n",
                        default_zone_name);
                 zone = icaltimezone_get_utc_timezone();
        }
        if (!zone) {
-               CtdlLogPrintf(1, "Unable to load UTC time zone!\n");
+               syslog(LOG_ALERT, "Unable to load UTC time zone!\n");
        }
         return zone;
 }
@@ -81,16 +82,16 @@ void ical_dezonify_backend(icalcomponent *cal,
 
                /* Convert it to an icaltimezone type. */
                if (tzid != NULL) {
-                       /* CtdlLogPrintf(9, "                * Stringy supplied timezone is: '%s'\n", tzid); */
+                       /* syslog(LOG_DEBUG, "                * Stringy supplied timezone is: '%s'\n", tzid); */
                        if ( (!strcasecmp(tzid, "UTC")) || (!strcasecmp(tzid, "GMT")) ) {
                                utc_declared_as_tzid = 1;
-                               /* CtdlLogPrintf(9, "                * ...and we handle that internally.\n"); */
+                               /* syslog(LOG_DEBUG, "                * ...and we handle that internally.\n"); */
                        }
                        else {
                                /* try attached first */
                                t = icalcomponent_get_timezone(cal, tzid);
 /*
-                               lprintf(9, "                * ...and I %s have tzdata for that zone.\n",
+                               syslog(LOG_DEBUG, "                * ...and I %s have tzdata for that zone.\n",
                                        (t ? "DO" : "DO NOT")
                                );
 */
@@ -99,7 +100,7 @@ void ical_dezonify_backend(icalcomponent *cal,
                                        t = icaltimezone_get_builtin_timezone(tzid);
 /*
                                        if (t) {
-                                               lprintf(9, "                * Using system tzdata!\n");
+                                               syslog(LOG_DEBUG, "                * Using system tzdata!\n");
                                        }
 */
                                }
@@ -126,24 +127,24 @@ void ical_dezonify_backend(icalcomponent *cal,
                return;
        }
 
-       /* CtdlLogPrintf(9, "                * Was: %s\n", icaltime_as_ical_string(TheTime)); */
+       /* syslog(LOG_DEBUG, "                * Was: %s\n", icaltime_as_ical_string(TheTime)); */
 
        if (TheTime.is_utc) {
-               /* CtdlLogPrintf(9, "                * This property is ALREADY UTC.\n"); */
+               /* syslog(LOG_DEBUG, "                * This property is ALREADY UTC.\n"); */
        }
 
        else if (utc_declared_as_tzid) {
-               /* CtdlLogPrintf(9, "                * Replacing '%s' TZID with 'Z' suffix.\n", tzid); */
+               /* syslog(LOG_DEBUG, "                * Replacing '%s' TZID with 'Z' suffix.\n", tzid); */
                TheTime.is_utc = 1;
        }
 
        else {
                /* Do the conversion. */
                if (t != NULL) {
-                       /* CtdlLogPrintf(9, "                * Timezone prop found.  Converting to UTC.\n"); */
+                       /* syslog(LOG_DEBUG, "                * Timezone prop found.  Converting to UTC.\n"); */
                }
                else {
-                       /* CtdlLogPrintf(9, "                * Converting default timezone to UTC.\n"); */
+                       /* syslog(LOG_DEBUG, "                * Converting default timezone to UTC.\n"); */
                }
 
                if (t == NULL) {
@@ -158,7 +159,7 @@ void ical_dezonify_backend(icalcomponent *cal,
        }
 
        icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);
-       /* CtdlLogPrintf(9, "                * Now: %s\n", icaltime_as_ical_string(TheTime)); */
+       /* syslog(LOG_DEBUG, "                * Now: %s\n", icaltime_as_ical_string(TheTime)); */
 
        /* Now add the converted property back in. */
        if (icalproperty_isa(prop) == ICAL_DTSTART_PROPERTY) {
@@ -224,7 +225,7 @@ void ical_dezonify_recurse(icalcomponent *cal, icalcomponent *rcal) {
 void ical_dezonify(icalcomponent *cal) {
        icalcomponent *vt = NULL;
 
-       /* CtdlLogPrintf(9, "ical_dezonify() started\n"); */
+       /* syslog(LOG_DEBUG, "ical_dezonify() started\n"); */
 
        /* Convert all times to UTC */
        ical_dezonify_recurse(cal, cal);
@@ -236,5 +237,5 @@ void ical_dezonify(icalcomponent *cal) {
                icalcomponent_free(vt);
        }
 
-       /* CtdlLogPrintf(9, "ical_dezonify() completed\n"); */
+       /* syslog(LOG_DEBUG, "ical_dezonify() completed\n"); */
 }
index 067071862122cef7d231c80f46749585caa7693f..543f1ed4bb5eeab0d86c4fe65b9065988b6b5ca9 100644 (file)
@@ -24,6 +24,7 @@
 #include <signal.h>
 #include <pwd.h>
 #include <errno.h>
+#include <syslog.h>
 #include <sys/types.h>
 
 #if TIME_WITH_SYS_TIME
 
 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
 
-
-/*
- * Prototype for making log entries in Citadel.
- */
-
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
-
 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT) 
-
 /*
  * Hook functions available to modules.
  */
index 0bb741a9819a8e3391d264b0aea1b5ea60fd4dd9..a5e4dd8e5271e9c199addfe715715bc77f5bb768 100644 (file)
@@ -603,7 +603,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
 
        else if (!strcasecmp(key, "From")) {
                process_rfc822_addr(value, user, node, name);
-               CtdlLogPrintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
+               syslog(LOG_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'] = strdup(name);
@@ -639,7 +639,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
 
        else if (!strcasecmp(key, "Message-ID")) {
                if (msg->cm_fields['I'] != NULL) {
-                       CtdlLogPrintf(CTDL_WARNING, "duplicate message id\n");
+                       syslog(LOG_WARNING, "duplicate message id\n");
                }
 
                if (msg->cm_fields['I'] == NULL) {
@@ -910,7 +910,7 @@ void directory_key(char *key, char *addr) {
        }
        key[keylen++] = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
+       syslog(LOG_DEBUG, "Directory key is <%s>\n", key);
 }
 
 
@@ -954,7 +954,7 @@ void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
        char key[SIZ];
 
        if (IsDirectory(internet_addr, 0) == 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
+       syslog(LOG_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
        directory_key(key, internet_addr);
        cdb_store(CDB_DIRECTORY, key, strlen(key), citadel_addr, strlen(citadel_addr)+1 );
 }
@@ -969,7 +969,7 @@ void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
 void CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr) {
        char key[SIZ];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
+       syslog(LOG_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
        directory_key(key, internet_addr);
        cdb_delete(CDB_DIRECTORY, key, strlen(key) );
 }
index 75bbb976a5fe17d85021700c76ddb190afff23ea..8efc6e59075bc7d6f8ab9b7e167e11c05b4ad434 100644 (file)
@@ -91,7 +91,7 @@ int CtdlTryUserLDAP(char *username,
 
        ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
        if (ldserver == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "LDAP: Could not connect to %s:%d : %s\n",
+               syslog(LOG_ALERT, "LDAP: Could not connect to %s:%d : %s\n",
                        config.c_ldap_host, config.c_ldap_port,
                        strerror(errno)
                );
@@ -102,13 +102,13 @@ int CtdlTryUserLDAP(char *username,
 
        striplt(config.c_ldap_bind_dn);
        striplt(config.c_ldap_bind_pw);
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP bind DN: %s\n", config.c_ldap_bind_dn);
+       syslog(LOG_DEBUG, "LDAP bind DN: %s\n", config.c_ldap_bind_dn);
        i = ldap_simple_bind_s(ldserver,
                (!IsEmptyStr(config.c_ldap_bind_dn) ? config.c_ldap_bind_dn : NULL),
                (!IsEmptyStr(config.c_ldap_bind_pw) ? config.c_ldap_bind_pw : NULL)
        );
        if (i != LDAP_SUCCESS) {
-               CtdlLogPrintf(CTDL_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+               syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
                return(i);
        }
 
@@ -122,7 +122,7 @@ int CtdlTryUserLDAP(char *username,
                sprintf(searchstring, "(&(objectclass=posixAccount)(uid=%s))", username);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP search: %s\n", searchstring);
+       syslog(LOG_DEBUG, "LDAP search: %s\n", searchstring);
        i = ldap_search_ext_s(ldserver,                         /* ld                           */
                config.c_ldap_base_dn,                          /* base                         */
                LDAP_SCOPE_SUBTREE,                             /* scope                        */
@@ -140,7 +140,7 @@ int CtdlTryUserLDAP(char *username,
         * the search succeeds.  Instead, we check to see whether search_result is still NULL.
         */
        if (search_result == NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "LDAP search: zero results were returned\n");
+               syslog(LOG_DEBUG, "LDAP search: zero results were returned\n");
                ldap_unbind(ldserver);
                return(2);
        }
@@ -153,7 +153,7 @@ int CtdlTryUserLDAP(char *username,
 
                user_dn = ldap_get_dn(ldserver, entry);
                if (user_dn) {
-                       CtdlLogPrintf(CTDL_DEBUG, "dn = %s\n", user_dn);
+                       syslog(LOG_DEBUG, "dn = %s\n", user_dn);
                }
 
                if (config.c_auth_mode == AUTHMODE_LDAP_AD) {
@@ -161,7 +161,7 @@ int CtdlTryUserLDAP(char *username,
                        if (values) {
                                if (values[0]) {
                                        if (fullname) safestrncpy(fullname, values[0], fullname_size);
-                                       CtdlLogPrintf(CTDL_DEBUG, "displayName = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "displayName = %s\n", values[0]);
                                }
                                ldap_value_free(values);
                        }
@@ -171,7 +171,7 @@ int CtdlTryUserLDAP(char *username,
                        if (values) {
                                if (values[0]) {
                                        if (fullname) safestrncpy(fullname, values[0], fullname_size);
-                                       CtdlLogPrintf(CTDL_DEBUG, "cn = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "cn = %s\n", values[0]);
                                }
                                ldap_value_free(values);
                        }
@@ -183,7 +183,7 @@ int CtdlTryUserLDAP(char *username,
                                if (values[0]) {
                                        if (uid != NULL) {
                                                *uid = abs(HashLittle(values[0], strlen(values[0])));
-                                               CtdlLogPrintf(CTDL_DEBUG, "uid hashed from objectGUID = %d\n", *uid);
+                                               syslog(LOG_DEBUG, "uid hashed from objectGUID = %d\n", *uid);
                                        }
                                }
                                ldap_value_free(values);
@@ -193,7 +193,7 @@ int CtdlTryUserLDAP(char *username,
                        values = ldap_get_values(ldserver, search_result, "uidNumber");
                        if (values) {
                                if (values[0]) {
-                                       CtdlLogPrintf(CTDL_DEBUG, "uidNumber = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "uidNumber = %s\n", values[0]);
                                        if (uid != NULL) {
                                                *uid = atoi(values[0]);
                                        }
@@ -211,7 +211,7 @@ int CtdlTryUserLDAP(char *username,
        ldap_unbind(ldserver);
 
        if (!user_dn) {
-               CtdlLogPrintf(CTDL_DEBUG, "No such user was found.\n");
+               syslog(LOG_DEBUG, "No such user was found.\n");
                return(4);
        }
 
@@ -227,20 +227,20 @@ int CtdlTryPasswordLDAP(char *user_dn, const char *password)
        int i = (-1);
 
        if (IsEmptyStr(password)) {
-               CtdlLogPrintf(CTDL_DEBUG, "LDAP: empty passwords are not permitted\n");
+               syslog(LOG_DEBUG, "LDAP: empty passwords are not permitted\n");
                return(1);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP: trying to bind as %s\n", user_dn);
+       syslog(LOG_DEBUG, "LDAP: trying to bind as %s\n", user_dn);
        ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
        if (ldserver) {
                ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
                i = ldap_simple_bind_s(ldserver, user_dn, password);
                if (i == LDAP_SUCCESS) {
-                       CtdlLogPrintf(CTDL_DEBUG, "LDAP: bind succeeded\n");
+                       syslog(LOG_DEBUG, "LDAP: bind succeeded\n");
                }
                else {
-                       CtdlLogPrintf(CTDL_DEBUG, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+                       syslog(LOG_DEBUG, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
                }
                ldap_unbind(ldserver);
        }
index e1693d25cd92571c7beccc7a26c7d3dd00e8b643..20704c927c3958f8a419f109fa70bf84018cef20 100644 (file)
@@ -1,5 +1,21 @@
 /*
  * Functions which handle hostname/address lookups and resolution
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -16,6 +32,7 @@
 #include <netdb.h>
 #include <string.h>
 #include <errno.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -296,7 +313,7 @@ int rbl_check(char *message_to_spammer)
 
                if (rblcheck_backend(tbuf, txt_answer, sizeof txt_answer)) {
                        strcpy(message_to_spammer, txt_answer);
-                       CtdlLogPrintf(CTDL_INFO, "RBL: %s\n", txt_answer);
+                       syslog(LOG_INFO, "RBL: %s\n", txt_answer);
                        return(1);
                }
        }
index d2bf8d03fc248f0c9f8bf997dd19c0e0e1b594d7..314a5ccea42aacc5d16f98a8d10d10ff091bac7e 100644 (file)
@@ -4,9 +4,9 @@
  * iTIP protocol.  See RFCs 2445 and 2446.
  *
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
@@ -50,7 +50,7 @@ icalcomponent *icalcomponent_new_citadel_vcalendar(void) {
 
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: could not allocate component!\n");
+               syslog(LOG_CRIT, "ERROR: could not allocate component!\n");
                return NULL;
        }
 
@@ -186,13 +186,13 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        strcpy(summary_string, "Calendar item");
 
        if (request == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
+               syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
                return;
        }
 
        the_reply = icalcomponent_new_clone(request);
        if (the_reply == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone request\n");
+               syslog(LOG_ERR, "ERROR: cannot clone request\n");
                return;
        }
 
@@ -594,13 +594,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);
-       CtdlLogPrintf(CTDL_DEBUG, "UID of event being replied to is <%s>\n", uid);
+       syslog(LOG_DEBUG, "UID of event being replied to is <%s>\n", uid);
 
        strcpy(hold_rm, CC->room.QRname);       /* save current room */
 
        if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
                CtdlGetRoom(&CC->room, hold_rm);
-               CtdlLogPrintf(CTDL_CRIT, "cannot get user calendar room\n");
+               syslog(LOG_CRIT, "cannot get user calendar room\n");
                return(2);
        }
 
@@ -614,7 +614,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
 
        CtdlGetRoom(&CC->room, hold_rm);        /* return to saved room */
 
-       CtdlLogPrintf(CTDL_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
+       syslog(LOG_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
        if (msgnum_being_replaced == 0) {
                return(1);                      /* no calendar event found */
        }
@@ -641,7 +641,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
 
        original_event = oec.c;
        if (original_event == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: Original_component is NULL.\n");
+               syslog(LOG_ERR, "ERROR: Original_component is NULL.\n");
                return(2);
        }
 
@@ -845,7 +845,7 @@ int ical_ctdl_is_overlap(
                return(1);
        }
 
-       /* lprintf (9, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
+       /* syslog(LOG_DEBUG, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
                t1start.hour, t1start.minute, t1end.hour, t1end.minute,
                t2start.hour, t2start.minute, t2end.hour, t2end.minute);
        */
@@ -854,11 +854,11 @@ int ical_ctdl_is_overlap(
 
        /* If event 1 ends before event 2 starts, we're in the clear. */
        if (icaltime_compare(t1end, t2start) <= 0) return(0);
-       /* lprintf(9, "first passed\n"); */
+       /* syslog(LOG_DEBUG, "first passed\n"); */
 
        /* If event 2 ends before event 1 starts, we're also ok. */
        if (icaltime_compare(t2end, t1start) <= 0) return(0);
-       /* lprintf(9, "second passed\n"); */
+       /* syslog(LOG_DEBUG, "second passed\n"); */
 
        /* Otherwise, they overlap. */
        return(1);
@@ -887,13 +887,13 @@ int ical_conflicts_phase6(struct icaltimetype t1start,
        /* debugging cruft *
        time_t tt;
        tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "  PROPOSED END: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "  PROPOSED END: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "  EXISTING END: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "  EXISTING END: %s", ctime(&tt));
        * debugging cruft */
 
        /* compare and output */
@@ -1430,7 +1430,7 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                strcpy(buf, who);
                recp = validate_recipients(buf, NULL, 0);
-               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
                                found_user = CtdlGetUser(&usbuf, recp->recp_local);
@@ -1444,7 +1444,7 @@ void ical_freebusy(char *who) {
         */
        if (found_user != 0) {
                snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
-               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                recp = validate_recipients(buf, NULL, 0);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
@@ -1467,7 +1467,7 @@ void ical_freebusy(char *who) {
                        if ( (!strcasecmp(type, "localhost"))
                           || (!strcasecmp(type, "directory")) ) {
                                snprintf(buf, sizeof buf, "%s@%s", who, host);
-                               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+                               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                                recp = validate_recipients(buf, NULL, 0);
                                if (recp != NULL) {
                                        if (recp->num_local == 1) {
@@ -1496,7 +1496,7 @@ void ical_freebusy(char *who) {
        }
 
        /* Create a VFREEBUSY subcomponent */
-       CtdlLogPrintf(CTDL_DEBUG, "Creating VFREEBUSY component\n");
+       syslog(LOG_DEBUG, "Creating VFREEBUSY component\n");
        fb = icalcomponent_new_vfreebusy();
        if (fb == NULL) {
                cprintf("%d Internal error: cannot allocate memory.\n",
@@ -1523,7 +1523,7 @@ void ical_freebusy(char *who) {
        icalcomponent_add_property(fb, icalproperty_new_organizer(buf));
 
        /* Add busy time from events */
-       CtdlLogPrintf(CTDL_DEBUG, "Adding busy time from events\n");
+       syslog(LOG_DEBUG, "Adding busy time from events\n");
        CtdlForEachMessage(MSGS_ALL, 0, NULL, NULL, NULL, ical_freebusy_backend, (void *)fb );
 
        /* If values for DTSTART and DTEND are still not present, set them
@@ -1537,7 +1537,7 @@ void ical_freebusy(char *who) {
        }
 
        /* Put the freebusy component into the calendar component */
-       CtdlLogPrintf(CTDL_DEBUG, "Encapsulating\n");
+       syslog(LOG_DEBUG, "Encapsulating\n");
        encaps = ical_encapsulate_subcomponent(fb);
        if (encaps == NULL) {
                icalcomponent_free(fb);
@@ -1548,11 +1548,11 @@ void ical_freebusy(char *who) {
        }
 
        /* Set the method to PUBLISH */
-       CtdlLogPrintf(CTDL_DEBUG, "Setting method\n");
+       syslog(LOG_DEBUG, "Setting method\n");
        icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
 
        /* Serialize it */
-       CtdlLogPrintf(CTDL_DEBUG, "Serializing\n");
+       syslog(LOG_DEBUG, "Serializing\n");
        serialized_request = icalcomponent_as_ical_string_r(encaps);
        icalcomponent_free(encaps);     /* Don't need this anymore. */
 
@@ -1661,7 +1661,7 @@ void ical_getics(void)
 
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+               syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
                cprintf("%d Could not allocate memory\n", ERROR+INTERNAL_ERROR);
                return;
        }
@@ -1787,7 +1787,7 @@ void ical_putics(void)
                                HashPos = GetNewHashPos(tzidlist, 0);
 
                                while (GetNextHashPos(tzidlist, HashPos, &len, &Key, &Value)) {
-                                       CtdlLogPrintf(CTDL_DEBUG, "Attaching timezone '%s'\n", (char*) Value);
+                                       syslog(LOG_DEBUG, "Attaching timezone '%s'\n", (char*) Value);
                                        icaltimezone *t = NULL;
 
                                        /* First look for a timezone attached to the original calendar */
@@ -1912,7 +1912,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERCALENDARROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1929,7 +1929,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERTASKSROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1946,7 +1946,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERNOTESROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1995,7 +1995,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        const char *tzidc = NULL;
 
        if (cal == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
+               syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
                return;
        }
 
@@ -2013,7 +2013,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        /* Clone the event */
        the_request = icalcomponent_new_clone(cal);
        if (the_request == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone calendar object\n");
+               syslog(LOG_ERR, "ERROR: cannot clone calendar object\n");
                return;
        }
 
@@ -2049,7 +2049,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                }
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
+       syslog(LOG_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!
@@ -2062,7 +2062,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        /* Encapsulate the VEVENT component into a complete VCALENDAR */
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+               syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
                icalcomponent_free(the_request);
                return;
        }
@@ -2214,7 +2214,7 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
        icalproperty *organizer = NULL;
        char organizer_string[SIZ];
 
-       CtdlLogPrintf(CTDL_DEBUG, "ical_saving_vevent() has been called!\n");
+       syslog(LOG_DEBUG, "ical_saving_vevent() has been called!\n");
 
        /* Don't send out invitations unless the client wants us to. */
        if (CIT_ICAL->server_generated_invitations == 0) {
@@ -2329,7 +2329,7 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
                                                free(msg->cm_fields['E']);
                                        }
                                        msg->cm_fields['E'] = strdup(buf);
-                                       CtdlLogPrintf(CTDL_DEBUG, "Saving calendar UID <%s>\n", buf);
+                                       syslog(LOG_DEBUG, "Saving calendar UID <%s>\n", buf);
                                }
                        }
 
@@ -2390,7 +2390,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
 
        /* It must be an RFC822 message! */
        if (msg->cm_format_type != 4) {
-               CtdlLogPrintf(CTDL_DEBUG, "Rejecting non-RFC822 message\n");
+               syslog(LOG_DEBUG, "Rejecting non-RFC822 message\n");
                return(1);              /* You tried to save a non-RFC822 message! */
        }
 
index 0b36b086cd6c9025e0715a4f5ed40b4e25c55f8a..061f980a7289c7f8c3b758ae2524d75132a8c4af 100644 (file)
@@ -66,13 +66,13 @@ void *checkpoint_thread(void *arg) {
        CtdlFillSystemContext(&checkpointCC, "checkpoint");
        citthread_setspecific(MyConKey, (void *)&checkpointCC );
 
-       CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() initializing\n");
+       syslog(LOG_DEBUG, "checkpoint_thread() initializing\n");
        while (!CtdlThreadCheckStop()) {
                cdb_checkpoint();
                CtdlThreadSleep(60);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() exiting\n");
+       syslog(LOG_DEBUG, "checkpoint_thread() exiting\n");
        CtdlClearSystemContext();
        return NULL;
 }
index e31638aee42a5935d4f67b2b754537eae6afe9af..11772261d8965573d8094429ee669dcb17c57299 100644 (file)
@@ -94,7 +94,7 @@ int clamd(struct CtdlMessage *msg) {
        /* Try them one by one until we get a working one */
         for (clamhost=0; clamhost<num_clamhosts; ++clamhost) {
                 extract_token(buf, clamhosts, clamhost, '|', sizeof buf);
-                CtdlLogPrintf(CTDL_INFO, "Connecting to clamd at <%s>\n", buf);
+                syslog(LOG_INFO, "Connecting to clamd at <%s>\n", buf);
 
                 /* Assuming a host:port entry */ 
                 extract_token(hostbuf, buf, 0, ':', sizeof hostbuf);
@@ -105,7 +105,7 @@ int clamd(struct CtdlMessage *msg) {
                   /* Port specified lets try connecting to it! */
                   sock = sock_connect(hostbuf, portbuf);
 
-                if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+                if (sock >= 0) syslog(LOG_DEBUG, "Connected!\n");
         }
 
        if (sock < 0) {
@@ -120,16 +120,16 @@ int clamd(struct CtdlMessage *msg) {
        CCC->sPos = NULL;
 
        /* Command */
-       CtdlLogPrintf(CTDL_DEBUG, "Transmitting STREAM command\n");
+       syslog(LOG_DEBUG, "Transmitting STREAM command\n");
        sprintf(buf, "STREAM\r\n");
        sock_write(&sock, buf, strlen(buf));
 
-       CtdlLogPrintf(CTDL_DEBUG, "Waiting for PORT number\n");
+       syslog(LOG_DEBUG, "Waiting for PORT number\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
 
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "PORT", 4)!=0) {
                goto bail;
        }
@@ -149,7 +149,7 @@ int clamd(struct CtdlMessage *msg) {
                return(0);
         }
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "STREAM socket connected!\n");
+               syslog(LOG_DEBUG, "STREAM socket connected!\n");
        }
 
 
@@ -170,11 +170,11 @@ int clamd(struct CtdlMessage *msg) {
                close(streamsock);
        
        /* Response */
-       CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
+       syslog(LOG_DEBUG, "Awaiting response\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "stream: OK", 10)!=0) {
                is_virus = 1;
        }
index e10cb79f0b489978622bed6d7f8edbe4bab08756..15b42035aa1274c9ab23d6645bde2892f0951581 100644 (file)
@@ -93,14 +93,14 @@ void init_ssl(void)
                RAND_egd(EGD_POOL);
 
        if (!RAND_status()) {
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                        "PRNG not adequately seeded, won't do SSL/TLS\n");
                return;
        }
        SSLCritters =
            malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t *));
        if (!SSLCritters) {
-               CtdlLogPrintf(CTDL_EMERG, "citserver: can't allocate memory!!\n");
+               syslog(LOG_EMERG, "citserver: can't allocate memory!!\n");
                /* Nothing's been initialized, just die */
                exit(1);
        } else {
@@ -109,7 +109,7 @@ void init_ssl(void)
                for (a = 0; a < CRYPTO_num_locks(); a++) {
                        SSLCritters[a] = malloc(sizeof(pthread_mutex_t));
                        if (!SSLCritters[a]) {
-                               CtdlLogPrintf(CTDL_EMERG,
+                               syslog(LOG_EMERG,
                                        "citserver: can't allocate memory!!\n");
                                /* Nothing's been initialized, just die */
                                exit(1);
@@ -125,12 +125,12 @@ void init_ssl(void)
        SSL_load_error_strings();
        ssl_method = SSLv23_server_method();
        if (!(ssl_ctx = SSL_CTX_new(ssl_method))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_CTX_new failed: %s\n",
+               syslog(LOG_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))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL: No ciphers available\n");
+               syslog(LOG_CRIT, "SSL: No ciphers available\n");
                SSL_CTX_free(ssl_ctx);
                ssl_ctx = NULL;
                return;
@@ -148,21 +148,21 @@ void init_ssl(void)
        /* Load DH parameters into the context */
        dh = DH_new();
        if (!dh) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't allocate a DH object: %s\n",
+               syslog(LOG_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))) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't assign DH_P: %s\n",
+               syslog(LOG_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))) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't assign DH_G: %s\n",
+               syslog(LOG_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;
@@ -181,13 +181,13 @@ void init_ssl(void)
         * Generate a key pair if we don't have one.
         */
        if (access(file_crpt_file_key, R_OK) != 0) {
-               CtdlLogPrintf(CTDL_INFO, "Generating RSA key pair.\n");
+               syslog(LOG_INFO, "Generating RSA key pair.\n");
                rsa = RSA_generate_key(1024,    /* modulus size */
                                        65537,  /* exponent */
                                        NULL,   /* no callback */
                                        NULL);  /* no callback */
                if (rsa == NULL) {
-                       CtdlLogPrintf(CTDL_CRIT, "Key generation failed: %s\n",
+                       syslog(LOG_CRIT, "Key generation failed: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
                }
                if (rsa != NULL) {
@@ -202,7 +202,7 @@ void init_ssl(void)
                                                        NULL,   /* no callbk */
                                                        NULL    /* no callbk */
                                ) != 1) {
-                                       CtdlLogPrintf(CTDL_CRIT, "Cannot write key: %s\n",
+                                       syslog(LOG_CRIT, "Cannot write key: %s\n",
                                                ERR_reason_error_string(ERR_get_error()));
                                        unlink(file_crpt_file_key);
                                }
@@ -218,7 +218,7 @@ void init_ssl(void)
         * the CSR in this step so that the next step may commence.
         */
        if ( (access(file_crpt_file_cer, R_OK) != 0) && (access(file_crpt_file_csr, R_OK) != 0) ) {
-               CtdlLogPrintf(CTDL_INFO, "Generating a certificate signing request.\n");
+               syslog(LOG_INFO, "Generating a certificate signing request.\n");
 
                /*
                 * Read our key from the file.  No, we don't just keep this
@@ -281,7 +281,7 @@ void init_ssl(void)
 
                                        /* Sign the CSR */
                                        if (!X509_REQ_sign(req, pk, EVP_md5())) {
-                                               CtdlLogPrintf(CTDL_CRIT, "X509_REQ_sign(): error\n");
+                                               syslog(LOG_CRIT, "X509_REQ_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -301,7 +301,7 @@ void init_ssl(void)
                }
 
                else {
-                       CtdlLogPrintf(CTDL_CRIT, "Unable to read private key.\n");
+                       syslog(LOG_CRIT, "Unable to read private key.\n");
                }
        }
 
@@ -311,7 +311,7 @@ void init_ssl(void)
         * Generate a self-signed certificate if we don't have one.
         */
        if (access(file_crpt_file_cer, R_OK) != 0) {
-               CtdlLogPrintf(CTDL_INFO, "Generating a self-signed certificate.\n");
+               syslog(LOG_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.
@@ -351,7 +351,7 @@ void init_ssl(void)
                                        
                                        /* Sign the cert */
                                        if (!X509_sign(cer, pk, EVP_md5())) {
-                                               CtdlLogPrintf(CTDL_CRIT, "X509_sign(): error\n");
+                                               syslog(LOG_CRIT, "X509_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -377,7 +377,7 @@ void init_ssl(void)
         SSL_CTX_use_certificate_chain_file(ssl_ctx, file_crpt_file_cer);
         SSL_CTX_use_PrivateKey_file(ssl_ctx, file_crpt_file_key, SSL_FILETYPE_PEM);
         if ( !SSL_CTX_check_private_key(ssl_ctx) ) {
-               CtdlLogPrintf(CTDL_CRIT, "Cannot install certificate: %s\n",
+               syslog(LOG_CRIT, "Cannot install certificate: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
         }
 
@@ -403,7 +403,7 @@ void client_write_ssl(const char *buf, int nbytes)
        while (nremain > 0) {
                if (SSL_want_write(CC->ssl)) {
                        if ((SSL_read(CC->ssl, junk, 0)) < 1) {
-                               CtdlLogPrintf(CTDL_DEBUG, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error()));
+                               syslog(LOG_DEBUG, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error()));
                        }
                }
                retval =
@@ -417,9 +417,9 @@ void client_write_ssl(const char *buf, int nbytes)
                                sleep(1);
                                continue;
                        }
-                       CtdlLogPrintf(CTDL_DEBUG, "SSL_write got error %ld, ret %d\n", errval, retval);
+                       syslog(LOG_DEBUG, "SSL_write got error %ld, ret %d\n", errval, retval);
                        if (retval == -1)
-                               CtdlLogPrintf(CTDL_DEBUG, "errno is %d\n", errno);
+                               syslog(LOG_DEBUG, "errno is %d\n", errno);
                        endtls();
                        client_write(&buf[nbytes - nremain], nremain);
                        return;
@@ -444,7 +444,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
        while (1) {
                if (SSL_want_read(pssl)) {
                        if ((SSL_write(pssl, junk, 0)) < 1) {
-                               CtdlLogPrintf(CTDL_DEBUG, "SSL_write in client_read\n");
+                               syslog(LOG_DEBUG, "SSL_write in client_read\n");
                        }
                }
                rlen = SSL_read(pssl, sbuf, sizeof(sbuf));
@@ -456,7 +456,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
                                sleep(1);
                                continue;
                        }
-                       CtdlLogPrintf(CTDL_DEBUG, "SSL_read got error %ld\n", errval);
+                       syslog(LOG_DEBUG, "SSL_read got error %ld\n", errval);
                        endtls();
                        return (-1);
                }
@@ -637,18 +637,18 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
        int retval, bits, alg_bits;
 
        if (!ssl_ctx) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL failed: no ssl_ctx exists?\n");
+               syslog(LOG_CRIT, "SSL failed: no ssl_ctx exists?\n");
                if (nosup_response != NULL) cprintf("%s", nosup_response);
                return;
        }
        if (!(CC->ssl = SSL_new(ssl_ctx))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_new failed: %s\n",
+               syslog(LOG_CRIT, "SSL_new failed: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
                if (error_response != NULL) cprintf("%s", error_response);
                return;
        }
        if (!(SSL_set_fd(CC->ssl, CC->client_socket))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_set_fd failed: %s\n",
+               syslog(LOG_CRIT, "SSL_set_fd failed: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                SSL_free(CC->ssl);
                CC->ssl = NULL;
@@ -667,7 +667,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
                char error_string[128];
 
                errval = SSL_get_error(CC->ssl, retval);
-               CtdlLogPrintf(CTDL_CRIT, "SSL_accept failed: retval=%d, errval=%ld, err=%s\n",
+               syslog(LOG_CRIT, "SSL_accept failed: retval=%d, errval=%ld, err=%s\n",
                        retval,
                        errval,
                        ERR_error_string(errval, error_string)
@@ -678,7 +678,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
        }
        BIO_set_close(CC->ssl->rbio, BIO_NOCLOSE);
        bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(CC->ssl), &alg_bits);
-       CtdlLogPrintf(CTDL_INFO, "SSL/TLS using %s on %s (%d of %d bits)\n",
+       syslog(LOG_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);
@@ -745,7 +745,7 @@ void endtls(void)
                return;
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Ending SSL/TLS\n");
+       syslog(LOG_INFO, "Ending SSL/TLS\n");
        SSL_shutdown(CC->ssl);
        SSL_free(CC->ssl);
        CC->ssl = NULL;
index 1f1349a17127115836e995e1d3f843d9b2c54c96..b29ba20a1c73437b861493647e0e2a669e2ffa83 100644 (file)
@@ -157,12 +157,12 @@ void dspam_do_msg(long msgnum, void *userdata)
        if (dspam_process (CTX, msgtext) != 0)
        {
                free(msgtext);
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: dspam_process failed");
+               syslog(LOG_CRIT, "ERROR: dspam_process failed");
                return;
        }
        if (CTX->signature == NULL)
        {
-               CtdlLogPrintf(CTDL_CRIT,"No signature provided\n");
+               syslog(LOG_CRIT,"No signature provided\n");
        }
        else
        {
@@ -175,7 +175,7 @@ void dspam_do_msg(long msgnum, void *userdata)
 
        SIG.length = CTX->signature->length;
        /* Print processing results */
-       CtdlLogPrintf (CTDL_DEBUG, "Probability: %2.4f Confidence: %2.4f, Result: %s\n",
+       syslog(LOG_DEBUG, "Probability: %2.4f Confidence: %2.4f, Result: %s\n",
                CTX->probability,
                CTX->confidence,
                (CTX->result == DSR_ISSPAM) ? "Spam" : "Innocent");
@@ -214,7 +214,7 @@ int serv_dspam_room(struct ctdlroom *room)
        /// else -> todo: global user for public rooms etc.
        if (CTX == NULL)
        {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: dspam_init failed!\n");
+               syslog(LOG_CRIT, "ERROR: dspam_init failed!\n");
                return ERROR + INTERNAL_ERROR;
        }
        /* Use graham and robinson algorithms, graham's p-values */
@@ -253,7 +253,7 @@ CTDL_MODULE_INIT(dspam)
 
 #else  /* HAVE_LIBDSPAM */
 
-               CtdlLogPrintf(CTDL_INFO, "This server is missing libdspam Spam filtering will be disabled.\n");
+               syslog(LOG_INFO, "This server is missing libdspam Spam filtering will be disabled.\n");
 
 #endif /* HAVE_LIBDSPAM */
        }
index 22442ad1526cc255ff5dfbad339fd39d096fdd6d..bf10973814a6f73efb3da339d0eff7b7fd4e077e 100644 (file)
@@ -247,12 +247,12 @@ void DoPurgeMessages(FILE *purgelist) {
 void PurgeMessages(void) {
        FILE *purgelist;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeMessages() called\n");
+       syslog(LOG_DEBUG, "PurgeMessages() called\n");
        messages_purged = 0;
 
        purgelist = tmpfile();
        if (purgelist == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Can't create purgelist temp file: %s\n",
+               syslog(LOG_CRIT, "Can't create purgelist temp file: %s\n",
                        strerror(errno));
                return;
        }
@@ -320,7 +320,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;
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
+               syslog(LOG_DEBUG, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
                if (age > purge_secs) do_purge = 1;
        } /* !QR_MAILBOX */
 
@@ -342,7 +342,7 @@ int PurgeRooms(void) {
        struct ValidUser *vuptr;
        char *transcript = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeRooms() called\n");
+       syslog(LOG_DEBUG, "PurgeRooms() called\n");
 
 
        /* Load up a table full of valid user numbers so we can delete
@@ -379,7 +379,7 @@ int PurgeRooms(void) {
        if (num_rooms_purged > 0) CtdlAideMessage(transcript, "Room Autopurger Message");
        free(transcript);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purged %d rooms.\n", num_rooms_purged);
+       syslog(LOG_DEBUG, "Purged %d rooms.\n", num_rooms_purged);
        return(num_rooms_purged);
 }
 
@@ -480,7 +480,7 @@ void do_user_purge(struct ctdluser *us, void *data) {
                 * we will need to try and purge them from users data bases.Some will not have names but
                 * those with names should be purged.
                 */
-               CtdlLogPrintf(CTDL_DEBUG, "Auto purger found a user 0 with name \"%s\"\n", us->fullname);
+               syslog(LOG_DEBUG, "Auto purger found a user 0 with name \"%s\"\n", us->fullname);
                // purge = 0;
        }
        
@@ -531,7 +531,7 @@ int PurgeUsers(void) {
        int num_users_purged = 0;
        char *transcript = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeUsers() called\n");
+       syslog(LOG_DEBUG, "PurgeUsers() called\n");
        users_not_purged = 0;
 
        switch(config.c_auth_mode) {
@@ -542,7 +542,7 @@ int PurgeUsers(void) {
                        ForEachUser(do_uid_user_purge, NULL);
                        break;
                default:
-                       CtdlLogPrintf(CTDL_DEBUG, "User purge for auth mode %d is not implemented.\n",
+                       syslog(LOG_DEBUG, "User purge for auth mode %d is not implemented.\n",
                                config.c_auth_mode);
                        break;
        }
@@ -593,7 +593,7 @@ int PurgeUsers(void) {
                users_zero_msg = NULL;
        }
                
-       CtdlLogPrintf(CTDL_DEBUG, "Purged %d users.\n", num_users_purged);
+       syslog(LOG_DEBUG, "Purged %d users.\n", num_users_purged);
        return(num_users_purged);
 }
 
@@ -708,7 +708,7 @@ int PurgeUseTable(void) {
        struct UPurgeList *uptr; 
 
        /* Phase 1: traverse through the table, discovering old records... */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: phase 1\n");
+       syslog(LOG_DEBUG, "Purge use table: phase 1\n");
        cdb_rewind(CDB_USETABLE);
        while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
 
@@ -735,7 +735,7 @@ int PurgeUseTable(void) {
        }
 
        /* Phase 2: delete the records */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: phase 2\n");
+       syslog(LOG_DEBUG, "Purge use table: phase 2\n");
        while (ul != NULL) {
                cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key));
                uptr = ul->next;
@@ -743,7 +743,7 @@ int PurgeUseTable(void) {
                ul = uptr;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: finished (purged %d records)\n", purged);
+       syslog(LOG_DEBUG, "Purge use table: finished (purged %d records)\n", purged);
        return(purged);
 }
 
@@ -762,7 +762,7 @@ int PurgeEuidIndexTable(void) {
        struct CtdlMessage *msg = NULL;
 
        /* Phase 1: traverse through the table, discovering old records... */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge EUID index: phase 1\n");
+       syslog(LOG_DEBUG, "Purge EUID index: phase 1\n");
        cdb_rewind(CDB_EUIDINDEX);
        while(cdbei = cdb_next_item(CDB_EUIDINDEX), cdbei != NULL) {
 
@@ -789,7 +789,7 @@ int PurgeEuidIndexTable(void) {
        }
 
        /* Phase 2: delete the records */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge euid index: phase 2\n");
+       syslog(LOG_DEBUG, "Purge euid index: phase 2\n");
        while (el != NULL) {
                cdb_delete(CDB_EUIDINDEX, el->ep_key, el->ep_keylen);
                free(el->ep_key);
@@ -798,7 +798,7 @@ int PurgeEuidIndexTable(void) {
                el = eptr;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purge euid index: finished (purged %d records)\n", purged);
+       syslog(LOG_DEBUG, "Purge euid index: finished (purged %d records)\n", purged);
        return(purged);
 }
 
@@ -840,7 +840,7 @@ int PurgeStaleOpenIDassociations(void) {
        HashPos = GetNewHashPos(keys, 0);
        while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n",  (char*)Value);
+               syslog(LOG_DEBUG, "Deleting associated OpenID <%s>\n",  (char*)Value);
                cdb_delete(CDB_OPENID, Value, strlen(Value));
                /* note: don't free(Value) -- deleting the hash list will handle this for us */
                ++num_deleted;
@@ -864,7 +864,7 @@ void *purge_databases(void *args)
 
        CtdlFillSystemContext(&purgerCC, "purger");
        citthread_setspecific(MyConKey, (void *)&purgerCC );
-       CtdlLogPrintf(CTDL_DEBUG, "Auto-purger_thread() initializing\n");
+       syslog(LOG_DEBUG, "Auto-purger_thread() initializing\n");
 
         while (!CtdlThreadCheckStop()) {
                 /* Do the auto-purge if the current hour equals the purge hour,
@@ -882,64 +882,64 @@ void *purge_databases(void *args)
                 }
 
 
-                CtdlLogPrintf(CTDL_INFO, "Auto-purger: starting.\n");
+                syslog(LOG_INFO, "Auto-purger: starting.\n");
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUsers();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d users.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d users.\n", retval);
                }
                
                if (!CtdlThreadCheckStop())
                {
                        PurgeMessages();
-                       CtdlLogPrintf(CTDL_NOTICE, "Expired %d messages.\n", messages_purged);
+                       syslog(LOG_NOTICE, "Expired %d messages.\n", messages_purged);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeRooms();
-                       CtdlLogPrintf(CTDL_NOTICE, "Expired %d rooms.\n", retval);
+                       syslog(LOG_NOTICE, "Expired %d rooms.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeVisits();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d visits.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d visits.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUseTable();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d entries from the use table.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d entries from the use table.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeEuidIndexTable();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d entries from the EUID index.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d entries from the EUID index.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeStaleOpenIDassociations();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d stale OpenID associations.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d stale OpenID associations.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = TDAP_ProcessAdjRefCountQueue();
-                       CtdlLogPrintf(CTDL_NOTICE, "Processed %d message reference count adjustments.\n", retval);
+                       syslog(LOG_NOTICE, "Processed %d message reference count adjustments.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
-                       CtdlLogPrintf(CTDL_INFO, "Auto-purger: finished.\n");
+                       syslog(LOG_INFO, "Auto-purger: finished.\n");
                        last_purge = now;       /* So we don't do it again soon */
                        force_purge_now = 0;
                }
                else
-                       CtdlLogPrintf(CTDL_INFO, "Auto-purger: STOPPED.\n");
+                       syslog(LOG_INFO, "Auto-purger: STOPPED.\n");
 
         }
        CtdlClearSystemContext();
index 3e80ef4d775e628f5c977928d8b4652c79ceaf7e..4707abf991b60d022c6909edfeaadf4f3d92b660 100644 (file)
@@ -123,7 +123,7 @@ StrBuf** GetNotifyHosts(void)
                pchs = ChrPtr(Host);
                pche = strchr(pchs, ':');
                if (pche == NULL) {
-                       CtdlLogPrintf(CTDL_ERR, 
+                       syslog(LOG_ERR, 
                                      __FILE__": filename not found in %s.\n", 
                                      pchs);
                        continue;
@@ -178,12 +178,12 @@ void do_extnotify_queue(void)
        /*
         * Go ahead and run the queue
         */
-       CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: processing notify queue\n");
+       syslog(LOG_DEBUG, "serv_extnotify: processing notify queue\n");
     
        memset(&Ctx, 0, sizeof(NotifyContext));
        Ctx.NotifyHostList = GetNotifyHosts();
        if (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
+               syslog(LOG_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
                CtdlClearSystemContext();
                return;
        }
@@ -213,7 +213,7 @@ void do_extnotify_queue(void)
                DeleteHash(&Ctx.NotifyErrors);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: queue run completed\n");
+       syslog(LOG_DEBUG, "serv_extnotify: queue run completed\n");
        doing_queue = 0;
 }
 
@@ -254,7 +254,7 @@ void process_notify(long NotifyMsgnum, void *usrdata)
            ((strncasecmp(configMsg, "none", 4) == 0) &&
             IsEmptyStr(config.c_pager_program) && 
             IsEmptyStr(config.c_funambol_host))) {
-               CtdlLogPrintf(CTDL_DEBUG, "No external notifiers configured on system/user");
+               syslog(LOG_DEBUG, "No external notifiers configured on system/user");
                goto nuke;
        }
 
@@ -344,7 +344,7 @@ void extNotify_getPrefs(long configMsgNum, char *configMsg)
        // Do a simple string search to see if 'funambol' is selected as the
        // type. This string would be at the very top of the message contents.
        if (configMsgNum == -1) {
-               CtdlLogPrintf(CTDL_ERR, "extNotify_isAllowedByPrefs was passed a non-existant config message id\n");
+               syslog(LOG_ERR, "extNotify_isAllowedByPrefs was passed a non-existant config message id\n");
                return;
        }
        prefMsg = CtdlFetchMessage(configMsgNum, 1);
@@ -383,7 +383,7 @@ long extNotify_getConfigMessage(char *username) {
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        } else {
-               CtdlLogPrintf(CTDL_DEBUG, "extNotify_getConfigMessage: No config messages found\n");
+               syslog(LOG_DEBUG, "extNotify_getConfigMessage: No config messages found\n");
                return -1;      /* No messages at all?  No further action. */
        }
        for (a = 0; a < num_msgs; ++a) {
index d3315b0033e761dff2eaa9ec6b39083db2902255..4985700adc7055b63e1a68969e6ca8abbad6f099 100644 (file)
@@ -73,7 +73,7 @@ int notify_http_server(char *remoteurl,
 
        curl = curl_easy_init();
        if (!curl) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                return 1;
        }
 
@@ -128,7 +128,7 @@ int notify_http_server(char *remoteurl,
                        snprintf(buf, SIZ, 
                                 "Cannot load template file %s [%s]won't send notification\r\n", 
                                 file_funambol_msg, strerror(errno));
-                       CtdlLogPrintf(CTDL_ERR, buf);
+                       syslog(LOG_ERR, buf);
 
                        CtdlAideMessage(buf, "External notifier unable to find message template!");
                        goto free;
@@ -153,7 +153,7 @@ int notify_http_server(char *remoteurl,
                        snprintf(buf, SIZ, 
                                 "Cannot load template file %s; won't send notification\r\n", 
                                 file_funambol_msg);
-                       CtdlLogPrintf(CTDL_ERR, buf);
+                       syslog(LOG_ERR, buf);
 
                        CtdlAideMessage(buf, "External notifier unable to load message template!");
                        goto free;
@@ -193,7 +193,7 @@ int notify_http_server(char *remoteurl,
        if (res) {
                StrBuf *ErrMsg;
 
-               CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_ALERT, "libcurl error %d: %s\n", res, errmsg);
                ErrMsg = NewStrBufPlain(HKEY("Error sending your Notification\n"));
                StrBufAppendPrintf(ErrMsg, "\nlibcurl error %d: %s\n", res, errmsg);
                StrBufAppendBufPlain(ErrMsg, curl_errbuf, -1, 0);
@@ -213,7 +213,7 @@ int notify_http_server(char *remoteurl,
                ExtNotify_PutErrorMessage(Ctx, ErrMsg);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Funambol notified\n");
+       syslog(LOG_DEBUG, "Funambol notified\n");
 free:
        curl_slist_free_all (headers);
        curl_easy_cleanup(curl);
index 44f40a45c58915a2b1748f696c0585b57b949f17..1979d48d3c53f957ebabfd38c16bfdb6b9a7c8df 100644 (file)
@@ -159,7 +159,7 @@ void noise_word_cleanup(void)
        int i;
        noise_word *cur, *next;
        
-       CtdlLogPrintf(CTDL_INFO, "Cleaning up fulltext noise words.\n");
+       syslog(LOG_INFO, "Cleaning up fulltext noise words.\n");
        
        for (i = 0 ; i < 26 ; i++)
        {
@@ -236,7 +236,7 @@ void wordbreaker(const char *text, int *num_tokens, int **tokens) {
                        /* extract the word */
                        word_len = word_end - word_start;
                        if (word_len >= sizeof word) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Invalid word length: %d\n", word_len);
+                               syslog(LOG_DEBUG, "Invalid word length: %d\n", word_len);
                                safestrncpy(word, word_start, sizeof word);
                                word[(sizeof word) - 1] = 0;
                        }
index 88064ad503dd29bc5e1aa9bfc3f35312f61c21de..f7861ad03ab16caa14651adf28b72de8000c543d 100644 (file)
@@ -93,7 +93,7 @@ void ft_flush_cache(void) {
 
        for (i=0; i<65536; ++i) {
                if ((time(NULL) - last_update) >= 10) {
-                       CtdlLogPrintf(CTDL_INFO,
+                       syslog(LOG_INFO,
                                "Flushing index cache to disk (%d%% complete)\n",
                                (i * 100 / 65536)
                        );
@@ -107,7 +107,7 @@ void ft_flush_cache(void) {
                        ftc_msgs[i] = NULL;
                }
        }
-       CtdlLogPrintf(CTDL_INFO, "Flushed index cache to disk (100%% complete)\n");
+       syslog(LOG_INFO, "Flushed index cache to disk (100%% complete)\n");
 }
 
 
@@ -126,17 +126,17 @@ void ft_index_message(long msgnum, int op) {
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ft_index_message() could not load msg %ld\n", msgnum);
+               syslog(LOG_ERR, "ft_index_message() could not load msg %ld\n", msgnum);
                return;
        }
 
        if (msg->cm_fields['1'] != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "ft_index_message() excluded msg %ld\n", msgnum);
+               syslog(LOG_DEBUG, "ft_index_message() excluded msg %ld\n", msgnum);
                CtdlFreeMessage(msg);
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "ft_index_message() %s msg %ld\n",
+       syslog(LOG_DEBUG, "ft_index_message() %s msg %ld\n",
                (op ? "adding" : "removing") , msgnum
        );
 
@@ -148,12 +148,12 @@ void ft_index_message(long msgnum, int op) {
        CtdlFreeMessage(msg);
        msgtext = CC->redirect_buffer;
        CC->redirect_buffer = NULL;
-       CtdlLogPrintf(CTDL_DEBUG, "Wordbreaking message %ld...\n", msgnum);
+       syslog(LOG_DEBUG, "Wordbreaking message %ld...\n", msgnum);
        txt = SmashStrBuf(&msgtext);
        wordbreaker(txt, &num_tokens, &tokens);
        free(txt);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Indexing message %ld [%d tokens]\n", msgnum, num_tokens);
+       syslog(LOG_DEBUG, "Indexing message %ld [%d tokens]\n", msgnum, num_tokens);
        if (num_tokens > 0) {
                for (i=0; i<num_tokens; ++i) {
 
@@ -199,7 +199,7 @@ void ft_index_message(long msgnum, int op) {
                                }
                        }
                        else {
-                               CtdlLogPrintf(CTDL_ALERT, "Invalid token %d !!\n", tok);
+                               syslog(LOG_ALERT, "Invalid token %d !!\n", tok);
                        }
                }
 
@@ -277,7 +277,7 @@ void do_fulltext_indexing(void) {
        }
        
        run_time = time(NULL);
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() started (%ld)\n", run_time);
+       syslog(LOG_DEBUG, "do_fulltext_indexing() started (%ld)\n", run_time);
        
        /*
         * If we've switched wordbreaker modules, burn the index and start
@@ -285,9 +285,9 @@ void do_fulltext_indexing(void) {
         */
        begin_critical_section(S_CONTROL);
        if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
-               CtdlLogPrintf(CTDL_DEBUG, "wb ver on disk = %d, code ver = %d\n",
+               syslog(LOG_DEBUG, "wb ver on disk = %d, code ver = %d\n",
                        CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID);
-               CtdlLogPrintf(CTDL_INFO, "(re)initializing full text index\n");
+               syslog(LOG_INFO, "(re)initializing full text index\n");
                cdb_trunc(CDB_FULLTEXT);
                CitControl.MMfulltext = 0L;
                put_control();
@@ -314,7 +314,7 @@ void do_fulltext_indexing(void) {
                /* Here it is ... do each message! */
                for (i=0; i<ft_num_msgs; ++i) {
                        if (time(NULL) != last_progress) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Indexed %d of %d messages (%d%%)\n",
                                                i, ft_num_msgs,
                                                ((i*100) / ft_num_msgs)
@@ -325,14 +325,14 @@ void do_fulltext_indexing(void) {
 
                        /* Check to see if we need to quit early */
                        if (CtdlThreadCheckStop()) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Indexer quitting early\n");
+                               syslog(LOG_DEBUG, "Indexer quitting early\n");
                                ft_newhighest = ft_newmsgs[i];
                                break;
                        }
 
                        /* Check to see if we have to maybe flush to disk */
                        if (i >= FT_MAX_CACHE) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Time to flush.\n");
+                               syslog(LOG_DEBUG, "Time to flush.\n");
                                ft_newhighest = ft_newmsgs[i];
                                break;
                        }
@@ -349,7 +349,7 @@ void do_fulltext_indexing(void) {
        if (CtdlThreadCheckStop())
                return;
        
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
+       syslog(LOG_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
                
        /* Save our place so we don't have to do this again */
        ft_flush_cache();
@@ -360,7 +360,7 @@ void do_fulltext_indexing(void) {
        end_critical_section(S_CONTROL);
        last_index = time(NULL);
 
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() finished\n");
+       syslog(LOG_DEBUG, "do_fulltext_indexing() finished\n");
        return;
 }
 
@@ -373,14 +373,14 @@ void *indexer_thread(void *arg) {
 
        CtdlFillSystemContext(&indexerCC, "indexer");
        citthread_setspecific(MyConKey, (void *)&indexerCC );
-       CtdlLogPrintf(CTDL_DEBUG, "indexer_thread() initializing\n");
+       syslog(LOG_DEBUG, "indexer_thread() initializing\n");
 
        while (!CtdlThreadCheckStop()) {
                do_fulltext_indexing();
                CtdlThreadSleep(300);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "indexer_thread() exiting\n");
+       syslog(LOG_DEBUG, "indexer_thread() exiting\n");
        CtdlClearSystemContext();
        return NULL;
 }
index 86102bf8ed9a2f4ce506ffd7e702cf48b84acac5..fa6cc0c8492ed57c20fca25af0385110b9ecce06 100644 (file)
@@ -240,7 +240,7 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
                text_size = 0;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, 
+       syslog(LOG_DEBUG, 
                "RFC822: headers=" SIZE_T_FMT 
                ", text=" SIZE_T_FMT
                ", total=" SIZE_T_FMT "\n",
@@ -288,7 +288,7 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
        char *desired_section;
 
        desired_section = (char *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "imap_load_part() looking for %s, found %s\n",
+       syslog(LOG_DEBUG, "imap_load_part() looking for %s, found %s\n",
                desired_section,
                partnum
        );
@@ -671,7 +671,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
        if (strchr(ChrPtr(section), '[') != NULL) {
                StrBufStripAllBut(section, '[', ']');
        }
-       CtdlLogPrintf(CTDL_DEBUG, "Section is: [%s]\n", 
+       syslog(LOG_DEBUG, "Section is: [%s]\n", 
              (StrLength(section) == 0) ? "(empty)" : ChrPtr(section)
        );
 
@@ -705,7 +705,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
                is_partial = 1;
        }
        if ( (is_partial == 1) && (StrLength(partial) > 0) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "Partial is <%s>\n", ChrPtr(partial));
+               syslog(LOG_DEBUG, "Partial is <%s>\n", ChrPtr(partial));
        }
 
        if (Imap->cached_body == NULL) {
@@ -1133,17 +1133,17 @@ void imap_do_fetch(citimap_command *Cmd) {
 /* debug output the parsed vector */
        {
                int i;
-               CtdlLogPrintf(CTDL_DEBUG, "----- %ld params \n",
+               syslog(LOG_DEBUG, "----- %ld params \n",
                              Cmd->num_parms);
 
        for (i=0; i < Cmd->num_parms; i++) {
                if (Cmd->Params[i].len != strlen(Cmd->Params[i].Key))
-                       CtdlLogPrintf(CTDL_DEBUG, "*********** %ld != %ld : %s\n",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s\n",
                                      Cmd->Params[i].len, 
                                      strlen(Cmd->Params[i].Key),
                                      Cmd->Params[i].Key);
                else
-                       CtdlLogPrintf(CTDL_DEBUG, "%ld : %s\n",
+                       syslog(LOG_DEBUG, "%ld : %s\n",
                                      Cmd->Params[i].len, 
                                      Cmd->Params[i].Key);
        }}
@@ -1468,7 +1468,7 @@ void imap_uidfetch(int num_parms, ConstStr *Params) {
 
        MakeStringOf(Cmd.CmdBuf, 4);
 #if 0
-       CtdlLogPrintf(CTDL_DEBUG, "-------%s--------\n", ChrPtr(Cmd.CmdBuf));
+       syslog(LOG_DEBUG, "-------%s--------\n", ChrPtr(Cmd.CmdBuf));
 #endif
        num_items = imap_extract_data_items(&Cmd);
        if (num_items < 1) {
index 015ee1cd3d9e21e4b19e0b2be8970b96c5898d5a..465c6ea4002a75f3121ce5c0c9c90d78ed1285f7 100644 (file)
@@ -377,7 +377,7 @@ void imap_list(int num_parms, ConstStr *Params)
                                          &Params[i], 
                                          1);
 
-                       CtdlLogPrintf(9, "evaluating <%s>\n", Params[i].Key);
+                       syslog(LOG_DEBUG, "evaluating <%s>\n", Params[i].Key);
 
                        if (!strcasecmp(Params[i].Key, "SUBSCRIBED")) {
                                ImapFilter.return_subscribed = 1;
index d62f487fa635ecb993f31f7ff553d355b20ab419..14cc8afa95e3ecbadd6c3c4aa162c59ab1c13343 100644 (file)
@@ -355,10 +355,10 @@ void imap_append(int num_parms, ConstStr *Params) {
        client_getln(dummy, sizeof dummy);
 
        /* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */
-       CtdlLogPrintf(CTDL_DEBUG, "Converting CRLF to LF\n");
+       syslog(LOG_DEBUG, "Converting CRLF to LF\n");
        StrBufToUnixLF(Imap->TransmittedMessage);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Converting message format\n");
+       syslog(LOG_DEBUG, "Converting message format\n");
        msg = convert_internet_message_buf(&Imap->TransmittedMessage);
 
        ret = imap_grabroom(roomname, Params[2].Key, 1);
index 0af9406d4860b2366cbd2ca557712434479b6614..28fb95948eca6528f339ecb46da41449b876f36c 100644 (file)
@@ -225,7 +225,7 @@ static char* toimap(char* destp, char* destend, char* src)
 
        *destp = 0;
        string_init(&dest, destp, destend-destp);
-       /* CtdlLogPrintf(CTDL_DEBUG, "toimap %s\r\n", src); */
+       /* syslog(LOG_DEBUG, "toimap %s\r\n", src); */
 
        for (;;)
        {
@@ -291,7 +291,7 @@ static char* toimap(char* destp, char* destend, char* src)
 
        if (state == 1)
                utf7_closeb64(&dest, v, i);
-       /* CtdlLogPrintf(CTDL_DEBUG, "    -> %s\r\n", destp); */
+       /* syslog(LOG_DEBUG, "    -> %s\r\n", destp); */
        return string_end(&dest);
 }
 
@@ -309,7 +309,7 @@ static char* fromimap(char* destp, char* destend, const char* src)
 
        *destp = 0;
        string_init(&dest, destp, destend-destp);
-       /* CtdlLogPrintf(CTDL_DEBUG, "fromimap %s\r\n", src); */
+       /* syslog(LOG_DEBUG, "fromimap %s\r\n", src); */
 
        do {
                c = *p++;
@@ -367,7 +367,7 @@ static char* fromimap(char* destp, char* destend, const char* src)
                        }
        } while (c != '\0');
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "      -> %s\r\n", destp); */
+       /* syslog(LOG_DEBUG, "      -> %s\r\n", destp); */
        return string_end(&dest);
 }
 
@@ -680,7 +680,7 @@ int imap_roomname(char *rbuf, int bufsize, const char *foldername)
        ret = (0 | IR_MAILBOX);
 
 exit:
-       CtdlLogPrintf(CTDL_DEBUG, "(That translates to \"%s\")\n", rbuf);
+       syslog(LOG_DEBUG, "(That translates to \"%s\")\n", rbuf);
        return(ret);
 }
 
index 798c25e5fc1fd3047fa8a70c3acf9d39ec12bf32..21f71a2b0c5395f69947b68836908d5734ceea00 100644 (file)
@@ -111,33 +111,33 @@ const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params)
        StrBufPlain(Imap->Reply, CKEY(Params[1]));
        StrBufUpCase(Imap->Reply);
 
-       CtdlLogPrintf(CTDL_DEBUG, "---- Looking up [%s] -----", 
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
                      ChrPtr(Imap->Reply));
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Found. \n"); 
+               syslog(LOG_DEBUG, "Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
 
        if (num_parms == 1)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "NOT Found. \n"); 
+               syslog(LOG_DEBUG, "NOT Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return NULL;
        }
        
-       CtdlLogPrintf(CTDL_DEBUG, "---- Looking up [%s] -----", 
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
                      ChrPtr(Imap->Reply));
        StrBufAppendBufPlain(Imap->Reply, CKEY(Params[2]), 0);
        StrBufUpCase(Imap->Reply);
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Found. \n"); 
+               syslog(LOG_DEBUG, "Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "NOT Found. \n"); 
+       syslog(LOG_DEBUG, "NOT Found. \n"); 
        FlushStrBuf(Imap->Reply);
                return NULL;
 }
@@ -306,7 +306,7 @@ void imap_load_msgids(void)
        citimap *Imap = IMAP;
 
        if (Imap->selected == 0) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "imap_load_msgids() can't run; no room selected\n");
                return;
        }
@@ -348,7 +348,7 @@ void imap_rescan_msgids(void)
        int num_recent = 0;
 
        if (Imap->selected == 0) {
-               CtdlLogPrintf(CTDL_ERR, "imap_load_msgids() can't run; no room selected\n");
+               syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected\n");
                return;
        }
 
@@ -368,7 +368,7 @@ void imap_rescan_msgids(void)
        if (cdbfr != NULL) {
                msglist = malloc(cdbfr->len);
                if (msglist == NULL) {
-                       CtdlLogPrintf(CTDL_CRIT, "malloc() failed\n");
+                       syslog(LOG_CRIT, "malloc() failed\n");
                        abort();
                }
                memcpy(msglist, cdbfr->ptr, (size_t)cdbfr->len);
@@ -483,7 +483,7 @@ void imap_cleanup_function(void)
                imap_do_expunge();
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing IMAP cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing IMAP cleanup hook\n");
        imap_free_msgids();
        imap_free_transmitted_message();
 
@@ -503,7 +503,7 @@ void imap_cleanup_function(void)
        FreeStrBuf(&Imap->Reply);
        if (Imap->Cmd.Params != NULL) free(Imap->Cmd.Params);
        free(Imap);
-       CtdlLogPrintf(CTDL_DEBUG, "Finished IMAP cleanup hook\n");
+       syslog(LOG_DEBUG, "Finished IMAP cleanup hook\n");
 }
 
 
@@ -918,7 +918,7 @@ int imap_do_expunge(void)
        long *delmsgs = NULL;
        int num_delmsgs = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "imap_do_expunge() called\n");
+       syslog(LOG_DEBUG, "imap_do_expunge() called\n");
        if (Imap->selected == 0) {
                return (0);
        }
@@ -941,7 +941,7 @@ int imap_do_expunge(void)
                imap_rescan_msgids();
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Expunged %d messages from <%s>\n", num_expunged, CC->room.QRname);
+       syslog(LOG_DEBUG, "Expunged %d messages from <%s>\n", num_expunged, CC->room.QRname);
        return (num_expunged);
 }
 
@@ -1036,14 +1036,14 @@ void imap_create(int num_parms, ConstStr *Params)
 
        if (strchr(Params[2].Key, '\\') != NULL) {
                IReply("NO Invalid character in folder name");
-               CtdlLogPrintf(CTDL_DEBUG, "invalid character in folder name\n");
+               syslog(LOG_DEBUG, "invalid character in folder name\n");
                return;
        }
 
        ret = imap_roomname(roomname, sizeof roomname, Params[2].Key);
        if (ret < 0) {
                IReply("NO Invalid mailbox name or location");
-               CtdlLogPrintf(CTDL_DEBUG, "invalid mailbox name or location\n");
+               syslog(LOG_DEBUG, "invalid mailbox name or location\n");
                return;
        }
        floornum = (ret & 0x00ff);      /* lower 8 bits = floor number */
@@ -1052,7 +1052,7 @@ void imap_create(int num_parms, ConstStr *Params)
        if (flags & IR_MAILBOX) {
                if (strncasecmp(Params[2].Key, "INBOX/", 6)) {
                        IReply("NO Personal folders must be created under INBOX");
-                       CtdlLogPrintf(CTDL_DEBUG, "not subordinate to inbox\n");
+                       syslog(LOG_DEBUG, "not subordinate to inbox\n");
                        return;
                }
        }
@@ -1065,7 +1065,7 @@ void imap_create(int num_parms, ConstStr *Params)
                newroomview = VIEW_BBS;
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
+       syslog(LOG_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
                roomname, floornum, newroomtype);
 
        ret = CtdlCreateRoom(roomname, newroomtype, "", floornum, 1, 0, newroomview);
@@ -1087,7 +1087,7 @@ void imap_create(int num_parms, ConstStr *Params)
                CtdlAideMessage(notification_message, "Room Creation Message");
                free(notification_message);
        }
-       CtdlLogPrintf(CTDL_DEBUG, "imap_create() completed\n");
+       syslog(LOG_DEBUG, "imap_create() completed\n");
 }
 
 
@@ -1450,7 +1450,7 @@ void imap_rename(int num_parms, ConstStr *Params)
                                           irl->irl_newfloor);
                        if (r != crr_ok) {
                                /* FIXME handle error returns better */
-                               CtdlLogPrintf(CTDL_ERR, "CtdlRenameRoom() error %d\n", r);
+                               syslog(LOG_ERR, "CtdlRenameRoom() error %d\n", r);
                        }
                        irlp = irl;
                        irl = irl->next;
@@ -1492,23 +1492,23 @@ void imap_command_loop(void)
                FlushStrBuf(Imap->Cmd.CmdBuf);
 
        if (CtdlClientGetLine(Imap->Cmd.CmdBuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\r\n");
                CC->kill_me = 1;
                return;
        }
 
        if (Imap->authstate == imap_as_expecting_password) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: <password>\n");
+               syslog(LOG_INFO, "IMAP: <password>\n");
        }
        else if (Imap->authstate == imap_as_expecting_plainauth) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: <plain_auth>\n");
+               syslog(LOG_INFO, "IMAP: <plain_auth>\n");
        }
        else if ((Imap->authstate == imap_as_expecting_multilineusername) || 
                 cbmstrcasestr(ChrPtr(Imap->Cmd.CmdBuf), " LOGIN ")) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: LOGIN...\n");
+               syslog(LOG_INFO, "IMAP: LOGIN...\n");
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: %s\n", ChrPtr(Imap->Cmd.CmdBuf));
+               syslog(LOG_INFO, "IMAP: %s\n", ChrPtr(Imap->Cmd.CmdBuf));
        }
 
        pchs = ChrPtr(Imap->Cmd.CmdBuf);
@@ -1564,17 +1564,17 @@ void imap_command_loop(void)
 /* debug output the parsed vector */
        {
                int i;
-               CtdlLogPrintf(CTDL_DEBUG, "----- %ld params \n",
+               syslog(LOG_DEBUG, "----- %ld params \n",
                              Imap->Cmd.num_parms);
 
        for (i=0; i < Imap->Cmd.num_parms; i++) {
                if (Imap->Cmd.Params[i].len != strlen(Imap->Cmd.Params[i].Key))
-                       CtdlLogPrintf(CTDL_DEBUG, "*********** %ld != %ld : %s\n",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s\n",
                                      Imap->Cmd.Params[i].len, 
                                      strlen(Imap->Cmd.Params[i].Key),
                                      Imap->Cmd.Params[i].Key);
                else
-                       CtdlLogPrintf(CTDL_DEBUG, "%ld : %s\n",
+                       syslog(LOG_DEBUG, "%ld : %s\n",
                                      Imap->Cmd.Params[i].len, 
                                      Imap->Cmd.Params[i].Key);
        }}
@@ -1627,7 +1627,7 @@ BAIL:
 
        gettimeofday(&tv2, NULL);
        total_time = (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000));
-       CtdlLogPrintf(CTDL_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
+       syslog(LOG_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
                (total_time / 1000000),
                (total_time % 1000000)
        );
index 15cd194ebfef14002dbfb9aa817789690815bb02..3ad989ab579a4da38e1a20db5059614ca18525a2 100644 (file)
@@ -515,7 +515,7 @@ void do_confirm(char *room, char *token) {
         */
        if (success) {
                cprintf("%d %d operation(s) confirmed.\n", CIT_OK, success);
-               CtdlLogPrintf(CTDL_NOTICE, 
+               syslog(LOG_NOTICE, 
                        "Mailing list: %s %ssubscribed to %s with token %s\n", 
                        email, 
                        (!IsEmptyStr(address_to_unsubscribe)) ? "un" : "", 
index f1523d73bf793ab1ebdd9a73c49056ee78e41ea2..0bdc0f1001fe03873b7dbbd0e6b7593d3c742720 100644 (file)
@@ -336,7 +336,7 @@ void cmd_mgsve_starttls(void)
 void cmd_mgsve_logout(struct sdm_userdata *u)
 {
        cprintf("OK\r\n");
-       CtdlLogPrintf(CTDL_NOTICE, "MgSve bye.");
+       syslog(LOG_NOTICE, "MgSve bye.");
        CC->kill_me = 1;
 }
 
@@ -585,11 +585,11 @@ void managesieve_command_loop(void) {
                length = strlen(parms[0]);
        }
        if (length < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "MANAGESIEVE: %s\n", cmdbuf);
+       syslog(LOG_INFO, "MANAGESIEVE: %s\n", cmdbuf);
        if ((length>= 12) && (!strncasecmp(parms[0], "AUTHENTICATE", 12))){
                cmd_mgsve_auth(num_parms, parms, &u);
        }
@@ -634,7 +634,7 @@ void managesieve_command_loop(void) {
        }
        else {
                cprintf("No Invalid access or command.\r\n");
-               CtdlLogPrintf(CTDL_INFO, "illegal Managesieve command: %s", parms[0]);
+               syslog(LOG_INFO, "illegal Managesieve command: %s", parms[0]);
                CC->kill_me = 1;
        }
 
@@ -650,7 +650,7 @@ void managesieve_cleanup_function(void) {
        /* Don't do this stuff if this is not a managesieve session! */
        if (CC->h_command_function != managesieve_command_loop) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing managesieve cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing managesieve cleanup hook\n");
        free(MGSVE);
 }
 
index e71801c3bd003706d051549ed56e3aef6e5b5358..31d2eceea2e41140c3aa325c73e17e927a1de958 100644 (file)
@@ -181,9 +181,9 @@ void migr_export_rooms(void) {
         * exporting the message multiple times.)
         */
        snprintf(cmd, sizeof cmd, "sort <%s >%s", migr_tempfilename1, migr_tempfilename2);
-       if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
+       if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
        snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1);
-       if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
+       if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
 }
 
 
@@ -340,7 +340,7 @@ void migr_export_messages(void) {
        Ctx = CC;
        migr_global_message_list = fopen(migr_tempfilename1, "r");
        if (migr_global_message_list != NULL) {
-               CtdlLogPrintf(CTDL_INFO, "Opened %s\n", migr_tempfilename1);
+               syslog(LOG_INFO, "Opened %s\n", migr_tempfilename1);
                while ((Ctx->kill_me != 1) && 
                       (fgets(buf, sizeof(buf), migr_global_message_list) != NULL)) {
                        msgnum = atol(buf);
@@ -352,9 +352,9 @@ void migr_export_messages(void) {
                fclose(migr_global_message_list);
        }
        if (Ctx->kill_me != 1)
-               CtdlLogPrintf(CTDL_INFO, "Exported %d messages.\n", count);
+               syslog(LOG_INFO, "Exported %d messages.\n", count);
        else
-               CtdlLogPrintf(CTDL_ERR, "Export aborted due to client disconnect! \n");
+               syslog(LOG_ERR, "Export aborted due to client disconnect! \n");
 
        migr_export_message(-1L);       /* This frees the encoding buffer */
 }
@@ -547,7 +547,7 @@ void migr_xml_start(void *data, const char *el, const char **attr) {
        }
 
        if (citadel_migrate_data != 1) {
-               CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
+               syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
                return;
        }
 
@@ -592,7 +592,7 @@ void migr_xml_end(void *data, const char *el) {
        }
 
        if (citadel_migrate_data != 1) {
-               CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
+               syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
                return;
        }
 
@@ -601,14 +601,14 @@ void migr_xml_end(void *data, const char *el) {
                migr_chardata_len = 0;
        }
 
-       // CtdlLogPrintf(CTDL_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
+       // syslog(LOG_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
 
        /*** CONFIG ***/
 
        if (!strcasecmp(el, "config")) {
                config.c_enable_fulltext = 0;   /* always disable */
                put_config();
-               CtdlLogPrintf(CTDL_INFO, "Completed import of server configuration\n");
+               syslog(LOG_INFO, "Completed import of server configuration\n");
        }
 
        else if (!strcasecmp(el, "c_nodename"))                 safestrncpy(config.c_nodename, migr_chardata, sizeof config.c_nodename);
@@ -697,7 +697,7 @@ void migr_xml_end(void *data, const char *el) {
        else if (!strcasecmp(el, "control")) {
                CitControl.MMfulltext = (-1L);  /* always flush */
                put_control();
-               CtdlLogPrintf(CTDL_INFO, "Completed import of control record\n");
+               syslog(LOG_INFO, "Completed import of control record\n");
        }
 
        /*** USER ***/
@@ -716,7 +716,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "user")) {
                CtdlPutUser(&usbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported user: %s\n", usbuf.fullname);
+               syslog(LOG_INFO, "Imported user: %s\n", usbuf.fullname);
        }
 
        /*** OPENID ***/
@@ -733,7 +733,7 @@ void migr_xml_end(void *data, const char *el) {
                memcpy(&oid_data[sizeof(long)], openid_url, strlen(openid_url) + 1);
                cdb_store(CDB_OPENID, openid_url, strlen(openid_url), oid_data, oid_data_len);
                free(oid_data);
-               CtdlLogPrintf(CTDL_INFO, "Imported OpenID: %s (%ld)\n", openid_url, openid_usernum);
+               syslog(LOG_INFO, "Imported OpenID: %s (%ld)\n", openid_url, openid_usernum);
        }
 
        /*** ROOM ***/
@@ -757,7 +757,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "room")) {
                CtdlPutRoom(&qrbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported room: %s\n", qrbuf.QRname);
+               syslog(LOG_INFO, "Imported room: %s\n", qrbuf.QRname);
        }
 
        /*** ROOM MESSAGE POINTERS ***/
@@ -770,7 +770,7 @@ void migr_xml_end(void *data, const char *el) {
                        msglist_alloc = 1000;
                        msglist = malloc(sizeof(long) * msglist_alloc);
 
-                       CtdlLogPrintf(CTDL_DEBUG, "Message list for: %s\n", FRname);
+                       syslog(LOG_DEBUG, "Message list for: %s\n", FRname);
 
                        ptr = migr_chardata;
                        while (*ptr != 0) {
@@ -798,7 +798,7 @@ void migr_xml_end(void *data, const char *el) {
                        free(msglist);
                        msglist = NULL;
                        msglist_alloc = 0;
-                       CtdlLogPrintf(CTDL_DEBUG, "Imported %d messages.\n", msgcount);
+                       syslog(LOG_DEBUG, "Imported %d messages.\n", msgcount);
                        if (CtdlThreadCheckStop()) {
                                return;
                }
@@ -815,7 +815,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "floor")) {
                CtdlPutFloor(&flbuf, floornum);
-               CtdlLogPrintf(CTDL_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
+               syslog(LOG_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
        }
 
        /*** VISITS ***/
@@ -837,7 +837,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "visit")) {
                put_visit(&vbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported visit: %ld/%ld/%ld\n", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
+               syslog(LOG_INFO, "Imported visit: %ld/%ld/%ld\n", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
        }
 
        /*** MESSAGES ***/
@@ -857,7 +857,7 @@ void migr_xml_end(void *data, const char *el) {
                free(decoded_msg);
                decoded_msg = NULL;
                PutMetaData(&smi);
-               CtdlLogPrintf(CTDL_INFO, "Imported message #%ld, size=%ld, refcount=%d, content-type: %s\n",
+               syslog(LOG_INFO, "Imported message #%ld, size=%ld, refcount=%d, content-type: %s\n",
                        import_msgnum, msglen, smi.meta_refcount, smi.meta_content_type);
        }
 
index 075b4578a9616204d3ae5af0497192bc9df386da..c2e7a79e9ea0cd8b6b4a917c828ca11c985f280d 100644 (file)
@@ -221,7 +221,7 @@ int network_usetable(struct CtdlMessage *msg) {
        cdbut = cdb_fetch(CDB_USETABLE, msgid, strlen(msgid));
        if (cdbut != NULL) {
                cdb_free(cdbut);
-               CtdlLogPrintf(CTDL_DEBUG, "network_usetable() : we already have %s\n", msgid);
+               syslog(LOG_DEBUG, "network_usetable() : we already have %s\n", msgid);
                return(1);
        }
 
@@ -323,7 +323,7 @@ int is_valid_node(char *nexthop, char *secret, char *node) {
         * First try the neighbor nodes
         */
        if (working_ignetcfg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "working_ignetcfg is NULL!\n");
+               syslog(LOG_ERR, "working_ignetcfg is NULL!\n");
                if (nexthop != NULL) {
                        strcpy(nexthop, "");
                }
@@ -371,7 +371,7 @@ int is_valid_node(char *nexthop, char *secret, char *node) {
        /*
         * If we get to this point, the supplied node name is bogus.
         */
-       CtdlLogPrintf(CTDL_ERR, "Invalid node name <%s>\n", node);
+       syslog(LOG_ERR, "Invalid node name <%s>\n", node);
        return(-1);
 }
 
@@ -562,7 +562,7 @@ void network_deliver_digest(SpoolControl *sc) {
        recps = malloc(recps_len);
 
        if (recps == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
+               syslog(LOG_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
                abort();
        }
 
@@ -617,7 +617,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
        recps = malloc(recps_len);
 
        if (recps == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
+               syslog(LOG_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
                abort();
        }
 
@@ -879,24 +879,24 @@ void network_spool_msg(long msgnum, void *userdata) {
 
                        /* Check for valid node name */
                        if (is_valid_node(NULL, NULL, mptr->remote_nodename) != 0) {
-                               CtdlLogPrintf(CTDL_ERR, "Invalid node <%s>\n", mptr->remote_nodename);
+                               syslog(LOG_ERR, "Invalid node <%s>\n", mptr->remote_nodename);
                                send = 0;
                        }
 
                        /* Check for split horizon */
-                       CtdlLogPrintf(CTDL_DEBUG, "Path is %s\n", msg->cm_fields['P']);
+                       syslog(LOG_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'], i, '!', sizeof buf);
-                               CtdlLogPrintf(CTDL_DEBUG, "Compare <%s> to <%s>\n",
+                               syslog(LOG_DEBUG, "Compare <%s> to <%s>\n",
                                        buf, mptr->remote_nodename) ;
                                if (!strcasecmp(buf, mptr->remote_nodename)) {
                                        send = 0;
-                                       CtdlLogPrintf(CTDL_DEBUG, "Not sending to %s\n",
+                                       syslog(LOG_DEBUG, "Not sending to %s\n",
                                                mptr->remote_nodename);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_DEBUG, "Sending to %s\n", mptr->remote_nodename);
+                                       syslog(LOG_DEBUG, "Sending to %s\n", mptr->remote_nodename);
                                }
                        }
 
@@ -928,7 +928,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                                time(NULL),
                                                rand()
                                        );
-                                       CtdlLogPrintf(CTDL_DEBUG, "Appending to %s\n", filename);
+                                       syslog(LOG_DEBUG, "Appending to %s\n", filename);
                                        fp = fopen(filename, "ab");
                                        if (fp != NULL) {
                                                fwrite(sermsg.ser,
@@ -936,7 +936,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                                fclose(fp);
                                        }
                                        else {
-                                               CtdlLogPrintf(CTDL_ERR, "%s: %s\n", filename, strerror(errno));
+                                               syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
                                        }
        
                                        /* free the serialized version */
@@ -1115,7 +1115,7 @@ int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
        TmpFD = open(tempfilename, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
        Cfg = NewStrBuf();
        if ((TmpFD < 0) || (errno != 0)) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot open %s: %s\n",
+               syslog(LOG_CRIT, "ERROR: cannot open %s: %s\n",
                        filename, strerror(errno));
                free_spoolcontrol_struct(scc);
                unlink(tempfilename);
@@ -1168,7 +1168,7 @@ int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
                        rename(tempfilename, filename);
                }
                else {
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to write %s; [%s]; not enough space on the disk?\n", 
                                      tempfilename, 
                                      strerror(errno));
@@ -1226,7 +1226,7 @@ void network_spoolout_room(char *room_to_spool) {
         * queued for networking and then deleted before it can happen.
         */
        if (CtdlGetRoom(&CC->room, room_to_spool) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
+               syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
                return;
        }
 
@@ -1239,7 +1239,7 @@ void network_spoolout_room(char *room_to_spool) {
                end_critical_section(S_NETCONFIGS);
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "Networking started for <%s>\n", CC->room.QRname);
+       syslog(LOG_INFO, "Networking started for <%s>\n", CC->room.QRname);
 
        /* If there are digest recipients, we have to build a digest */
        if (sc->digestrecps != NULL) {
@@ -1335,7 +1335,7 @@ int network_sync_to(char *target_node) {
        /* Concise cleanup because we know there's only one node in the sc */
        free(sc.ignet_push_shares);
 
-       CtdlLogPrintf(CTDL_NOTICE, "Synchronized %d messages to <%s>\n",
+       syslog(LOG_NOTICE, "Synchronized %d messages to <%s>\n",
                num_spooled, target_node);
        return(num_spooled);
 }
@@ -1454,7 +1454,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        static int serialnum = 0;
        size_t size;
 
-       CtdlLogPrintf(CTDL_DEBUG, "entering network_bounce()\n");
+       syslog(LOG_DEBUG, "entering network_bounce()\n");
 
        if (msg == NULL) return;
 
@@ -1543,7 +1543,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        /* Clean up */
        if (valid != NULL) free_recipients(valid);
        CtdlFreeMessage(msg);
-       CtdlLogPrintf(CTDL_DEBUG, "leaving network_bounce()\n");
+       syslog(LOG_DEBUG, "leaving network_bounce()\n");
 }
 
 
@@ -1567,13 +1567,13 @@ void network_process_buffer(char *buffer, long size) {
        unsigned char firstbyte;
        unsigned char lastbyte;
 
-       CtdlLogPrintf(CTDL_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
+       syslog(LOG_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
 
        /* Validate just a little bit.  First byte should be FF and * last byte should be 00. */
        firstbyte = buffer[0];
        lastbyte = buffer[size-1];
        if ( (firstbyte != 255) || (lastbyte != 0) ) {
-               CtdlLogPrintf(CTDL_ERR, "Corrupt message ignored.  Length=%ld, firstbyte = %d, lastbyte = %d\n",
+               syslog(LOG_ERR, "Corrupt message ignored.  Length=%ld, firstbyte = %d, lastbyte = %d\n",
                        size, firstbyte, lastbyte);
                return;
        }
@@ -1630,14 +1630,14 @@ void network_process_buffer(char *buffer, long size) {
                                        time(NULL),
                                        rand()
                                );
-                               CtdlLogPrintf(CTDL_DEBUG, "Appending to %s\n", filename);
+                               syslog(LOG_DEBUG, "Appending to %s\n", filename);
                                fp = fopen(filename, "ab");
                                if (fp != NULL) {
                                        fwrite(sermsg.ser, sermsg.len, 1, fp);
                                        fclose(fp);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_ERR, "%s: %s\n", filename, strerror(errno));
+                                       syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
                                }
                                free(sermsg.ser);
                                CtdlFreeMessage(msg);
@@ -1688,7 +1688,7 @@ void network_process_buffer(char *buffer, long size) {
                                "Please check the address and try sending the message again.\n");
                        msg = NULL;
                        free_recipients(recp);
-                       CtdlLogPrintf(CTDL_DEBUG, "Bouncing message due to invalid recipient address.\n");
+                       syslog(LOG_DEBUG, "Bouncing message due to invalid recipient address.\n");
                        return;
                }
                strcpy(target_room, "");        /* no target room if mail */
@@ -1757,12 +1757,12 @@ void network_process_file(char *filename) {
 
        fp = fopen(filename, "rb");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
+               syslog(LOG_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
                return;
        }
 
        fseek(fp, 0L, SEEK_END);
-       CtdlLogPrintf(CTDL_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
+       syslog(LOG_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
        rewind(fp);
 
        /* Look for messages in the data stream and break them out */
@@ -1805,11 +1805,11 @@ void network_do_spoolin(void) {
         */
        if (stat(ctdl_netin_dir, &statbuf)) return;
        if (statbuf.st_mtime == last_spoolin_mtime) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: nothing in inbound queue\n");
+               syslog(LOG_DEBUG, "network: nothing in inbound queue\n");
                return;
        }
        last_spoolin_mtime = statbuf.st_mtime;
-       CtdlLogPrintf(CTDL_DEBUG, "network: processing inbound queue\n");
+       syslog(LOG_DEBUG, "network: processing inbound queue\n");
 
        /*
         * Ok, there's something interesting in there, so scan it.
@@ -1865,9 +1865,9 @@ void network_consolidate_spoolout(void) {
                                d->d_name
                        );
        
-                       CtdlLogPrintf(CTDL_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
+                       syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
                        if (network_talking_to(nexthop, NTT_CHECK)) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Currently online with %s - skipping for now\n",
                                        nexthop
                                );
@@ -1949,7 +1949,7 @@ void receive_spool(int *sock, char *remote_nodename) {
 
        if (sock_puts(sock, "NDOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                return;
        }
@@ -1962,11 +1962,11 @@ void receive_spool(int *sock, char *remote_nodename) {
        bytes_received = 0L;
        fp = fopen(tempfilename, "w");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Cannot create %s: %s\n", tempfilename, strerror(errno));
+               syslog(LOG_CRIT, "Cannot create %s: %s\n", tempfilename, strerror(errno));
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Expecting to transfer %d bytes\n", download_len);
+       syslog(LOG_DEBUG, "Expecting to transfer %d bytes\n", download_len);
        while (bytes_received < download_len) {
                /*
                 * If shutting down we can exit here and unlink the temp file.
@@ -1999,7 +1999,7 @@ void receive_spool(int *sock, char *remote_nodename) {
                        plen = extract_int(&buf[4], 0);
                        StrBuf *pbuf = NewStrBuf();
                        if (socket_read_blob(sock, pbuf, plen, CLIENT_TIMEOUT) != plen) {
-                               CtdlLogPrintf(CTDL_INFO, "Short read from peer; aborting.\n");
+                               syslog(LOG_INFO, "Short read from peer; aborting.\n");
                                fclose(fp);
                                unlink(tempfilename);
                                FreeStrBuf(&pbuf);
@@ -2033,13 +2033,13 @@ void receive_spool(int *sock, char *remote_nodename) {
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
+       syslog(LOG_DEBUG, "%s\n", buf);
 
        /*
         * Now move the temp file to its permanent location.
         */
        if (link(tempfilename, permfilename) != 0) {
-               CtdlLogPrintf(CTDL_ALERT, "Could not link %s to %s: %s\n",
+               syslog(LOG_ALERT, "Could not link %s to %s: %s\n",
                        tempfilename, permfilename, strerror(errno)
                );
        }
@@ -2063,7 +2063,7 @@ void transmit_spool(int *sock, char *remote_nodename)
 
        if (sock_puts(sock, "NUOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                return;
        }
@@ -2076,7 +2076,7 @@ void transmit_spool(int *sock, char *remote_nodename)
        fd = open(sfname, O_RDONLY);
        if (fd < 0) {
                if (errno != ENOENT) {
-                       CtdlLogPrintf(CTDL_CRIT, "cannot open %s: %s\n", sfname, strerror(errno));
+                       syslog(LOG_CRIT, "cannot open %s: %s\n", sfname, strerror(errno));
                }
                return;
        }
@@ -2127,10 +2127,10 @@ ABORTUPL:
         * From here on we must complete or messages will get lost
         */
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] == '2') {
-               CtdlLogPrintf(CTDL_DEBUG, "Removing <%s>\n", sfname);
+               syslog(LOG_DEBUG, "Removing <%s>\n", sfname);
                unlink(sfname);
        }
 }
@@ -2149,24 +2149,24 @@ 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);
-       CtdlLogPrintf(CTDL_DEBUG, "network: polling <%s>\n", node);
-       CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port);
+       syslog(LOG_DEBUG, "network: polling <%s>\n", node);
+       syslog(LOG_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port);
 
        sock = sock_connect(host, port);
        if (sock < 0) {
-               CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Could not connect: %s\n", strerror(errno));
                network_talking_to(node, NTT_REMOVE);
                return;
        }
        
-       CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+       syslog(LOG_DEBUG, "Connected!\n");
        CCC->sReadBuf = NewStrBuf();
        CCC->sMigrateBuf = NewStrBuf();
        CCC->sPos = NULL;
 
        /* Read the server greeting */
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
 
        /* Check that the remote is who we think it is and warn the Aide if not */
        extract_token (connected_to, buf, 1, ' ', sizeof connected_to);
@@ -2176,16 +2176,16 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
                        "Connected to node \"%s\" but I was expecting to connect to node \"%s\".",
                        connected_to, node
                );
-               CtdlLogPrintf(CTDL_ERR, "%s\n", err_buf);
+               syslog(LOG_ERR, "%s\n", err_buf);
                CtdlAideMessage(err_buf, "Network error");
        }
        else {
                /* We're talking to the correct node.  Now identify ourselves. */
                snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
-               CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+               syslog(LOG_DEBUG, "<%s\n", buf);
                if (sock_puts(&sock, buf) <0) goto bail;
                if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-               CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+               syslog(LOG_DEBUG, ">%s\n", buf);
                if (buf[0] != '2') {
                        goto bail;
                }
@@ -2224,7 +2224,7 @@ void network_poll_other_citadel_nodes(int full_poll) {
        char spoolfile[256];
 
        if (working_ignetcfg == NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: no neighbor nodes are configured - not polling.\n");
+               syslog(LOG_DEBUG, "network: no neighbor nodes are configured - not polling.\n");
                return;
        }
 
@@ -2267,21 +2267,21 @@ void network_poll_other_citadel_nodes(int full_poll) {
  */
 void create_spool_dirs(void) {
        if ((mkdir(ctdl_spool_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
        if (chown(ctdl_spool_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
        if ((mkdir(ctdl_netin_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
        if (chown(ctdl_netin_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
        if ((mkdir(ctdl_nettmp_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
        if (chown(ctdl_nettmp_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
        if ((mkdir(ctdl_netout_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
        if (chown(ctdl_netout_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
 }
 
 
@@ -2304,7 +2304,7 @@ void network_do_queue(void) {
         */
        if ( (time(NULL) - last_run) < config.c_net_freq ) {
                full_processing = 0;
-               CtdlLogPrintf(CTDL_DEBUG, "Network full processing in %ld seconds.\n",
+               syslog(LOG_DEBUG, "Network full processing in %ld seconds.\n",
                        config.c_net_freq - (time(NULL)- last_run)
                );
        }
@@ -2340,12 +2340,12 @@ void network_do_queue(void) {
         * Go ahead and run the queue
         */
        if (full_processing && !CtdlThreadCheckStop()) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: loading outbound queue\n");
+               syslog(LOG_DEBUG, "network: loading outbound queue\n");
                CtdlForEachRoom(network_queue_room, NULL);
        }
 
        if (rplist != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: running outbound queue\n");
+               syslog(LOG_DEBUG, "network: running outbound queue\n");
                while (rplist != NULL && !CtdlThreadCheckStop()) {
                        char spoolroomname[ROOMNAMELEN];
                        safestrncpy(spoolroomname, rplist->name, sizeof spoolroomname);
@@ -2384,7 +2384,7 @@ void network_do_queue(void) {
 
        network_consolidate_spoolout();
 
-       CtdlLogPrintf(CTDL_DEBUG, "network: queue run completed\n");
+       syslog(LOG_DEBUG, "network: queue run completed\n");
 
        if (full_processing) {
                last_run = time(NULL);
@@ -2421,7 +2421,7 @@ void cmd_netp(char *cmdbuf)
                        "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n",
                        node, CC->cs_host, CC->cs_addr
                );
-               CtdlLogPrintf(CTDL_WARNING, err_buf);
+               syslog(LOG_WARNING, err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;
@@ -2432,21 +2432,21 @@ void cmd_netp(char *cmdbuf)
                        "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n",
                        CC->cs_host, CC->cs_addr, node
                );
-               CtdlLogPrintf(CTDL_WARNING, err_buf);
+               syslog(LOG_WARNING, err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;
        }
 
        if (network_talking_to(node, NTT_CHECK)) {
-               CtdlLogPrintf(CTDL_WARNING, "Duplicate session for network node <%s>", node);
+               syslog(LOG_WARNING, "Duplicate session for network node <%s>", node);
                cprintf("%d Already talking to %s right now\n", ERROR + RESOURCE_BUSY, node);
                return;
        }
 
        safestrncpy(CC->net_node, node, sizeof CC->net_node);
        network_talking_to(node, NTT_ADD);
-       CtdlLogPrintf(CTDL_NOTICE, "Network node <%s> logged in from %s [%s]\n",
+       syslog(LOG_NOTICE, "Network node <%s> logged in from %s [%s]\n",
                CC->net_node, CC->cs_host, CC->cs_addr
        );
        cprintf("%d authenticated as network node '%s'\n", CIT_OK, CC->net_node);
@@ -2462,7 +2462,7 @@ int network_room_handler (struct ctdlroom *room)
 void *ignet_thread(void *arg) {
        struct CitContext ignet_thread_CC;
 
-       CtdlLogPrintf(CTDL_DEBUG, "ignet_thread() initializing\n");
+       syslog(LOG_DEBUG, "ignet_thread() initializing\n");
        CtdlFillSystemContext(&ignet_thread_CC, "IGnet Queue");
        citthread_setspecific(MyConKey, (void *)&ignet_thread_CC);
 
index e1e6b81cc39e60e764fe45f0f693587b1c32d478..db8474b1ace28dd9604369e92143ec002bace775 100644 (file)
@@ -66,7 +66,7 @@ void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp,
 
        if (!strcasecmp(cbtype, "text/vnote")) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Part %s contains a vNote!  Loading...\n", partnum);
+               syslog(LOG_DEBUG, "Part %s contains a vNote!  Loading...\n", partnum);
                if (*v != NULL) {
                        vnote_free(*v);
                }
@@ -118,7 +118,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
                                }
                        }
 
-                       CtdlLogPrintf(9, "UUID of note is: %s\n", uuid);
+                       syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
                        if (!IsEmptyStr(uuid)) {
 
                                if (msg->cm_fields['E'] != NULL) {
@@ -150,7 +150,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
        /* Set the message EUID to the vNote UID */
 
        if (v->uid) if (!IsEmptyStr(v->uid)) {
-               CtdlLogPrintf(9, "UID of vNote is: %s\n", v->uid);
+               syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid);
                if (msg->cm_fields['E'] != NULL) {
                        free(msg->cm_fields['E']);
                }
index aee397cad8565d4411fe76d63e5a9bdecac0ec17..d8fa443fdea8f164b8eaa282afb4ee824cdd4304 100644 (file)
@@ -74,7 +74,7 @@ void openid_cleanup_function(void) {
        struct CitContext *CCC = CC;    /* CachedCitContext - performance boost */
 
        if (CCC->openid_data != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Clearing OpenID session state\n");
+               syslog(LOG_DEBUG, "Clearing OpenID session state\n");
                Free_ctdl_openid((ctdl_openid **) &CCC->openid_data);
        }
 }
@@ -125,11 +125,11 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id)
                cdb_free(cdboi);
 
                if (fetched_usernum == who->usernum) {
-                       CtdlLogPrintf(CTDL_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id));
+                       syslog(LOG_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id));
                        return(0);
                }
                else {
-                       CtdlLogPrintf(CTDL_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id));
+                       syslog(LOG_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id));
                        return(3);
                }
        }
@@ -148,7 +148,7 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id)
        snprintf(buf, sizeof buf, "User <%s> (#%ld) has claimed the OpenID URL %s\n",
                 who->fullname, who->usernum, ChrPtr(claimed_id));
        CtdlAideMessage(buf, "OpenID claim");
-       CtdlLogPrintf(CTDL_INFO, "%s", buf);
+       syslog(LOG_INFO, "%s", buf);
        return(0);
 }
 
@@ -188,7 +188,7 @@ void openid_purge(struct ctdluser *usbuf) {
        HashPos = GetNewHashPos(keys, 0);
        while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value);
+               syslog(LOG_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value);
                cdb_delete(CDB_OPENID, Value, strlen(Value));
                /* note: don't free(Value) -- deleting the hash list will handle this for us */
        }
@@ -421,11 +421,11 @@ int openid_create_user_via_sreg(StrBuf *claimed_id, HashList *sreg_keys)
        if (CC->logged_in) return(3);
        if (!GetHash(sreg_keys, "sreg.nickname", 13, (void *) &desired_name)) return(4);
 
-       CtdlLogPrintf(CTDL_DEBUG, "The desired account name is <%s>\n", desired_name);
+       syslog(LOG_DEBUG, "The desired account name is <%s>\n", desired_name);
 
        len = cutuserkey(desired_name);
        if (!CtdlGetUser(&CC->user, desired_name)) {
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> is already taken by another user.\n", desired_name);
+               syslog(LOG_DEBUG, "<%s> is already taken by another user.\n", desired_name);
                memset(&CC->user, 0, sizeof(struct ctdluser));
                return(5);
        }
@@ -569,7 +569,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf)
 
        curl = curl_easy_init();
        if (!curl) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                return(-1);
        }
 
@@ -598,7 +598,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf)
        }
        res = curl_easy_perform(curl);
        if (res) {
-               CtdlLogPrintf(CTDL_DEBUG, "fetch_http() libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_DEBUG, "fetch_http() libcurl error %d: %s\n", res, errmsg);
        }
        curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
        StrBufPlain(url, effective_url, -1);
@@ -646,7 +646,7 @@ void cmd_oids(char *argbuf) {
        oiddata->verified = 0;
 
        i = fetch_http(oiddata->claimed_id, &ReplyBuf);
-       CtdlLogPrintf(CTDL_DEBUG, "Normalized URL and Claimed ID is: %s\n", 
+       syslog(LOG_DEBUG, "Normalized URL and Claimed ID is: %s\n", 
                      ChrPtr(oiddata->claimed_id));
        if ((StrLength(ReplyBuf) > 0) && (i > 0)) {
 
@@ -744,13 +744,13 @@ void cmd_oidf(char *argbuf) {
                if (len < 0)
                        len = sizeof(thiskey) - 1;
                extract_token(thisdata, buf, 1, '|', sizeof thisdata);
-               CtdlLogPrintf(CTDL_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
+               syslog(LOG_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
                Put(keys, thiskey, len, strdup(thisdata), NULL);
        }
 
 
        /* Now that we have all of the parameters, we have to validate the signature against the server */
-       CtdlLogPrintf(CTDL_DEBUG, "About to validate the signature...\n");
+       syslog(LOG_DEBUG, "About to validate the signature...\n");
 
        CURL *curl;
        CURLcode res;
@@ -771,14 +771,14 @@ void cmd_oidf(char *argbuf) {
                CURLFORM_COPYNAME,      "openid.mode",
                CURLFORM_COPYCONTENTS,  "check_authentication",
                CURLFORM_END);
-       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.mode", "check_authentication");
+       syslog(LOG_DEBUG, "%25s : %s\n", "openid.mode", "check_authentication");
 
        if (GetHash(keys, "assoc_handle", 12, (void *) &o_assoc_handle)) {
                curl_formadd(&formpost, &lastptr,
                        CURLFORM_COPYNAME,      "openid.assoc_handle",
                        CURLFORM_COPYCONTENTS,  o_assoc_handle,
                        CURLFORM_END);
-               CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.assoc_handle", o_assoc_handle);
+               syslog(LOG_DEBUG, "%25s : %s\n", "openid.assoc_handle", o_assoc_handle);
        }
 
        if (GetHash(keys, "sig", 3, (void *) &o_sig)) {
@@ -786,7 +786,7 @@ void cmd_oidf(char *argbuf) {
                        CURLFORM_COPYNAME,      "openid.sig",
                        CURLFORM_COPYCONTENTS,  o_sig,
                        CURLFORM_END);
-                       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.sig", o_sig);
+                       syslog(LOG_DEBUG, "%25s : %s\n", "openid.sig", o_sig);
        }
 
        if (GetHash(keys, "signed", 6, (void *) &o_signed)) {
@@ -794,7 +794,7 @@ void cmd_oidf(char *argbuf) {
                        CURLFORM_COPYNAME,      "openid.signed",
                        CURLFORM_COPYCONTENTS,  o_signed,
                        CURLFORM_END);
-               CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.signed", o_signed);
+               syslog(LOG_DEBUG, "%25s : %s\n", "openid.signed", o_signed);
 
                num_signed_values = num_tokens(o_signed, ',');
                for (i=0; i<num_signed_values; ++i) {
@@ -806,10 +806,10 @@ void cmd_oidf(char *argbuf) {
                                                CURLFORM_COPYNAME,      k_o_keyname,
                                                CURLFORM_COPYCONTENTS,  k_value,
                                                CURLFORM_END);
-                                       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", k_o_keyname, k_value);
+                                       syslog(LOG_DEBUG, "%25s : %s\n", k_o_keyname, k_value);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_INFO, "OpenID: signed field '%s' is missing\n",
+                                       syslog(LOG_INFO, "OpenID: signed field '%s' is missing\n",
                                                k_keyname);
                                }
                        }
@@ -845,7 +845,7 @@ void cmd_oidf(char *argbuf) {
 
        res = curl_easy_perform(curl);
        if (res) {
-               CtdlLogPrintf(CTDL_DEBUG, "cmd_oidf() libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_DEBUG, "cmd_oidf() libcurl error %d: %s\n", res, errmsg);
        }
        curl_easy_cleanup(curl);
        curl_formfree(formpost);
@@ -855,7 +855,7 @@ void cmd_oidf(char *argbuf) {
        }
        FreeStrBuf(&ReplyBuf);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Authentication %s.\n", (oiddata->verified ? "succeeded" : "failed") );
+       syslog(LOG_DEBUG, "Authentication %s.\n", (oiddata->verified ? "succeeded" : "failed") );
 
        /* Respond to the client */
 
@@ -865,11 +865,11 @@ void cmd_oidf(char *argbuf) {
                if (CC->logged_in) {
                        if (attach_openid(&CC->user, oiddata->claimed_id) == 0) {
                                cprintf("attach\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "OpenID attach succeeded\n");
+                               syslog(LOG_DEBUG, "OpenID attach succeeded\n");
                        }
                        else {
                                cprintf("fail\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "OpenID attach failed\n");
+                               syslog(LOG_DEBUG, "OpenID attach failed\n");
                        }
                }
 
@@ -886,7 +886,7 @@ void cmd_oidf(char *argbuf) {
                        if (login_via_openid(oiddata->claimed_id) == 0) {
                                cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
                                logged_in_response();
-                               CtdlLogPrintf(CTDL_DEBUG, "Logged in using previously claimed OpenID\n");
+                               syslog(LOG_DEBUG, "Logged in using previously claimed OpenID\n");
                        }
 
                        /*
@@ -895,7 +895,7 @@ void cmd_oidf(char *argbuf) {
                         */
                        else if (config.c_disable_newu) {
                                cprintf("fail\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "Creating user failed due to local policy\n");
+                               syslog(LOG_DEBUG, "Creating user failed due to local policy\n");
                        }
 
                        /*
@@ -904,7 +904,7 @@ void cmd_oidf(char *argbuf) {
                        else if (openid_create_user_via_sreg(oiddata->claimed_id, keys) == 0) {
                                cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
                                logged_in_response();
-                               CtdlLogPrintf(CTDL_DEBUG, "Successfully auto-created new user\n");
+                               syslog(LOG_DEBUG, "Successfully auto-created new user\n");
                        }
 
                        /*
@@ -921,7 +921,7 @@ void cmd_oidf(char *argbuf) {
                                else {
                                        cprintf("\n");
                                }
-                               CtdlLogPrintf(CTDL_DEBUG, "The desired Simple Registration name is already taken.\n");
+                               syslog(LOG_DEBUG, "The desired Simple Registration name is already taken.\n");
                        }
                }
        }
index 1ad355a3e9cc955955d735e0b46820388cecf910..fe67455e1a4dc667e0a2e2ec3c2c63d4720962d2 100644 (file)
@@ -81,7 +81,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;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing POP3 cleanup hook\n");
        if (POP3->msgs != NULL) free(POP3->msgs);
 
        free(POP3);
@@ -135,7 +135,7 @@ void pop3_user(char *argbuf) {
        strcpy(username, argbuf);
        striplt(username);
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", username); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, username) == login_ok) {
                cprintf("+OK Password required for %s\r\n", username);
        }
@@ -213,7 +213,7 @@ void pop3_login(void)
        if (msgs >= 0) {
                cprintf("+OK %s is logged in (%d messages)\r\n",
                        CC->user.fullname, msgs);
-               CtdlLogPrintf(CTDL_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
+               syslog(LOG_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
        }
        else {
                cprintf("-ERR Can't open your mailbox\r\n");
@@ -285,7 +285,7 @@ void pop3_pass(char *argbuf) {
        safestrncpy(password, argbuf, sizeof password);
        striplt(password);
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", password); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", password); */
        if (CtdlTryPassword(password, strlen(password)) == pass_ok) {
                pop3_login();
        }
@@ -624,15 +624,15 @@ void pop3_command_loop(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\r\n");
                CC->kill_me = 1;
                return;
        }
        if (!strncasecmp(cmdbuf, "PASS", 4)) {
-               CtdlLogPrintf(CTDL_INFO, "POP3: PASS...\r\n");
+               syslog(LOG_INFO, "POP3: PASS...\r\n");
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "POP3: %s\r\n", cmdbuf);
+               syslog(LOG_INFO, "POP3: %s\r\n", cmdbuf);
        }
        while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
 
index 0b2eb99be648be621704b725f3313e757d2e8a76..d91ded9a4b7fd39526bec521a5729dc742b1b096 100644 (file)
@@ -82,29 +82,29 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
        struct UseTable ut;
        CitContext *CCC=CC;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s %s %s <password>\n", roomname, pop3host, pop3user);
-       CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s>\n", pop3host);
+       syslog(LOG_DEBUG, "POP3: %s %s %s <password>\n", roomname, pop3host, pop3user);
+       syslog(LOG_NOTICE, "Connecting to <%s>\n", pop3host);
        
        if (CtdlThreadCheckStop())
                return;
                
        sock = sock_connect(pop3host, "110");
        if (sock < 0) {
-               CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Could not connect: %s\n", strerror(errno));
                return;
        }
        
        if (CtdlThreadCheckStop())
                goto bail;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+       syslog(LOG_DEBUG, "Connected!\n");
        CCC->sReadBuf = NewStrBuf();
        CCC->sMigrateBuf = NewStrBuf();
        CCC->sPos = NULL;
 
        /* Read the server greeting */
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
        if (strncasecmp(buf, "+OK", 3)) goto bail;
 
        if (CtdlThreadCheckStop())
@@ -116,10 +116,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
         * actually barfs on LF-terminated newlines.
         */
        snprintf(buf, sizeof buf, "USER %s\r", pop3user);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (sock_puts(&sock, buf) <0) goto bail;
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
        if (strncasecmp(buf, "+OK", 3)) goto bail;
 
        if (CtdlThreadCheckStop())
@@ -127,10 +127,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
 
        /* Password */
        snprintf(buf, sizeof buf, "PASS %s\r", pop3pass);
-       CtdlLogPrintf(CTDL_DEBUG, "<PASS <password>\n");
+       syslog(LOG_DEBUG, "<PASS <password>\n");
        if (sock_puts(&sock, buf) <0) goto bail;
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
        if (strncasecmp(buf, "+OK", 3)) goto bail;
 
        if (CtdlThreadCheckStop())
@@ -138,10 +138,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
 
        /* Get the list of messages */
        snprintf(buf, sizeof buf, "LIST\r");
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (sock_puts(&sock, buf) <0) goto bail;
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
        if (strncasecmp(buf, "+OK", 3)) goto bail;
 
        if (CtdlThreadCheckStop())
@@ -152,7 +152,7 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
                        goto bail;
 
                if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-               CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+               syslog(LOG_DEBUG, ">%s\n", buf);
                msg_to_fetch = atoi(buf);
                if (msg_to_fetch > 0) {
                        if (alloc_msgs == 0) {
@@ -172,10 +172,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
 
                /* Find out the UIDL of the message, to determine whether we've already downloaded it */
                snprintf(buf, sizeof buf, "UIDL %d\r", msglist[i]);
-               CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+               syslog(LOG_DEBUG, "<%s\n", buf);
                if (sock_puts(&sock, buf) <0) goto bail;
                if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-               CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+               syslog(LOG_DEBUG, ">%s\n", buf);
                if (strncasecmp(buf, "+OK", 3)) goto bail;
                extract_token(this_uidl, buf, 2, ' ', sizeof this_uidl);
 
@@ -187,7 +187,7 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
                cdbut = cdb_fetch(CDB_USETABLE, utmsgid, strlen(utmsgid));
                if (cdbut != NULL) {
                        /* message has already been seen */
-                       CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", utmsgid);
+                       syslog(LOG_DEBUG, "%s has already been seen\n", utmsgid);
                        cdb_free(cdbut);
 
                        /* rewrite the record anyway, to update the timestamp */
@@ -198,10 +198,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
                else {
                        /* Message has not been seen. Tell the server to fetch the message... */
                        snprintf(buf, sizeof buf, "RETR %d\r", msglist[i]);
-                       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+                       syslog(LOG_DEBUG, "<%s\n", buf);
                        if (sock_puts(&sock, buf) <0) goto bail;
                        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-                       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+                       syslog(LOG_DEBUG, ">%s\n", buf);
                        if (strncasecmp(buf, "+OK", 3)) goto bail;
        
                        if (CtdlThreadCheckStop())
@@ -211,7 +211,7 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
                        body = CtdlReadMessageBody(HKEY("."), config.c_maxmsglen, NULL, 1, &sock);
                        if (body == NULL) goto bail;
        
-                       CtdlLogPrintf(CTDL_DEBUG, "Converting message...\n");
+                       syslog(LOG_DEBUG, "Converting message...\n");
                        msg = convert_internet_message(body);
                        body = NULL;    /* yes, this should be dereferenced, NOT freed */
        
@@ -222,10 +222,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
        
                                if (!keep) {
                                        snprintf(buf, sizeof buf, "DELE %d\r", msglist[i]);
-                                       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+                                       syslog(LOG_DEBUG, "<%s\n", buf);
                                        if (sock_puts(&sock, buf) <0) goto bail;
                                        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-                                       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf); /* errors here are non-fatal */
+                                       syslog(LOG_DEBUG, ">%s\n", buf); /* errors here are non-fatal */
                                }
 
                                /* write the uidl to the use table so we don't fetch this message again */
@@ -240,10 +240,10 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
 
        /* Log out */
        snprintf(buf, sizeof buf, "QUIT\r");
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (sock_puts(&sock, buf) <0) goto bail;
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
 bail:  
        FreeStrBuf(&CCC->sReadBuf);
        FreeStrBuf(&CCC->sMigrateBuf);
@@ -328,7 +328,7 @@ void pop3client_scan(void) {
        if (doing_pop3client) return;
        doing_pop3client = 1;
 
-       CtdlLogPrintf(CTDL_DEBUG, "pop3client started\n");
+       syslog(LOG_DEBUG, "pop3client started\n");
        CtdlForEachRoom(pop3client_scan_room, NULL);
 
        while (palist != NULL && !CtdlThreadCheckStop()) {
@@ -341,7 +341,7 @@ void pop3client_scan(void) {
                free(pptr);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "pop3client ended\n");
+       syslog(LOG_DEBUG, "pop3client ended\n");
        last_run = time(NULL);
        doing_pop3client = 0;
 }
index 13156ba0df047eca2b55796bc577d30c4e166738..d2522c1d5576667e51577307689af46bde3fc16f 100644 (file)
@@ -158,7 +158,7 @@ fill_encoding_info (const char *charset, XML_Encoding * info)
 { 
   iconv_t cd = (iconv_t)(-1); 
   int flag; 
-       CtdlLogPrintf(0, "RSS: fill encoding info ...\n");
+       syslog(LOG_EMERG, "RSS: fill encoding info ...\n");
  
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 
   cd = iconv_open ("UCS-2LE", charset); 
@@ -236,7 +236,7 @@ iconv_convertor (void *data, const char *s)
 { 
   XML_Encoding *info = data; 
   int res; 
-       CtdlLogPrintf(0, "RSS: Converting ...\n");
+       syslog(LOG_EMERG, "RSS: Converting ...\n");
 
   if (s == NULL) 
     return -1; 
@@ -269,7 +269,7 @@ handle_unknown_xml_encoding (void *encodingHandleData,
                             XML_Encoding * info) 
 { 
   int result; 
-  CtdlLogPrintf(0, "RSS: unknown encoding ...\n");
+  syslog(LOG_EMERG, "RSS: unknown encoding ...\n");
   result = fill_encoding_info (name, info); 
   if (result >= 0) 
     { 
@@ -340,7 +340,7 @@ int LookupUrl(StrBuf *ShorterUrlStr)
 
        curl = curl_easy_init();
        if (!curl) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                return 0;
        }
        Answer = NewStrBufPlain(NULL, SIZ);
@@ -379,7 +379,7 @@ int LookupUrl(StrBuf *ShorterUrlStr)
 
        rc = curl_easy_perform(curl);
        if (rc) {
-               CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", rc, errmsg);
+               syslog(LOG_ALERT, "libcurl error %d: %s\n", rc, errmsg);
                rc = 0;
        }
        else 
@@ -585,7 +585,7 @@ void rss_save_item(rss_item *ri)
 #ifndef DEBUG_RSS
        if (cdbut != NULL) {
                /* Item has already been seen */
-               CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", utmsgid);
+               syslog(LOG_DEBUG, "%s has already been seen\n", utmsgid);
                cdb_free(cdbut);
 
                /* rewrite the record anyway, to update the timestamp */
@@ -597,7 +597,7 @@ void rss_save_item(rss_item *ri)
 #endif
 {
                /* Item has not been seen, so save it. */
-               CtdlLogPrintf(CTDL_DEBUG, "RSS: saving item...\n");
+               syslog(LOG_DEBUG, "RSS: saving item...\n");
                if (ri->description == NULL) ri->description = NewStrBufPlain(HKEY(""));
                StrBufSpaceToBlank(ri->description);
                msg = malloc(sizeof(struct CtdlMessage));
@@ -773,7 +773,7 @@ void rss_xml_start(void *data, const char *supplied_el, const char **attr)
        char            *sep = NULL;
 
        /* Axe the namespace, we don't care about it */
-///    CtdlLogPrintf(0, "RSS: supplied el %d: %s...\n", rssc->Cfg->ItemType, supplied_el);
+///    syslog(LOG_EMERG, "RSS: supplied el %d: %s...\n", rssc->Cfg->ItemType, supplied_el);
        pel = supplied_el;
        while (sep = strchr(pel, ':'), sep) {
                pel = sep + 1;
@@ -789,7 +789,7 @@ void rss_xml_start(void *data, const char *supplied_el, const char **attr)
                             &v))
                {
 #ifdef DEBUG_RSS
-                       CtdlLogPrintf(0, "RSS: START ignoring because of wrong namespace [%s] = [%s]\n", 
+                       syslog(LOG_EMERG, "RSS: START ignoring because of wrong namespace [%s] = [%s]\n", 
                                      supplied_el);
 #endif
                        return;
@@ -819,12 +819,12 @@ void rss_xml_start(void *data, const char *supplied_el, const char **attr)
                }
 #ifdef DEBUG_RSS
                else 
-                       CtdlLogPrintf(0, "RSS: START unhandled: [%s] [%s]...\n", pel, supplied_el);
+                       syslog(LOG_EMERG, "RSS: START unhandled: [%s] [%s]...\n", pel, supplied_el);
 #endif
        }
 #ifdef DEBUG_RSS
        else 
-               CtdlLogPrintf(0, "RSS: START unhandled: [%s] [%s]...\n", pel,  supplied_el);
+               syslog(LOG_EMERG, "RSS: START unhandled: [%s] [%s]...\n", pel,  supplied_el);
 #endif
 }
 
@@ -843,7 +843,7 @@ void rss_xml_end(void *data, const char *supplied_el)
        while (sep = strchr(pel, ':'), sep) {
                pel = sep + 1;
        }
-//     CtdlLogPrintf(0, "RSS: END %s...\n", el);
+//     syslog(LOG_EMERG, "RSS: END %s...\n", el);
        if (pel != supplied_el)
        {
                void *v;
@@ -854,7 +854,7 @@ void rss_xml_end(void *data, const char *supplied_el)
                             &v))
                {
 #ifdef DEBUG_RSS
-                       CtdlLogPrintf(0, "RSS: END ignoring because of wrong namespace [%s] = [%s]\n", 
+                       syslog(LOG_EMERG, "RSS: END ignoring because of wrong namespace [%s] = [%s]\n", 
                                      supplied_el, ChrPtr(rssc->CData));
 #endif
                        FlushStrBuf(rssc->CData);
@@ -885,12 +885,12 @@ void rss_xml_end(void *data, const char *supplied_el)
                }
 #ifdef DEBUG_RSS
                else 
-                       CtdlLogPrintf(0, "RSS: END   unhandled: [%s]  [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
+                       syslog(LOG_EMERG, "RSS: END   unhandled: [%s]  [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
 #endif
        }
 #ifdef DEBUG_RSS
        else 
-               CtdlLogPrintf(0, "RSS: END   unhandled: [%s]  [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
+               syslog(LOG_EMERG, "RSS: END   unhandled: [%s]  [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
 #endif
        FlushStrBuf(rssc->CData);
        rssc->Current = NULL;
@@ -902,19 +902,19 @@ void rss_xml_end(void *data, const char *supplied_el)
 
 void RSS_item_rss_start (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RSS feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an RSS feed.\n");
        Cfg->ItemType = RSS_RSS;
 }
 
 void RSS_item_rdf_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RDF feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an RDF feed.\n");
        Cfg->ItemType = RSS_RSS;
 }
 
 void ATOM_item_feed_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an ATOM feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an ATOM feed.\n");
        Cfg->ItemType = RSS_ATOM;
 }
 
@@ -1189,13 +1189,13 @@ void ATOM_item_entry_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char
 
 void RSS_item_rss_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
 {
-//             CtdlLogPrintf(CTDL_DEBUG, "End of feed detected.  Closing parser.\n");
+//             syslog(LOG_DEBUG, "End of feed detected.  Closing parser.\n");
        ri->done_parsing = 1;
        
 }
 void RSS_item_rdf_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
 {
-//             CtdlLogPrintf(CTDL_DEBUG, "End of feed detected.  Closing parser.\n");
+//             syslog(LOG_DEBUG, "End of feed detected.  Closing parser.\n");
        ri->done_parsing = 1;
 }
 
@@ -1263,11 +1263,11 @@ void rss_do_fetching(rssnetcfg *Cfg) {
        rssc.Item = &ri;
        rssc.Cfg = Cfg;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Fetching RSS feed <%s>\n", Cfg->url);
+       syslog(LOG_DEBUG, "Fetching RSS feed <%s>\n", Cfg->url);
 
        curl = curl_easy_init();
        if (!curl) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                return;
        }
        Answer = NewStrBufPlain(NULL, SIZ);
@@ -1306,7 +1306,7 @@ void rss_do_fetching(rssnetcfg *Cfg) {
 
        res = curl_easy_perform(curl);
        if (res) {
-               CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_ALERT, "libcurl error %d: %s\n", res, errmsg);
        }
 
        if (CtdlThreadCheckStop())
@@ -1342,7 +1342,7 @@ void rss_do_fetching(rssnetcfg *Cfg) {
 
        xp = XML_ParserCreateNS(ptr, ':');
        if (!xp) {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
+               syslog(LOG_ALERT, "Cannot create XML parser!\n");
                goto shutdown;
        }
        FlushStrBuf(rssc.Key);
@@ -1369,7 +1369,7 @@ void rss_do_fetching(rssnetcfg *Cfg) {
                XML_Parse(xp, "", 0, 1);
 
 
-       CtdlLogPrintf(CTDL_ALERT, "RSS: XML Status [%s] \n", 
+       syslog(LOG_ALERT, "RSS: XML Status [%s] \n", 
                      XML_ErrorString(
                              XML_GetErrorCode(xp)));
 
@@ -1484,7 +1484,7 @@ void rssclient_scan(void) {
        if (doing_rssclient) return;
        doing_rssclient = 1;
 
-       CtdlLogPrintf(CTDL_DEBUG, "rssclient started\n");
+       syslog(LOG_DEBUG, "rssclient started\n");
        CtdlForEachRoom(rssclient_scan_room, NULL);
 
        while (rnclist != NULL && !CtdlThreadCheckStop()) {
@@ -1495,7 +1495,7 @@ void rssclient_scan(void) {
                free(rptr);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "rssclient ended\n");
+       syslog(LOG_DEBUG, "rssclient ended\n");
        last_run = time(NULL);
        doing_rssclient = 0;
        return;
@@ -1551,7 +1551,7 @@ CTDL_MODULE_INIT(rssclient)
 {
        if (threading)
        {
-               CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
+               syslog(LOG_INFO, "%s\n", curl_version());
                CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
        }
        else 
index a8fe4ea38a030f18eab573a8e985e2992b18d045..6a3ad95090a81ea8a24cf9100ba32905d8e3f70c 100644 (file)
@@ -64,7 +64,7 @@ char *msiv_extensions = NULL;
  */
 int ctdl_debug(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
+       syslog(LOG_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
        return SIEVE2_OK;
 }
 
@@ -74,7 +74,7 @@ int ctdl_debug(sieve2_context_t *s, void *my)
  */
 int ctdl_errparse(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_WARNING, "Error in script, line %d: %s\n",
+       syslog(LOG_WARNING, "Error in script, line %d: %s\n",
                sieve2_getvalue_int(s, "lineno"),
                sieve2_getvalue_string(s, "message")
        );
@@ -87,7 +87,7 @@ int ctdl_errparse(sieve2_context_t *s, void *my)
  */
 int ctdl_errexec(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_WARNING, "Error executing script: %s\n",
+       syslog(LOG_WARNING, "Error executing script: %s\n",
                sieve2_getvalue_string(s, "message")
        );
        return SIEVE2_OK;
@@ -106,22 +106,22 @@ int ctdl_redirect(sieve2_context_t *s, void *my)
 
        safestrncpy(recp, sieve2_getvalue_string(s, "address"), sizeof recp);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
+       syslog(LOG_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
 
        valid = validate_recipients(recp, NULL, 0);
        if (valid == NULL) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                return SIEVE2_ERROR_BADARGS;
        }
        if (valid->num_error > 0) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
 
        msg = CtdlFetchMessage(cs->msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: unable to fetch msg %ld\n", cs->msgnum);
+               syslog(LOG_WARNING, "REDIRECT failed: unable to fetch msg %ld\n", cs->msgnum);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
@@ -141,7 +141,7 @@ int ctdl_keep(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        
-       CtdlLogPrintf(CTDL_DEBUG, "Action is KEEP\n");
+       syslog(LOG_DEBUG, "Action is KEEP\n");
 
        cs->keep = 1;
        cs->cancel_implicit_keep = 1;
@@ -160,7 +160,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        char foldername[256];
        char original_room_name[ROOMNAMELEN];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is FILEINTO, destination is <%s>\n", dest_folder);
+       syslog(LOG_DEBUG, "Action is FILEINTO, destination is <%s>\n", dest_folder);
 
        /* FILEINTO 'INBOX' is the same thing as KEEP */
        if ( (!strcasecmp(dest_folder, "INBOX")) || (!strcasecmp(dest_folder, MAILROOM)) ) {
@@ -183,7 +183,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        }
 
        if (c != 0) {
-               CtdlLogPrintf(CTDL_WARNING, "FILEINTO failed: target <%s> does not exist\n", dest_folder);
+               syslog(LOG_WARNING, "FILEINTO failed: target <%s> does not exist\n", dest_folder);
                return SIEVE2_ERROR_BADARGS;
        }
 
@@ -214,7 +214,7 @@ int ctdl_discard(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is DISCARD\n");
+       syslog(LOG_DEBUG, "Action is DISCARD\n");
 
        /* Cancel the implicit keep.  That's all there is to it. */
        cs->cancel_implicit_keep = 1;
@@ -231,11 +231,11 @@ int ctdl_reject(sieve2_context_t *s, void *my)
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        char *reject_text = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is REJECT\n");
+       syslog(LOG_DEBUG, "Action is REJECT\n");
 
        /* If we don't know who sent the message, do a DISCARD instead. */
        if (IsEmptyStr(cs->sender)) {
-               CtdlLogPrintf(CTDL_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.\n");
+               syslog(LOG_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.\n");
                return ctdl_discard(s, my);
        }
 
@@ -286,7 +286,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        char *vacamsg_text = NULL;
        char vacamsg_subject[1024];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is VACATION\n");
+       syslog(LOG_DEBUG, "Action is VACATION\n");
 
        message = sieve2_getvalue_string(s, "message");
        if (message == NULL) return SIEVE2_ERROR_BADARGS;
@@ -306,7 +306,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        for (vptr = cs->u->first_vacation; vptr != NULL; vptr = vptr->next) {
                if (!strcasecmp(vptr->fromaddr, cs->sender)) {
                        if ( (time(NULL) - vptr->timestamp) < (days * 86400) ) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Already alerted <%s> recently.\n", cs->sender);
+                               syslog(LOG_DEBUG, "Already alerted <%s> recently.\n", cs->sender);
                                return SIEVE2_OK;
                        }
                }
@@ -391,7 +391,7 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
+       syslog(LOG_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
                cs->envelope_from, cs->envelope_to);
 
        if (cs->envelope_from != NULL) {
@@ -463,13 +463,13 @@ int ctdl_getscript(sieve2_context_t *s, void *my) {
 
        for (sptr=cs->u->first_script; sptr!=NULL; sptr=sptr->next) {
                if (sptr->script_active > 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getscript() is using script '%s'\n", sptr->script_name);
+                       syslog(LOG_DEBUG, "ctdl_getscript() is using script '%s'\n", sptr->script_name);
                        sieve2_setvalue_string(s, "script", sptr->script_content);
                        return SIEVE2_OK;
                }
        }
                
-       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getscript() found no active script\n");
+       syslog(LOG_DEBUG, "ctdl_getscript() found no active script\n");
        return SIEVE2_ERROR_GETSCRIPT;
 }
 
@@ -480,7 +480,7 @@ int ctdl_getheaders(sieve2_context_t *s, void *my) {
 
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getheaders() was called\n");
+       syslog(LOG_DEBUG, "ctdl_getheaders() was called\n");
        sieve2_setvalue_string(s, "allheaders", cs->rfc822headers);
        return SIEVE2_OK;
 }
@@ -501,7 +501,7 @@ void sieve_queue_room(struct ctdlroom *which_room) {
        ptr->next = sieve_list;
        sieve_list = ptr;
        end_critical_section(S_SIEVELIST);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s> queued for Sieve processing\n", which_room->QRname);
+       syslog(LOG_DEBUG, "<%s> queued for Sieve processing\n", which_room->QRname);
 }
 
 
@@ -521,13 +521,13 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        if (u == NULL)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Can't process message <%ld> without userdata!\n", msgnum);
+               syslog(LOG_EMERG, "Can't process message <%ld> without userdata!\n", msgnum);
                return;
        }
 
        sieve2_context = u->sieve2_context;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
 
        /*
         * Make sure you include message body so you can get those second-level headers ;)
@@ -638,10 +638,10 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        sieve2_setvalue_string(sieve2_context, "allheaders", my.rfc822headers);
        
-       CtdlLogPrintf(CTDL_DEBUG, "Calling sieve2_execute()\n");
+       syslog(LOG_DEBUG, "Calling sieve2_execute()\n");
        res = sieve2_execute(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_execute() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_execute() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
        free(my.rfc822headers);
@@ -652,11 +652,11 @@ void sieve_do_msg(long msgnum, void *userdata) {
         * if no other action was successfully taken.
         */
        if ( (!my.keep) && (my.cancel_implicit_keep) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "keep is 0 -- deleting message from inbox\n");
+               syslog(LOG_DEBUG, "keep is 0 -- deleting message from inbox\n");
                CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Completed sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Completed sieve processing on msg <%ld>\n", msgnum);
        u->lastproc = msgnum;
 
        return;
@@ -865,7 +865,7 @@ void sieve_do_room(char *roomname) {
         */
        snprintf(u.config_roomname, sizeof u.config_roomname, "%010ld.%s", atol(roomname), USERCONFIGROOM);
        if (CtdlGetRoom(&CC->room, u.config_roomname) != 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> does not exist.  No processing is required.\n", u.config_roomname);
+               syslog(LOG_DEBUG, "<%s> does not exist.  No processing is required.\n", u.config_roomname);
                return;
        }
 
@@ -877,14 +877,14 @@ void sieve_do_room(char *roomname) {
                get_sieve_config_backend, (void *)&u );
 
        if (u.config_msgnum < 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "No Sieve rules exist.  No processing is required.\n");
+               syslog(LOG_DEBUG, "No Sieve rules exist.  No processing is required.\n");
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Rules found.  Performing Sieve processing for <%s>\n", roomname);
+       syslog(LOG_DEBUG, "Rules found.  Performing Sieve processing for <%s>\n", roomname);
 
        if (CtdlGetRoom(&CC->room, roomname) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", roomname);
+               syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", roomname);
                return;
        }
 
@@ -892,13 +892,13 @@ void sieve_do_room(char *roomname) {
        
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -909,7 +909,7 @@ void sieve_do_room(char *roomname) {
        my.u = &u;
        res = sieve2_validate(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_validate() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_validate() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -924,7 +924,7 @@ void sieve_do_room(char *roomname) {
 BAIL:
        res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
        /* Rewrite the config if we have to */
@@ -939,7 +939,7 @@ void perform_sieve_processing(void) {
        struct RoomProcList *ptr = NULL;
 
        if (sieve_list != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Begin Sieve processing\n");
+               syslog(LOG_DEBUG, "Begin Sieve processing\n");
                while (sieve_list != NULL) {
                        char spoolroomname[ROOMNAMELEN];
                        safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname);
@@ -1256,7 +1256,7 @@ void ctdl_sieve_init(void) {
                strcpy(&cred[55], "...");
        }
 
-       CtdlLogPrintf(CTDL_INFO, "%s\n",cred);
+       syslog(LOG_INFO, "%s\n",cred);
        free(cred);
 
        /* Briefly initialize a Sieve parser instance just so we can list the
@@ -1264,22 +1264,22 @@ void ctdl_sieve_init(void) {
         */
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
        msiv_extensions = strdup(sieve2_listextensions(sieve2_context));
-       CtdlLogPrintf(CTDL_INFO, "Extensions: %s\n", msiv_extensions);
+       syslog(LOG_INFO, "Extensions: %s\n", msiv_extensions);
 
 BAIL:  res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
 }
index cccb61bf68ae6df8d893cbac4b8fc4fd72b41ee0..d2fbe63840b603778225dcc9640bc590bf52c3d0 100644 (file)
@@ -217,7 +217,7 @@ void lmtp_unfiltered_greeting(void) {
  */
 void smtp_auth_greeting(void) {
                cprintf("235 Hello, %s\r\n", CC->user.fullname);
-               CtdlLogPrintf(CTDL_NOTICE, "SMTP authenticated %s\n", CC->user.fullname);
+               syslog(LOG_NOTICE, "SMTP authenticated %s\n", CC->user.fullname);
                CC->internal_pgm = 0;
                CC->cs_flags &= ~CS_STEALTH;
 }
@@ -302,7 +302,7 @@ void smtp_get_user(char *argbuf) {
        citsmtp *sSMTP = SMTP;
 
        CtdlDecodeBase64(username, argbuf, SIZ);
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", username); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, username) == login_ok) {
                CtdlEncodeBase64(buf, "Password:", 9, 0);
                cprintf("334 %s\r\n", buf);
@@ -324,7 +324,7 @@ void smtp_get_pass(char *argbuf) {
 
        memset(password, 0, sizeof(password));  
        len = CtdlDecodeBase64(password, argbuf, SIZ);
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", password); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", password); */
        if (CtdlTryPassword(password, len) == pass_ok) {
                smtp_auth_greeting();
        }
@@ -695,7 +695,7 @@ void smtp_data(void) {
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Converting message...\n");
+       syslog(LOG_DEBUG, "Converting message...\n");
        msg = convert_internet_message_buf(&body);
 
        /* If the user is locally authenticated, FORCE the From: header to
@@ -785,20 +785,18 @@ void smtp_data(void) {
                cprintf("%s", result);
        }
 
-       /* Write something to the syslog (which may or may not be where the
+       /* Write something to the syslog(which may or may not be where the
         * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
         */
-       if (enable_syslog) {
-               syslog((LOG_MAIL | LOG_INFO),
-                       "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
-                       msgnum,
-                       sSMTP->from,
-                       sSMTP->number_of_recipients,
-                       CC->cs_host,
-                       CC->cs_addr,
-                       result
-               );
-       }
+       syslog((LOG_MAIL | LOG_INFO),
+               "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
+               msgnum,
+               sSMTP->from,
+               sSMTP->number_of_recipients,
+               CC->cs_host,
+               CC->cs_addr,
+               result
+       );
 
        /* Clean up */
        CtdlFreeMessage(msg);
@@ -836,17 +834,17 @@ void smtp_command_loop(void) {
        citsmtp *sSMTP = SMTP;
 
        if (sSMTP == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Session SMTP data is null.  WTF?  We will crash now.\n");
+               syslog(LOG_EMERG, "Session SMTP data is null.  WTF?  We will crash now.\n");
        }
 
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "SMTP server: %s\n", cmdbuf);
+       syslog(LOG_INFO, "SMTP server: %s\n", cmdbuf);
        while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
 
        if (sSMTP->command_state == smtp_user) {
@@ -937,7 +935,7 @@ void smtp_cleanup_function(void) {
        /* Don't do this stuff if this is not an SMTP session! */
        if (CC->h_command_function != smtp_command_loop) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing SMTP cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing SMTP cleanup hook\n");
        free(SMTP);
 }
 
index 0626ffdbd7b5ee1a06c42cbc157162b615d2f8f5..a8fa3afecd3bc189b8664159d7b96915e3df49e9 100644 (file)
@@ -128,7 +128,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);
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Attempting delivery to <%s> @ <%s> (%s)\n",
+       syslog(LOG_DEBUG, "SMTP client: Attempting delivery to <%s> @ <%s> (%s)\n",
                user, node, name);
 
        /* Load the message out of the database */
@@ -189,7 +189,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);
-       CtdlLogPrintf(CTDL_DEBUG, "Number of MX hosts for <%s> is %d [%s]\n", node, num_mxhosts, mxhosts);
+       syslog(LOG_DEBUG, "Number of MX hosts for <%s> is %d [%s]\n", node, num_mxhosts, mxhosts);
        if (num_mxhosts < 1) {
                *status = 5;
                snprintf(dsn, SIZ, "No MX hosts found for <%s>", node);
@@ -223,21 +223,21 @@ void smtp_try(const char *key, const char *addr, int *status,
                else {
                        strcpy(mx_port, "25");
                }
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
+               syslog(LOG_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
                sock = sock_connect(mx_host, mx_port);
                snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
                if (sock >= 0) 
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n");
+                       syslog(LOG_DEBUG, "SMTP client: connected!\n");
                                int fdflags; 
                                fdflags = fcntl(sock, F_GETFL);
                                if (fdflags < 0)
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                      "unable to get SMTP-Client socket flags! %s \n",
                                                      strerror(errno));
                                fdflags = fdflags | O_NONBLOCK;
                                if (fcntl(sock, F_SETFL, fdflags) < 0)
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                      "unable to set SMTP-Client socket nonblocking flags! %s \n",
                                                      strerror(errno));
                }
@@ -266,7 +266,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                strcpy(dsn, "Connection broken during SMTP conversation");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -284,17 +284,17 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* Do a EHLO command.  If it fails, try the HELO command. */
        snprintf(buf, sizeof buf, "EHLO %s\r\n", config.c_fqdn);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP HELO");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
-               CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+               syslog(LOG_DEBUG, ">%s", buf);
                sock_write(&sock, buf, strlen(buf));
                if (ml_sock_gets(&sock, buf, 30) < 0) {
                        *status = 4;
@@ -321,14 +321,14 @@ void smtp_try(const char *key, const char *addr, int *status,
                sprintf(buf, "%s%c%s%c%s", mx_user, '\0', mx_user, '\0', mx_pass);
                CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2, 0);
                snprintf(buf, sizeof buf, "AUTH PLAIN %s\r\n", encoded);
-               CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+               syslog(LOG_DEBUG, ">%s", buf);
                sock_write(&sock, buf, strlen(buf));
                if (ml_sock_gets(&sock, buf, 30) < 0) {
                        *status = 4;
                        strcpy(dsn, "Connection broken during SMTP AUTH");
                        goto bail;
                }
-               CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+               syslog(LOG_DEBUG, "<%s\n", buf);
                if (buf[0] != '2') {
                        if (buf[0] == '4') {
                                *status = 4;
@@ -345,14 +345,14 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* previous command succeeded, now try the MAIL FROM: command */
        snprintf(buf, sizeof buf, "MAIL FROM:<%s>\r\n", envelope_from);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP MAIL");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -368,14 +368,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@%s>\r\n", user, node);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP RCPT");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -390,14 +390,14 @@ void smtp_try(const char *key, const char *addr, int *status,
        }
 
        /* RCPT succeeded, now try the DATA command */
-       CtdlLogPrintf(CTDL_DEBUG, ">DATA\n");
+       syslog(LOG_DEBUG, ">DATA\n");
        sock_write(&sock, "DATA\r\n", 6);
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP DATA");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '3') {
                if (buf[0] == '4') {
                        *status = 3;
@@ -417,7 +417,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                           msg_size, 
                           (msg_size / 128) + 50);
        if (msgtext[msg_size-1] != 10) {
-               CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
+               syslog(LOG_WARNING, "Possible problem: message did not "
                        "correctly terminate. (expecting 0x10, got 0x%02x)\n",
                                buf[msg_size-1]);
                sock_write(&sock, "\r\n", 2);
@@ -430,7 +430,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                strcpy(dsn, "Connection broken during SMTP message transmit");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
+       syslog(LOG_DEBUG, "%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -448,11 +448,11 @@ void smtp_try(const char *key, const char *addr, int *status,
        safestrncpy(dsn, &buf[4], 1023);
        *status = 2;
 
-       CtdlLogPrintf(CTDL_DEBUG, ">QUIT\n");
+       syslog(LOG_DEBUG, ">QUIT\n");
        sock_write(&sock, "QUIT\r\n", 6);
        ml_sock_gets(&sock, buf, 30);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
-       CtdlLogPrintf(CTDL_INFO, "SMTP client: delivery to <%s> @ <%s> (%s) succeeded\n",
+       syslog(LOG_DEBUG, "<%s\n", buf);
+       syslog(LOG_INFO, "SMTP client: delivery to <%s> @ <%s> (%s) succeeded\n",
                user, node, name);
 
 bail:  free(msgtext);
@@ -461,18 +461,16 @@ bail:     free(msgtext);
        if (sock != -1)
                sock_close(sock);
 
-       /* Write something to the syslog (which may or may not be where the
+       /* Write something to the syslog(which may or may not be where the
         * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
         */
-       if (enable_syslog) {
-               syslog((LOG_MAIL | LOG_INFO),
-                       "%ld: to=<%s>, relay=%s, stat=%s",
-                       msgnum,
-                       addr,
-                       mx_host,
-                       dsn
-               );
-       }
+       syslog((LOG_MAIL | LOG_INFO),
+               "%ld: to=<%s>, relay=%s, stat=%s",
+               msgnum,
+               addr,
+               mx_host,
+               dsn
+       );
 
        return;
 }
@@ -506,7 +504,7 @@ void smtp_do_bounce(char *instr) {
        StrBuf *BounceMB;
        long omsgid = (-1);
 
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
+       syslog(LOG_DEBUG, "smtp_do_bounce() called\n");
        strcpy(bounceto, "");
        boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
        StrBufAppendPrintf(boundary, "%s_%04x%04x", config.c_fqdn, getpid(), ++seq);
@@ -575,7 +573,7 @@ void smtp_do_bounce(char *instr) {
                dsnlen = extract_token(dsn, buf, 3, '|', sizeof dsn);
                bounce_this = 0;
 
-               CtdlLogPrintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
+               syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
                        key, addr, status, dsn);
 
                if (!strcasecmp(key, "bounceto")) {
@@ -629,13 +627,13 @@ void smtp_do_bounce(char *instr) {
                free(bmsg->cm_fields['A']);
        bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
        /* Deliver the bounce if there's anything worth mentioning */
-       CtdlLogPrintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
+       syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
        if (num_bounces > 0) {
 
                /* First try the user who sent the message */
-               CtdlLogPrintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto);
+               syslog(LOG_DEBUG, "bounce to user? <%s>\n", bounceto);
                if (IsEmptyStr(bounceto)) {
-                       CtdlLogPrintf(CTDL_ERR, "No bounce address specified\n");
+                       syslog(LOG_ERR, "No bounce address specified\n");
                        bounce_msgid = (-1L);
                }
 
@@ -660,7 +658,7 @@ void smtp_do_bounce(char *instr) {
        }
        FreeStrBuf(&boundary);
        CtdlFreeMessage(bmsg);
-       CtdlLogPrintf(CTDL_DEBUG, "Done processing bounces\n");
+       syslog(LOG_DEBUG, "Done processing bounces\n");
 }
 
 
@@ -730,12 +728,12 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        time_t last_attempted = 0L;
        time_t retry = SMTP_RETRY_INTERVAL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: smtp_do_procmsg(%ld)\n", msgnum);
+       syslog(LOG_DEBUG, "SMTP client: smtp_do_procmsg(%ld)\n", msgnum);
        strcpy(envelope_from, "");
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP client: tried %ld but no such message!\n", msgnum);
+               syslog(LOG_ERR, "SMTP client: tried %ld but no such message!\n", msgnum);
                return;
        }
 
@@ -783,7 +781,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)) {
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Retry time not yet reached.\n");
+               syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n");
                free(instr);
                return;
        }
@@ -793,7 +791,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         * Bail out if there's no actual message associated with this
         */
        if (text_msgid < 0L) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP client: no 'msgid' directive found!\n");
+               syslog(LOG_ERR, "SMTP client: no 'msgid' directive found!\n");
                free(instr);
                return;
        }
@@ -823,7 +821,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
 
                        --i;
                        --lines;
-                       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Trying <%s>\n", addr);
+                       syslog(LOG_DEBUG, "SMTP client: Trying <%s>\n", addr);
                        smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid, envelope_from);
                        if (status != 2) {
                                if (results == NULL) {
@@ -944,19 +942,19 @@ void *smtp_queue_thread(void *arg) {
 
        CtdlFillSystemContext(&smtp_queue_CC, "SMTP Send");
        citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_queue_thread() initializing\n");
+       syslog(LOG_DEBUG, "smtp_queue_thread() initializing\n");
 
        while (!CtdlThreadCheckStop()) {
                
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: processing outbound queue\n");
+               syslog(LOG_INFO, "SMTP client: processing outbound queue\n");
 
                if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
+                       syslog(LOG_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
                }
                else {
                        num_processed = CtdlForEachMessage(MSGS_ALL, 0L, NULL, SPOOLMIME, NULL, smtp_do_procmsg, NULL);
                }
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
+               syslog(LOG_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
                CtdlThreadSleep(60);
        }
 
index be829829856e658dce582638243d9b8e7ac1921d..8d8a8b6649f12f2f9f03e58a8508f95c57b77a2b 100644 (file)
@@ -92,9 +92,9 @@ int spam_assassin(struct CtdlMessage *msg) {
        /* Try them one by one until we get a working one */
         for (sa=0; sa<num_sahosts; ++sa) {
                 extract_token(buf, sahosts, sa, '|', sizeof buf);
-                CtdlLogPrintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
+                syslog(LOG_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
                 sock = sock_connect(buf, SPAMASSASSIN_PORT);
-                if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+                if (sock >= 0) syslog(LOG_DEBUG, "Connected!\n");
         }
 
        if (sock < 0) {
@@ -109,7 +109,7 @@ int spam_assassin(struct CtdlMessage *msg) {
        CCC->sPos = NULL;
 
        /* Command */
-       CtdlLogPrintf(CTDL_DEBUG, "Transmitting command\n");
+       syslog(LOG_DEBUG, "Transmitting command\n");
        sprintf(buf, "CHECK SPAMC/1.2\r\n\r\n");
        sock_write(&sock, buf, strlen(buf));
 
@@ -129,21 +129,21 @@ int spam_assassin(struct CtdlMessage *msg) {
                sock_shutdown(sock, SHUT_WR);
        
        /* Response */
-       CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
+       syslog(LOG_DEBUG, "Awaiting response\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "SPAMD", 5)) {
                goto bail;
        }
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
-        CtdlLogPrintf(CTDL_DEBUG, "c_spam_flag_only setting %d\n", config.c_spam_flag_only);
+        syslog(LOG_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "c_spam_flag_only setting %d\n", config.c_spam_flag_only);
         if (config.c_spam_flag_only) {
-                CtdlLogPrintf(CTDL_DEBUG, "flag spam code used");
+                syslog(LOG_DEBUG, "flag spam code used");
                int headerlen;
                int newmsgsize;
                int oldmsgsize;
@@ -174,7 +174,7 @@ int spam_assassin(struct CtdlMessage *msg) {
                memcpy(msg->cm_fields['M'],buf,headerlen);
 
        } else {
-                CtdlLogPrintf(CTDL_DEBUG, "reject spam code used");
+                syslog(LOG_DEBUG, "reject spam code used");
                if (!strncasecmp(buf, "Spam: True", 10)) {
                        is_spam = 1;
                }
index 7538b401a321fc116401440b57c2ca9663c91062..797958f199b256b4321a957c704c6dda37629fad 100644 (file)
 
 
 void CleanupTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- test of adding an unload hook --- \n");
+       syslog(LOG_DEBUG, "--- test of adding an unload hook --- \n");
        }
 
 void NewRoomTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- test module was told we're now in a new room ---\n");
+       syslog(LOG_DEBUG, "--- test module was told we're now in a new room ---\n");
        }
 
 void SessionStartTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- starting up session %d ---\n",
+       syslog(LOG_DEBUG, "--- starting up session %d ---\n",
                CC->cs_pid);
        }
 
 void SessionStopTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- ending session %d ---\n", 
+       syslog(LOG_DEBUG, "--- ending session %d ---\n", 
                CC->cs_pid);
        }
 
 void LoginTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
+       syslog(LOG_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
        }
 
 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
index 317023ae7a5558ce412d1a52a196f30e516f1505..8b6b315a5d63199bf4f74eb602d21c6dc4fbdef4 100644 (file)
@@ -131,14 +131,14 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
 
                if (CtdlGetRoomLock(&qr, rplist->name) == 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
+                       syslog(LOG_DEBUG, "Processing <%s>...\n", rplist->name);
                        if ( (qr.QRflags & QR_MAILBOX) == 0) {
-                               CtdlLogPrintf(CTDL_DEBUG, "  -- not a mailbox\n");
+                               syslog(LOG_DEBUG, "  -- not a mailbox\n");
                        }
                        else {
 
                                qr.QRgen = time(NULL);
-                               CtdlLogPrintf(CTDL_DEBUG, "  -- fixed!\n");
+                               syslog(LOG_DEBUG, "  -- fixed!\n");
                        }
                        CtdlPutRoomLock(&qr);
                }
@@ -153,7 +153,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
  * quick fix to bump mailbox generation numbers
  */
 void bump_mailbox_generation_numbers(void) {
-       CtdlLogPrintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
+       syslog(LOG_WARNING, "Applying security fix to mailbox rooms\n");
        CtdlForEachRoom(cmd_bmbx_backend, NULL);
        cmd_bmbx_backend(NULL, NULL);
        return;
@@ -186,7 +186,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
        while (uplist != NULL) {
 
                if (CtdlGetUserLock(&us, uplist->user) == 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
+                       syslog(LOG_DEBUG, "Processing <%s>...\n", uplist->user);
                        if (us.uid == CTDLUID) {
                                us.uid = (-1);
                        }
@@ -203,7 +203,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
  * quick fix to change all CTDLUID users to (-1)
  */
 void convert_ctdluid_to_minusone(void) {
-       CtdlLogPrintf(CTDL_WARNING, "Applying uid changes\n");
+       syslog(LOG_WARNING, "Applying uid changes\n");
        ForEachUser(cbtm_backend, NULL);
        cbtm_backend(NULL, NULL);
        return;
@@ -223,7 +223,7 @@ void guess_time_zone(void) {
                if (fgets(buf, sizeof buf, fp) && (strlen(buf) > 2)) {
                        buf[strlen(buf)-1] = 0;
                        safestrncpy(config.c_default_cal_zone, buf, sizeof config.c_default_cal_zone);
-                       CtdlLogPrintf(CTDL_INFO, "Configuring timezone: %s\n", config.c_default_cal_zone);
+                       syslog(LOG_INFO, "Configuring timezone: %s\n", config.c_default_cal_zone);
                }
                fclose(fp);
        }
@@ -278,12 +278,12 @@ void update_config(void) {
 void check_server_upgrades(void) {
 
        get_control();
-       CtdlLogPrintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
+       syslog(LOG_INFO, "Server-hosted upgrade level is %d.%02d\n",
                (CitControl.version / 100),
                (CitControl.version % 100) );
 
        if (CitControl.version < REV_LEVEL) {
-               CtdlLogPrintf(CTDL_WARNING,
+               syslog(LOG_WARNING,
                        "Server hosted updates need to be processed at "
                        "this time.  Please wait...\n");
        }
@@ -294,7 +294,7 @@ void check_server_upgrades(void) {
        update_config();
 
        if ((CitControl.version > 000) && (CitControl.version < 555)) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "Your data files are from a version of Citadel\n"
                        "that is too old to be upgraded.  Sorry.\n");
                exit(EXIT_FAILURE);
index 2a2ffb4b3b3b329b3ea18bf21df9113998242ae8..0aba02889749b845e7f3ac68d36368774ee194e9 100644 (file)
@@ -146,18 +146,18 @@ void vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
         * probably just the networker or something.
         */
        if (CC->logged_in) {
-               CtdlLogPrintf(CTDL_DEBUG, "Checking for <%s>...\n", internet_addr);
+               syslog(LOG_DEBUG, "Checking for <%s>...\n", internet_addr);
                if (CtdlDirectoryLookup(buf, internet_addr, sizeof buf) == 0) {
                        if (strcasecmp(buf, citadel_addr)) {
                                /* This address belongs to someone else.
                                 * Bail out silently without saving.
                                 */
-                               CtdlLogPrintf(CTDL_DEBUG, "DOOP!\n");
+                               syslog(LOG_DEBUG, "DOOP!\n");
                                return;
                        }
                }
        }
-       CtdlLogPrintf(CTDL_INFO, "Adding %s (%s) to directory\n", citadel_addr, internet_addr);
+       syslog(LOG_INFO, "Adding %s (%s) to directory\n", citadel_addr, internet_addr);
        CtdlDirectoryAddUser(internet_addr, citadel_addr);
 }
 
@@ -284,7 +284,7 @@ void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp,
        if (  (!strcasecmp(cbtype, "text/x-vcard"))
           || (!strcasecmp(cbtype, "text/vcard")) ) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Part %s contains a vCard!  Loading...\n", partnum);
+               syslog(LOG_DEBUG, "Part %s contains a vCard!  Loading...\n", partnum);
                if (*v != NULL) {
                        vcard_free(*v);
                }
@@ -362,7 +362,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
        }
 
        s = vcard_get_prop(v, "fn", 1, 0, 0);
-       if (s) CtdlLogPrintf(CTDL_DEBUG, "vCard beforesave hook running for <%s>\n", s);
+       if (s) syslog(LOG_DEBUG, "vCard beforesave hook running for <%s>\n", s);
 
        if (yes_my_citadel_config) {
                /* Bingo!  The user is uploading a new vCard, so
@@ -810,7 +810,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
        struct vCard *v;
 
        vcard_fn_to_n(vname, usbuf->fullname, sizeof vname);
-       CtdlLogPrintf(CTDL_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
+       syslog(LOG_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
 
        /* Create and save the vCard */
        v = vcard_new();
@@ -829,7 +829,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer) != NULL) {
 #else // SOLARIS_GETPWUID
                struct passwd *result = NULL;
-               CtdlLogPrintf(CTDL_DEBUG, "Searching for uid %d\n", usbuf->uid);
+               syslog(LOG_DEBUG, "Searching for uid %d\n", usbuf->uid);
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
 #endif // HAVE_GETPWUID_R
                        snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn);
@@ -1116,13 +1116,13 @@ void check_get(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, ": %s\n", cmdbuf);
+       syslog(LOG_INFO, ": %s\n", cmdbuf);
        while (strlen(cmdbuf) < 3) strcat(cmdbuf, " ");
-       CtdlLogPrintf(CTDL_INFO, "[ %s]\n", cmdbuf);
+       syslog(LOG_INFO, "[ %s]\n", cmdbuf);
        
        if (strncasecmp(cmdbuf, "GET ", 4)==0)
        {
@@ -1139,13 +1139,13 @@ void check_get(void) {
                {
 
                        cprintf("200 OK %s\n", internet_addr);
-                       CtdlLogPrintf(CTDL_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
+                       syslog(LOG_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
                }
                else 
                {
                        cprintf("500 REJECT noone here by that name.\n");
                        
-                       CtdlLogPrintf(CTDL_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
+                       syslog(LOG_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
                }
                if (rcpt != NULL) 
                        free_recipients(rcpt);
@@ -1154,7 +1154,7 @@ void check_get(void) {
        {
                cprintf("500 REJECT invalid Query.\n");
                
-               CtdlLogPrintf(CTDL_INFO, "sending 500 REJECT invalid Query: %s\n", internet_addr);
+               syslog(LOG_INFO, "sending 500 REJECT invalid Query: %s\n", internet_addr);
        }
 }
 
@@ -1176,7 +1176,7 @@ void vcard_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERCONTACTSROOM)) {
-               CtdlLogPrintf(CTDL_ERR, "Couldn't get the user CONTACTS room!\n");
+               syslog(LOG_ERR, "Couldn't get the user CONTACTS room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1351,7 +1351,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
                        }
                        vcard_free(v);
 
-                       CtdlLogPrintf(CTDL_DEBUG, "Adding contact: %s\n", recipient);
+                       syslog(LOG_DEBUG, "Adding contact: %s\n", recipient);
                        vmsgnum = CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
                        CtdlFreeMessage(vmsg);
                }
index 81825c689c0d84d0207163d88d9229f6b4e5a7b1..0399124b396e44949fccfdc29af3070d37fbbf89 100644 (file)
@@ -116,7 +116,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
        if (    (strlen(msg->cm_fields['E']) >= 9)
                && (!strcasecmp(&msg->cm_fields['E'][strlen(msg->cm_fields['E'])-9], "_HISTORY_"))
        ) {
-               CtdlLogPrintf(CTDL_DEBUG, "History page not being historied\n");
+               syslog(LOG_DEBUG, "History page not being historied\n");
                return(0);
        }
 
@@ -182,10 +182,10 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                } while (nbytes == 1024);
                diffbuf[diffbuf_len] = 0;
                if (pclose(fp) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - diff failed\n");
+                       syslog(LOG_ERR, "pclose() returned an error - diff failed\n");
                }
        }
-       CtdlLogPrintf(CTDL_DEBUG, "diff length is %d bytes\n", diffbuf_len);
+       syslog(LOG_DEBUG, "diff length is %d bytes\n", diffbuf_len);
 
        unlink(diff_old_filename);
        unlink(diff_new_filename);
@@ -315,7 +315,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                CtdlSubmitMsg(history_msg, NULL, "", 0);
        }
        else {
-               CtdlLogPrintf(CTDL_ALERT, "Empty boundary string in history message.  No history!\n");
+               syslog(LOG_ALERT, "Empty boundary string in history message.  No history!\n");
        }
 
        free(diffbuf);
@@ -419,7 +419,7 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
 
        CtdlDecodeBase64(memo, filename, strlen(filename));
        extract_token(this_rev, memo, 0, '|', sizeof this_rev);
-       CtdlLogPrintf(CTDL_DEBUG, "callback found rev: %s\n", this_rev);
+       syslog(LOG_DEBUG, "callback found rev: %s\n", this_rev);
 
        /* Perform the patch */
        fp = popen("patch -f -s -p0 -r /dev/null >/dev/null 2>/dev/null", "w");
@@ -443,13 +443,13 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
                        }
                } while ((*ptr != 0) && (ptr < ((char*)content + length)));
                if (pclose(fp) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - patch failed\n");
+                       syslog(LOG_ERR, "pclose() returned an error - patch failed\n");
                }
        }
 
        if (!strcasecmp(this_rev, hecbd->stop_when)) {
                /* Found our target rev.  Tell any subsequent callbacks to suppress processing. */
-               CtdlLogPrintf(CTDL_DEBUG, "Target revision has been reached -- stop patching.\n");
+               syslog(LOG_DEBUG, "Target revision has been reached -- stop patching.\n");
                hecbd->done = 1;
        }
 }
@@ -522,7 +522,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                fclose(fp);
        }
        else {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
+               syslog(LOG_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
        }
        CtdlFreeMessage(msg);
 
@@ -580,7 +580,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        fseek(fp, 0L, SEEK_SET);
                        msg->cm_fields['M'] = malloc(len + 1);
                        rv = fread(msg->cm_fields['M'], len, 1, fp);
-                       CtdlLogPrintf(CTDL_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
+                       syslog(LOG_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
                        msg->cm_fields['M'][len] = 0;
                        fclose(fp);
                }
index 922288f695bed26f71e7f404d2c15d9da2042098..a3084c6b1e1debeeaf87b55b327f6a03944e5e9d 100644 (file)
@@ -179,9 +179,9 @@ void xmpp_xml_start(void *data, const char *supplied_el, const char **attr) {
        }
 
        /*
-       CtdlLogPrintf(CTDL_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
+       syslog(LOG_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
        for (i=0; attr[i] != NULL; i+=2) {
-               CtdlLogPrintf(CTDL_DEBUG, "                    Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
+               syslog(LOG_DEBUG, "                    Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
        }
        uncomment for more verbosity */
 
@@ -251,9 +251,9 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        /*
-       CtdlLogPrintf(CTDL_DEBUG, "XMPP ELEMENT END  : <%s>\n", el);
+       syslog(LOG_DEBUG, "XMPP ELEMENT END  : <%s>\n", el);
        if (XMPP->chardata_len > 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "          chardata: %s\n", XMPP->chardata);
+               syslog(LOG_DEBUG, "          chardata: %s\n", XMPP->chardata);
        }
        uncomment for more verbosity */
 
@@ -314,7 +314,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                         * Unknown query ... return the XML equivalent of a blank stare
                         */
                        else {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Unknown query <%s> - returning <service-unavailable/>\n",
                                        el
                                );
@@ -449,14 +449,14 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        else if (!strcasecmp(el, "stream")) {
-               CtdlLogPrintf(CTDL_DEBUG, "XMPP client shut down their stream\n");
+               syslog(LOG_DEBUG, "XMPP client shut down their stream\n");
                xmpp_massacre_roster();
                cprintf("</stream>\n");
                CC->kill_me = 1;
        }
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "Ignoring unknown tag <%s>\n", el);
+               syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", el);
        }
 
        XMPP->chardata_len = 0;
@@ -521,7 +521,7 @@ void xmpp_greeting(void) {
 
        XMPP->xp = XML_ParserCreateNS("UTF-8", ':');
        if (XMPP->xp == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
+               syslog(LOG_ALERT, "Cannot create XML parser!\n");
                CC->kill_me = 1;
                return;
        }
@@ -547,7 +547,7 @@ void xmpp_command_loop(void) {
                XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
        }
        else {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
        }
        FreeStrBuf(&stream_input);
index cef4661f5083302309402c63ba03974bf7a3f402..2ef90858c0e25fd0c9c5a169959bfdef0624515e 100644 (file)
@@ -184,12 +184,12 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
                }
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "%d sessions for <%s> are now visible to session %d\n",
+       syslog(LOG_DEBUG, "%d sessions for <%s> are now visible to session %d\n",
                visible_sessions, presence_jid, CC->cs_pid);
 
        if ( (event_type == XMPP_EVT_LOGIN) && (visible_sessions == 1) ) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n",
+               syslog(LOG_DEBUG, "Telling session %d that <%s> logged in\n",
                        CC->cs_pid, presence_jid);
 
                /* Do an unsolicited roster update that adds a new contact. */
@@ -204,7 +204,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
        }
 
        if (visible_sessions == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n",
+               syslog(LOG_DEBUG, "Telling session %d that <%s> logged out\n",
                        CC->cs_pid, presence_jid);
                xmpp_destroy_buddy(presence_jid);
        }
@@ -261,7 +261,7 @@ void xmpp_fetch_mortuary_backend(long msgnum, void *userdata) {
 HashList *xmpp_fetch_mortuary(void) {
        HashList *mortuary = NewHash(1, NULL);
        if (!mortuary) {
-               CtdlLogPrintf(CTDL_ALERT, "NewHash() failed!\n");
+               syslog(LOG_ALERT, "NewHash() failed!\n");
                return(NULL);
        }
 
index ee83d98eca0a8ddcf2b8b627a285f89088bd6c71..993801bf880128e332872d10f2baa1cd78309595 100644 (file)
@@ -88,7 +88,7 @@ void xmpp_iq_roster_query(void)
        if (cptr) {
                for (i=0; i<nContexts; i++) {
                        if (xmpp_is_visible(&cptr[i], CC)) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
+                               syslog(LOG_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
                                xmpp_roster_item(&cptr[i]);
                        }
                }
@@ -124,7 +124,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
                supported_namespace = 1;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
+       syslog(LOG_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
 
        /*
         * Beginning of query result.
@@ -162,7 +162,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
         */
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG,
+               syslog(LOG_DEBUG,
                        "Unknown query namespace '%s' - returning <service-unavailable/>\n",
                        query_xmlns
                );
index 77ce80343ece12c67e3520ed2e6d40eac0e7787c..f9fdd5823b1eb9b8a3f16d31cbbf6432e3fda730 100644 (file)
@@ -66,7 +66,7 @@ void xmpp_queue_event(int event_type, char *email_addr) {
        int purged_something = 0;
        struct CitContext *cptr;
 
-       CtdlLogPrintf(CTDL_DEBUG, "xmpp_queue_event(%d, %s)\n", event_type, email_addr);
+       syslog(LOG_DEBUG, "xmpp_queue_event(%d, %s)\n", event_type, email_addr);
 
        /* Purge events more than a minute old */
        begin_critical_section(S_XMPP_QUEUE);
index 9c8ab860216f2c0cf214bfc626ac4c9612c95a49..bcc67be38c5af4f9dca92bd929ae2b05c3e7a0f7 100644 (file)
@@ -198,7 +198,7 @@ int alias(char *name)
        }
 
        if (strcasecmp(original_name, name)) {
-               CtdlLogPrintf(CTDL_INFO, "%s is being forwarded to %s\n", original_name, name);
+               syslog(LOG_INFO, "%s is being forwarded to %s\n", original_name, name);
        }
 
        /* Change "user @ xxx" to "user" if xxx is an alias for this host */
@@ -206,7 +206,7 @@ int alias(char *name)
                if (name[a] == '@') {
                        if (CtdlHostAlias(&name[a+1]) == hostalias_localhost) {
                                name[a] = 0;
-                               CtdlLogPrintf(CTDL_INFO, "Changed to <%s>\n", name);
+                               syslog(LOG_INFO, "Changed to <%s>\n", name);
                        }
                }
        }
@@ -404,7 +404,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                which_user = &CC->user;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %s, %d) in <%s>\n",
+       syslog(LOG_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %s, %d) in <%s>\n",
                num_target_msgnums, target_msgnums[0],
                (target_setting ? "SET" : "CLEAR"),
                which_set,
@@ -441,17 +441,17 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
 
 
 #if 0  /* This is a special diagnostic section.  Do not allow it to run during normal operation. */
-       CtdlLogPrintf(CTDL_DEBUG, "There are %d messages in the room.\n", num_msgs);
+       syslog(LOG_DEBUG, "There are %d messages in the room.\n", num_msgs);
        for (i=0; i<num_msgs; ++i) {
                if ((i > 0) && (msglist[i] <= msglist[i-1])) abort();
        }
-       CtdlLogPrintf(CTDL_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums);
+       syslog(LOG_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums);
        for (k=0; k<num_target_msgnums; ++k) {
                if ((k > 0) && (target_msgnums[k] <= target_msgnums[k-1])) abort();
        }
 #endif
 
-       CtdlLogPrintf(CTDL_DEBUG, "before update: %s\n", ChrPtr(vset));
+       syslog(LOG_DEBUG, "before update: %s\n", ChrPtr(vset));
 
        /* Translate the existing sequence set into an array of booleans */
        setstr = NewStrBuf();
@@ -574,7 +574,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                vset = new_set;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, " after update: %s\n", ChrPtr(vset));
+       syslog(LOG_DEBUG, " after update: %s\n", ChrPtr(vset));
 
        /* Decide which message set we're manipulating */
        switch (which_set) {
@@ -1157,11 +1157,11 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
        cit_uint8_t ch;
        cit_uint8_t field_header;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
+       syslog(LOG_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
 
 #ifdef MESSAGE_IN_ROOM
        if (!CtdlMessageInRoom(msgnum)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Message %ld not in current room\n", msgnum);
+               syslog(LOG_DEBUG, "Message %ld not in current room\n", msgnum);
                return NULL;
        }
 #endif
@@ -1180,7 +1180,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
         */
        ch = *mptr++;
        if (ch != 255) {
-               CtdlLogPrintf(CTDL_ERR, "Message %ld appears to be corrupted.\n", msgnum);
+               syslog(LOG_ERR, "Message %ld appears to be corrupted.\n", msgnum);
                cdb_free(dmsgtext);
                return NULL;
        }
@@ -1244,7 +1244,7 @@ int is_valid_message(struct CtdlMessage *msg) {
        if (msg == NULL)
                return 0;
        if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
-               CtdlLogPrintf(CTDL_WARNING, "is_valid_message() -- self-check failed\n");
+               syslog(LOG_WARNING, "is_valid_message() -- self-check failed\n");
                return 0;
        }
        return 1;
@@ -1291,7 +1291,7 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
        struct ma_info *ma;
        
        ma = (struct ma_info *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "fixed_output_pre() type=<%s>\n", cbtype);    
+       syslog(LOG_DEBUG, "fixed_output_pre() type=<%s>\n", cbtype);    
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                ++ma->is_ma;
                ma->did_print = 0;
@@ -1311,7 +1311,7 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
        struct ma_info *ma;
        
        ma = (struct ma_info *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "fixed_output_post() type=<%s>\n", cbtype);   
+       syslog(LOG_DEBUG, "fixed_output_post() type=<%s>\n", cbtype);   
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                --ma->is_ma;
                ma->did_print = 0;
@@ -1335,7 +1335,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
 
        ma = (struct ma_info *)cbuserdata;
 
-       CtdlLogPrintf(CTDL_DEBUG,
+       syslog(LOG_DEBUG,
                "fixed_output() part %s: %s (%s) (%ld bytes)\n",
                partnum, filename, cbtype, (long)length);
 
@@ -1344,7 +1344,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
         * we've already printed another section, skip this one.
         */     
        if ( (ma->is_ma) && (ma->did_print) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
+               syslog(LOG_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
                return;
        }
        ma->did_print = 1;
@@ -1416,7 +1416,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
                extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
                if ( (!strcasecmp(buf, cbtype)) && (!ma->freeze) ) {
                        if (i < ma->chosen_pref) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Setting chosen part: <%s>\n", partnum);
+                               syslog(LOG_DEBUG, "Setting chosen part: <%s>\n", partnum);
                                safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
                                ma->chosen_pref = i;
                        }
@@ -1583,7 +1583,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
        struct encapmsg encap;
        int r;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlOutputMsg(msgnum=%ld, mode=%d, section=%s)\n", 
+       syslog(LOG_DEBUG, "CtdlOutputMsg(msgnum=%ld, mode=%d, section=%s)\n", 
                msg_num, mode,
                (section ? section : "<>")
        );
@@ -1603,7 +1603,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
 
 #ifdef MESSAGE_IN_ROOM
        if (!CtdlMessageInRoom(msg_num)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Message %ld not in current room\n", msg_num);
+               syslog(LOG_DEBUG, "Message %ld not in current room\n", msg_num);
                if (do_proto) cprintf("%d Can't locate msg %ld in room\n",
                        ERROR + MESSAGE_NOT_FOUND, msg_num);
                return(om_no_such_msg);
@@ -1690,7 +1690,7 @@ char *qp_encode_email_addrs(char *source)
        if (source == NULL) return source;
        if (IsEmptyStr(source)) return source;
        cit_backtrace();
-       CtdlLogPrintf(CTDL_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
+       syslog(LOG_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
 
        AddrPtr = malloc (sizeof (long) * nAddrPtrMax);
        AddrUtf8 = malloc (sizeof (long) * nAddrPtrMax);
@@ -2170,7 +2170,7 @@ int CtdlOutputPreLoadedMsg(
        char snode[100];
        char mid[100];
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
+       syslog(LOG_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
                ((TheMessage == NULL) ? "NULL" : "not null"),
                mode, headers_only, do_proto, crlf);
 
@@ -2178,7 +2178,7 @@ int CtdlOutputPreLoadedMsg(
        nl = (crlf ? "\r\n" : "\n");
 
        if (!is_valid_message(TheMessage)) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "ERROR: invalid preloaded message for output\n");
                cit_backtrace ();
                return(om_no_such_msg);
@@ -2572,7 +2572,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        long *msgs_to_be_merged = NULL;
        int num_msgs_to_be_merged = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG,
+       syslog(LOG_DEBUG,
                "CtdlSaveMsgPointersInRoom(room=%s, num_msgs=%d, repl=%d, suppress_rca=%d)\n",
                roomname, num_newmsgs, do_repl_check, suppress_refcount_adj
        );
@@ -2588,7 +2588,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        if (CtdlGetRoomLock(&CC->room,
           ((roomname != NULL) ? roomname : CC->room.QRname) )
           != 0) {
-               CtdlLogPrintf(CTDL_ERR, "No such room <%s>\n", roomname);
+               syslog(LOG_ERR, "No such room <%s>\n", roomname);
                return(ERROR + ROOM_NOT_FOUND);
        }
 
@@ -2625,14 +2625,14 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
                }
        }
 
-       CtdlLogPrintf(9, "%d unique messages to be merged\n", num_msgs_to_be_merged);
+       syslog(LOG_DEBUG, "%d unique messages to be merged\n", num_msgs_to_be_merged);
 
        /*
         * Now merge the new messages
         */
        msglist = realloc(msglist, (sizeof(long) * (num_msgs + num_msgs_to_be_merged)) );
        if (msglist == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: can't realloc message list!\n");
+               syslog(LOG_ALERT, "ERROR: can't realloc message list!\n");
        }
        memcpy(&msglist[num_msgs], msgs_to_be_merged, (sizeof(long) * num_msgs_to_be_merged) );
        num_msgs += num_msgs_to_be_merged;
@@ -2656,7 +2656,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
 
        /* Perform replication checks if necessary */
        if ( (DoesThisRoomNeedEuidIndexing(&CC->room)) && (do_repl_check) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() doing repl checks\n");
+               syslog(LOG_DEBUG, "CtdlSaveMsgPointerInRoom() doing repl checks\n");
 
                for (i=0; i<num_msgs_to_be_merged; ++i) {
                        msgid = msgs_to_be_merged[i];
@@ -2686,7 +2686,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        }
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
+               syslog(LOG_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
        }
 
        /* Submit this room for processing by hooks */
@@ -2775,7 +2775,7 @@ long send_message(struct CtdlMessage *msg) {
        /* Write our little bundle of joy into the message base */
        if (cdb_store(CDB_MSGMAIN, &newmsgid, (int)sizeof(long),
                      smr.ser, smr.len) < 0) {
-               CtdlLogPrintf(CTDL_ERR, "Can't store message\n");
+               syslog(LOG_ERR, "Can't store message\n");
                retval = 0L;
        } else {
                if (is_bigmsg) {
@@ -2818,7 +2818,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
         * Check for valid message format
         */
        if (is_valid_message(msg) == 0) {
-               CtdlLogPrintf(CTDL_ERR, "serialize_message() aborting due to invalid message\n");
+               syslog(LOG_ERR, "serialize_message() aborting due to invalid message\n");
                ret->len = 0;
                ret->ser = NULL;
                return;
@@ -2831,7 +2831,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
 
        ret->ser = malloc(ret->len);
        if (ret->ser == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "serialize_message() malloc(%ld) failed: %s\n",
+               syslog(LOG_ERR, "serialize_message() malloc(%ld) failed: %s\n",
                        (long)ret->len, strerror(errno));
                ret->len = 0;
                ret->ser = NULL;
@@ -2849,7 +2849,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
                safestrncpy((char *)&ret->ser[wlen], msg->cm_fields[(int)forder[i]], fieldlen+1);
                wlen = wlen + fieldlen + 1;
        }
-       if (ret->len != wlen) CtdlLogPrintf(CTDL_ERR, "ERROR: len=%ld wlen=%ld\n",
+       if (ret->len != wlen) syslog(LOG_ERR, "ERROR: len=%ld wlen=%ld\n",
                (long)ret->len, (long)wlen);
 
        return;
@@ -2875,7 +2875,7 @@ void dump_message(struct CtdlMessage *msg,        /* unserialized msg */
         * Check for valid message format
         */
        if (is_valid_message(msg) == 0) {
-               CtdlLogPrintf(CTDL_ERR, "dump_message() aborting due to invalid message\n");
+               syslog(LOG_ERR, "dump_message() aborting due to invalid message\n");
                return;
        }
 
@@ -2903,19 +2903,19 @@ void ReplicationChecks(struct CtdlMessage *msg) {
 
        if (DoesThisRoomNeedEuidIndexing(&CC->room) == 0) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing replication checks in <%s>\n",
+       syslog(LOG_DEBUG, "Performing replication checks in <%s>\n",
                CC->room.QRname);
 
        /* No exclusive id?  Don't do anything. */
        if (msg == NULL) return;
        if (msg->cm_fields['E'] == NULL) return;
        if (IsEmptyStr(msg->cm_fields['E'])) return;
-       /*CtdlLogPrintf(CTDL_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
+       /*syslog(LOG_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
                msg->cm_fields['E'], CC->room.QRname);*/
 
        old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields['E'], &CC->room);
        if (old_msgnum > 0L) {
-               CtdlLogPrintf(CTDL_DEBUG, "ReplicationChecks() replacing message %ld\n", old_msgnum);
+               syslog(LOG_DEBUG, "ReplicationChecks() replacing message %ld\n", old_msgnum);
                CtdlDeleteMessages(CC->room.QRname, &old_msgnum, 1, "");
        }
 }
@@ -2958,7 +2958,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        size_t tmp = 0;
        int rv = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlSubmitMsg() called\n");
+       syslog(LOG_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
@@ -2994,7 +2994,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 
        /* Learn about what's inside, because it's what's inside that counts */
        if (msg->cm_fields['M'] == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: attempt to save message with NULL body\n");
+               syslog(LOG_ERR, "ERROR: attempt to save message with NULL body\n");
                return(-2);
        }
 
@@ -3026,7 +3026,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Goto the correct room */
-       CtdlLogPrintf(CTDL_DEBUG, "Selected room %s\n", (recps) ? CCC->room.QRname : SENTITEMS);
+       syslog(LOG_DEBUG, "Selected room %s\n", (recps) ? CCC->room.QRname : SENTITEMS);
        strcpy(hold_rm, CCC->room.QRname);
        strcpy(actual_rm, CCC->room.QRname);
        if (recps != NULL) {
@@ -3038,7 +3038,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                if (CCC->user.axlevel == AxProbU) {
                        strcpy(hold_rm, actual_rm);
                        strcpy(actual_rm, config.c_twitroom);
-                       CtdlLogPrintf(CTDL_DEBUG, "Diverting to twit room\n");
+                       syslog(LOG_DEBUG, "Diverting to twit room\n");
                }
        }
 
@@ -3047,7 +3047,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                strcpy(actual_rm, force_room);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Final selection: %s\n", actual_rm);
+       syslog(LOG_DEBUG, "Final selection: %s\n", actual_rm);
        if (strcasecmp(actual_rm, CCC->room.QRname)) {
                /* CtdlGetRoom(&CCC->room, actual_rm); */
                CtdlUserGoto(actual_rm, 0, 1, NULL, NULL);
@@ -3061,7 +3061,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Perform "before save" hooks (aborting if any return nonzero) */
-       CtdlLogPrintf(CTDL_DEBUG, "Performing before-save hooks\n");
+       syslog(LOG_DEBUG, "Performing before-save hooks\n");
        if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-3);
 
        /*
@@ -3073,7 +3073,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Save it to disk */
-       CtdlLogPrintf(CTDL_DEBUG, "Saving to disk\n");
+       syslog(LOG_DEBUG, "Saving to disk\n");
        newmsgid = send_message(msg);
        if (newmsgid <= 0L) return(-5);
 
@@ -3081,7 +3081,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         * be a critical section because nobody else knows about this message
         * yet.
         */
-       CtdlLogPrintf(CTDL_DEBUG, "Creating MetaData record\n");
+       syslog(LOG_DEBUG, "Creating MetaData record\n");
        memset(&smi, 0, sizeof(struct MetaData));
        smi.meta_msgnum = newmsgid;
        smi.meta_refcount = 0;
@@ -3099,7 +3099,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         *    message to attach to the journalized copy.
         */
        if (CCC->redirect_buffer != NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "CCC->redirect_buffer is not NULL during message submission!\n");
+               syslog(LOG_ALERT, "CCC->redirect_buffer is not NULL during message submission!\n");
                abort();
        }
        CCC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
@@ -3111,7 +3111,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        PutMetaData(&smi);
 
        /* Now figure out where to store the pointers */
-       CtdlLogPrintf(CTDL_DEBUG, "Storing pointers\n");
+       syslog(LOG_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
@@ -3119,7 +3119,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         */
        if ((!CCC->internal_pgm) || (recps == NULL)) {
                if (CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 1, msg) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "ERROR saving message pointer!\n");
+                       syslog(LOG_ERR, "ERROR saving message pointer!\n");
                        CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0, msg);
                }
        }
@@ -3134,12 +3134,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
          for (i=0; i<num_tokens(recps->recp_room, '|'); ++i) {
                extract_token(recipient, recps->recp_room, i,
                                        '|', sizeof recipient);
-               CtdlLogPrintf(CTDL_DEBUG, "Delivering to room <%s>\n", recipient);
+               syslog(LOG_DEBUG, "Delivering to room <%s>\n", recipient);
                CtdlSaveMsgPointerInRoom(recipient, newmsgid, 0, msg);
        }
 
        /* Bump this user's messages posted counter. */
-       CtdlLogPrintf(CTDL_DEBUG, "Updating user\n");
+       syslog(LOG_DEBUG, "Updating user\n");
        CtdlGetUserLock(&CCC->user, CCC->curr_user);
        CCC->user.posted = CCC->user.posted + 1;
        CtdlPutUserLock(&CCC->user);
@@ -3162,7 +3162,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
          for (i=0; i<num_tokens(recps->recp_local, '|'); ++i) {
                extract_token(recipient, recps->recp_local, i,
                                        '|', sizeof recipient);
-               CtdlLogPrintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
+               syslog(LOG_DEBUG, "Delivering private local mail to <%s>\n",
                        recipient);
                if (CtdlGetUser(&userbuf, recipient) == 0) {
                        // Add a flag so the Funambol module knows its mail
@@ -3197,14 +3197,14 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
                        }
                }
                else {
-                       CtdlLogPrintf(CTDL_DEBUG, "No user <%s>\n", recipient);
+                       syslog(LOG_DEBUG, "No user <%s>\n", recipient);
                        CtdlSaveMsgPointerInRoom(config.c_aideroom,
                                newmsgid, 0, msg);
                }
        }
 
        /* Perform "after save" hooks */
-       CtdlLogPrintf(CTDL_DEBUG, "Performing after-save hooks\n");
+       syslog(LOG_DEBUG, "Performing after-save hooks\n");
        PerformMessageHooks(msg, EVT_AFTERSAVE);
 
        /* For IGnet mail, we have to save a new copy into the spooler for
@@ -3248,7 +3248,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Go back to the room we started from */
-       CtdlLogPrintf(CTDL_DEBUG, "Returning to original room %s\n", hold_rm);
+       syslog(LOG_DEBUG, "Returning to original room %s\n", hold_rm);
        if (strcasecmp(hold_rm, CCC->room.QRname))
                CtdlUserGoto(hold_rm, 0, 1, NULL, NULL);
 
@@ -3258,7 +3258,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         * contain a recipient.
         */
        if ((recps != NULL) && (recps->num_internet > 0)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Generating delivery instructions\n");
+               syslog(LOG_DEBUG, "Generating delivery instructions\n");
                instr_alloc = 1024;
                instr = malloc(instr_alloc);
                snprintf(instr, instr_alloc,
@@ -3854,7 +3854,7 @@ struct recptypes *validate_recipients(const char *supplied_recipients,
                striplt(this_recp);
                if (IsEmptyStr(this_recp))
                        break;
-               CtdlLogPrintf(CTDL_DEBUG, "Evaluating recipient #%d: %s\n", num_recps, this_recp);
+               syslog(LOG_DEBUG, "Evaluating recipient #%d: %s\n", num_recps, this_recp);
                ++num_recps;
                mailtype = alias(this_recp);
                mailtype = alias(this_recp);
@@ -3998,12 +3998,12 @@ struct recptypes *validate_recipients(const char *supplied_recipients,
                strcpy(ret->errormsg, "No recipients specified.");
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "validate_recipients()\n");
-       CtdlLogPrintf(CTDL_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
-       CtdlLogPrintf(CTDL_DEBUG, "  room: %d <%s>\n", ret->num_room, ret->recp_room);
-       CtdlLogPrintf(CTDL_DEBUG, "  inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
-       CtdlLogPrintf(CTDL_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
-       CtdlLogPrintf(CTDL_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
+       syslog(LOG_DEBUG, "validate_recipients()\n");
+       syslog(LOG_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
+       syslog(LOG_DEBUG, "  room: %d <%s>\n", ret->num_room, ret->recp_room);
+       syslog(LOG_DEBUG, "  inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
+       syslog(LOG_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
+       syslog(LOG_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
 
        free(recipients);
        return(ret);
@@ -4020,7 +4020,7 @@ void free_recipients(struct recptypes *valid) {
        }
 
        if (valid->recptypes_magic != RECPTYPES_MAGIC) {
-               CtdlLogPrintf(CTDL_EMERG, "Attempt to call free_recipients() on some other data type!\n");
+               syslog(LOG_EMERG, "Attempt to call free_recipients() on some other data type!\n");
                abort();
        }
 
@@ -4377,12 +4377,12 @@ int CtdlDeleteMessages(char *room_name,         /* which room */
                regcomp(&re, content_type, 0);
                need_to_free_re = 1;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlDeleteMessages(%s, %d msgs, %s)\n",
+       syslog(LOG_DEBUG, "CtdlDeleteMessages(%s, %d msgs, %s)\n",
                room_name, num_dmsgnums, content_type);
 
        /* get room record, obtaining a lock... */
        if (CtdlGetRoomLock(&qrbuf, room_name) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
+               syslog(LOG_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
                        room_name);
                if (need_to_free_re) regfree(&re);
                return (0);     /* room not found */
@@ -4459,7 +4459,7 @@ int CtdlDeleteMessages(char *room_name,           /* which room */
        /* Now free the memory we used, and go away. */
        if (msglist != NULL) free(msglist);
        if (dellist != NULL) free(dellist);
-       CtdlLogPrintf(CTDL_DEBUG, "%d message(s) deleted.\n", num_deleted);
+       syslog(LOG_DEBUG, "%d message(s) deleted.\n", num_deleted);
        if (need_to_free_re) regfree(&re);
        return (num_deleted);
 }
@@ -4693,7 +4693,7 @@ void AdjRefCount(long msgnum, int incr)
        struct arcq new_arcq;
        int rv = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "AdjRefCount() msg %ld ref count delta %+d\n",
+       syslog(LOG_DEBUG, "AdjRefCount() msg %ld ref count delta %+d\n",
                msgnum, incr
        );
 
@@ -4705,7 +4705,7 @@ void AdjRefCount(long msgnum, int incr)
 
        /* msgnum < 0 means that we're trying to close the file */
        if (msgnum < 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Closing the AdjRefCount queue file\n");
+               syslog(LOG_DEBUG, "Closing the AdjRefCount queue file\n");
                begin_critical_section(S_SUPPMSGMAIN);
                if (arcfp != NULL) {
                        fclose(arcfp);
@@ -4757,7 +4757,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
 
        r = link(file_arcq, file_arcq_temp);
        if (r != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
                end_critical_section(S_SUPPMSGMAIN);
                return(num_records_processed);
        }
@@ -4767,7 +4767,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
 
        fp = fopen(file_arcq_temp, "rb");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
                return(num_records_processed);
        }
 
@@ -4779,7 +4779,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
        fclose(fp);
        r = unlink(file_arcq_temp);
        if (r != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
        }
 
        return(num_records_processed);
@@ -4810,7 +4810,7 @@ void TDAP_AdjRefCount(long msgnum, int incr)
        smi.meta_refcount += incr;
        PutMetaData(&smi);
        end_critical_section(S_SUPPMSGMAIN);
-       CtdlLogPrintf(CTDL_DEBUG, "TDAP_AdjRefCount() msg %ld ref count delta %+d, is now %d\n",
+       syslog(LOG_DEBUG, "TDAP_AdjRefCount() msg %ld ref count delta %+d, is now %d\n",
                msgnum, incr, smi.meta_refcount
        );
 
@@ -4818,7 +4818,7 @@ void TDAP_AdjRefCount(long msgnum, int incr)
         * (and its supplementary record as well).
         */
        if (smi.meta_refcount == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
+               syslog(LOG_DEBUG, "Deleting message <%ld>\n", msgnum);
                
                /* Call delete hooks with NULL room to show it has gone altogether */
                PerformDeleteHooks(NULL, msgnum);
@@ -4864,7 +4864,7 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
                safestrncpy(roomname, req_room, sizeof(roomname));
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Raw length is %ld\n", (long)raw_length);
+       syslog(LOG_DEBUG, "Raw length is %ld\n", (long)raw_length);
 
        if (is_binary) {
                encoded_message = malloc((size_t) (((raw_length * 134) / 100) + 4096 ) );
@@ -4902,7 +4902,7 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
                );
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Allocating\n");
+       syslog(LOG_DEBUG, "Allocating\n");
        msg = malloc(sizeof(struct CtdlMessage));
        memset(msg, 0, sizeof(struct CtdlMessage));
        msg->cm_magic = CTDLMESSAGE_MAGIC;
@@ -4926,7 +4926,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) {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleted %d other msgs of this type\n",
+               syslog(LOG_DEBUG, "Deleted %d other msgs of this type\n",
                        CtdlDeleteMessages(roomname, NULL, 0, content_type)
                );
        }
index c48cfbbc5d4e2fc447c7bdbf9fadd277dac5325c..4120538cce869d22a190353866a06d8204214b20 100644 (file)
@@ -94,7 +94,7 @@
 /* Copy the first part of user declarations.  */
 #line 1 "parsedate.y"
 
-/* $Revision: 4003 $
+/* $Revision$
 **
 **  Originally written by Steven M. Bellovin <smb@research.att.com> while
 **  at the University of North Carolina at Chapel Hill.  Later tweaked by
@@ -242,7 +242,7 @@ typedef union YYSTYPE
     time_t             Number;
     enum _MERIDIAN     Meridian;
 }
-/* Line 187 of yacc.c.  */
+/* Line 193 of yacc.c.  */
 #line 247 "y.tab.c"
        YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
index c6801b6d352b2d7f4c4e665eedd9fa71d64add9f..91fca856b2412078ab020815170d80ba33ceeb52 100644 (file)
@@ -1019,7 +1019,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
 
        if (retmsgs != NULL) *retmsgs = total_messages;
        if (retnew != NULL) *retnew = new_messages;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
+       syslog(LOG_DEBUG, "<%s> %d new of %d total messages\n",
                CC->room.QRname,
                new_messages, total_messages
        );
@@ -1162,7 +1162,7 @@ void cmd_goto(char *gargs)
                                   ((ra & UA_KNOWN) == 0) &&
                                   (CC->user.axlevel < AxAideU)
                                   ) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Failed to acquire private room\n");
+                               syslog(LOG_DEBUG, "Failed to acquire private room\n");
                        } else {
                                memcpy(&CC->room, &QRscratch,
                                        sizeof(struct ctdlroom));
@@ -1342,7 +1342,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
        long owner = 0L;
        char actual_old_name[ROOMNAMELEN];
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
+       syslog(LOG_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
                old_name, new_name, new_floor);
 
        if (new_floor >= 0) {
@@ -1433,11 +1433,11 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
                lgetfloor(&flbuf, old_floor);
                --flbuf.f_ref_count;
                lputfloor(&flbuf, old_floor);
-               CtdlLogPrintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
+               syslog(LOG_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);
-               CtdlLogPrintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
+               syslog(LOG_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
        }
 
        /* ...and everybody say "YATTA!" */     
@@ -1686,7 +1686,7 @@ void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf)
        char old_name[ROOMNAMELEN];
        static int seq = 0;
 
-       CtdlLogPrintf(CTDL_NOTICE, "Scheduling room <%s> for deletion\n",
+       syslog(LOG_NOTICE, "Scheduling room <%s> for deletion\n",
                qrbuf->QRname);
 
        safestrncpy(old_name, qrbuf->QRname, sizeof old_name);
@@ -1724,7 +1724,7 @@ void CtdlDeleteRoom(struct ctdlroom *qrbuf)
        char filename[100];
        /* TODO: filename magic? does this realy work? */
 
-       CtdlLogPrintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
+       syslog(LOG_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
 
        /* Delete the info file */
        assoc_file_name(filename, sizeof filename, qrbuf, ctdl_info_dir);
@@ -1855,11 +1855,11 @@ unsigned CtdlCreateRoom(char *new_room_name,
        struct floor flbuf;
        visit vbuf;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
+       syslog(LOG_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
                new_room_name, new_room_type, new_room_view);
 
        if (CtdlGetRoom(&qrbuf, new_room_name) == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
+               syslog(LOG_DEBUG, "%s already exists.\n", new_room_name);
                return(0);
        }
 
@@ -2067,9 +2067,9 @@ void cmd_einf(char *ok)
                return;
        }
        assoc_file_name(infofilename, sizeof infofilename, &CC->room, ctdl_info_dir);
-       CtdlLogPrintf(CTDL_DEBUG, "opening\n");
+       syslog(LOG_DEBUG, "opening\n");
        fp = fopen(infofilename, "w");
-       CtdlLogPrintf(CTDL_DEBUG, "checking\n");
+       syslog(LOG_DEBUG, "checking\n");
        if (fp == NULL) {
                cprintf("%d Cannot open %s: %s\n",
                  ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
index cd89694d14ca20bc90db68fc999b24aa98c08621..b9eeef46f8d9c9fff224c1c7d2489cdb502e8a9b 100755 (executable)
@@ -81,7 +81,7 @@ cat <<EOF  >$U_FILE
 void upgrade_modules (void)
 {
 
-    CtdlLogPrintf (CTDL_INFO, "Upgrade modules.\n");
+    syslog(LOG_INFO, "Upgrade modules.\n");
 
 EOF
 
@@ -118,17 +118,17 @@ void initialise_modules (int threading)
     nSizErrmsg = 0;
 
     if (threading)
-        CtdlLogPrintf (CTDL_INFO, "Initialize modules, CtdlThreads enabled.\n");
+        syslog(LOG_INFO, "Initialize modules, CtdlThreads enabled.\n");
     else
-        CtdlLogPrintf (CTDL_INFO, "Initialize modules, CtdlThreads not yet enabled.\n");
+        syslog(LOG_INFO, "Initialize modules, CtdlThreads not yet enabled.\n");
 /* static server initialization: */
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(citserver));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(control));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(euidindex));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(file_ops));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(msgbase));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(room_ops));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(user_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(citserver));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(control));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(euidindex));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(file_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(msgbase));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(room_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(user_ops));
 /* dynamic modules: */
 
 EOF
@@ -165,7 +165,7 @@ do
                RES_OUT=`echo $RES | cut -b2-`
                /usr/bin/printf "Found entry point in file $i\n"
 cat <<EOF  >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 
 EOF
 cat <<EOF >>$H_FILE
@@ -177,7 +177,7 @@ EOF
                RES_OUT=`echo $RES | cut -b2-`
                /usr/bin/printf "Found upgrade point in file $i\n"
 cat <<EOF  >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 
 EOF
 cat <<EOF >>$H_FILE
@@ -215,7 +215,7 @@ EOF
                                                /usr/bin/printf "Found entry point in file modules/$j/$k\n"
 # Add this entry point to the .c file
 cat <<EOF >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 EOF
 # Add this entry point to the .h file
 cat <<EOF >> $H_FILE
@@ -228,7 +228,7 @@ EOF
                                                /usr/bin/printf "Found upgrade point in file modules/$j/$k\n"
 # Add this entry point to the .c file
 cat <<EOF >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 EOF
 # Add this entry point to the .h file
 cat <<EOF >> $H_FILE
@@ -271,7 +271,7 @@ EOF
                                                RES_OUT=`echo $RES | cut -b2-`
                                                /usr/bin/printf "Found entry point in file user_modules/$j/$k\n"
 cat <<EOF >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 EOF
 cat <<EOF >> $H_FILE
 CTDL_MODULE_INIT($RES_OUT);
@@ -282,7 +282,7 @@ EOF
                                                RES_OUT=`echo $RES | cut -b2-`
                                                /usr/bin/printf "Found upgrade point in file user_modules/$j/$k\n"
 cat <<EOF >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 EOF
 cat <<EOF >> $H_FILE
 CTDL_MODULE_UPGRADE($RES_OUT);
index e23772e9602c9f72086375e5e185b7ecec7b6de2..df80cc845424658f94cfc7c5d4f3d706824f8aaa 100644 (file)
@@ -1,6 +1,22 @@
 /*
  * Citadel Dynamic Loading Module
  * Written by Brian Costello <btx@calyx.net>
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -12,6 +28,7 @@
 #include <string.h>
 #include <limits.h>
 #include <ctype.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -109,8 +126,8 @@ void LogPrintMessages(long err)
 
        snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
 
-       CtdlLogPrintf(0,Message);
-       CtdlLogPrintf(0,ErrSubject);
+       syslog(LOG_EMERG,Message);
+       syslog(LOG_EMERG,ErrSubject);
        quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
        if (errormessages!=NULL) free (errormessages);
        errormessages = NULL;
@@ -225,7 +242,7 @@ void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
        p->desc = desc;
 
        Put(ProtoHookList, cmd, 4, p, NULL);
-       CtdlLogPrintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
+       syslog(LOG_INFO, "Registered server command %s (%s)\n", cmd, desc);
 }
 
 void CtdlDestroyProtoHooks(void)
@@ -246,7 +263,7 @@ void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
        newfcn->h_function_pointer = fcn_ptr;
        CleanupHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new cleanup function\n");
+       syslog(LOG_INFO, "Registered a new cleanup function\n");
 }
 
 
@@ -258,7 +275,7 @@ void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered cleanup function\n");
+                       syslog(LOG_INFO, "Unregistered cleanup function\n");
                        p = cur->next;
                        if (cur == CleanupHookTable) {
                                CleanupHookTable = p;
@@ -276,7 +293,7 @@ void CtdlDestroyCleanupHooks(void)
        cur = CleanupHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed cleanup function\n");
+               syslog(LOG_INFO, "Destroyed cleanup function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -297,7 +314,7 @@ void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
        newfcn->eventtype = EventType;
        SessionHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new session function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new session function (type %d)\n",
                EventType);
 }
 
@@ -311,7 +328,7 @@ void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered session function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered session function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == SessionHookTable) {
@@ -330,7 +347,7 @@ void CtdlDestroySessionHooks(void)
        cur = SessionHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed session function\n");
+               syslog(LOG_INFO, "Destroyed session function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -351,7 +368,7 @@ void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
        newfcn->eventtype = EventType;
        UserHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new user function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new user function (type %d)\n",
                EventType);
 }
 
@@ -365,7 +382,7 @@ void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered user function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered user function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == UserHookTable) {
@@ -384,7 +401,7 @@ void CtdlDestroyUserHooks(void)
        cur = UserHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed user function \n");
+               syslog(LOG_INFO, "Destroyed user function \n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -406,7 +423,7 @@ void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
        newfcn->eventtype = EventType;
        MessageHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new message function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new message function (type %d)\n",
                EventType);
 }
 
@@ -421,7 +438,7 @@ void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
                while (cur != NULL &&
                                handler == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered message function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered message function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == MessageHookTable) {
@@ -440,7 +457,7 @@ void CtdlDestroyMessageHook(void)
        cur = MessageHookTable; 
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed message function (type %d)\n", cur->eventtype);
+               syslog(LOG_INFO, "Destroyed message function (type %d)\n", cur->eventtype);
                p = cur->next;
                free(cur);
                cur = p;
@@ -459,7 +476,7 @@ void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
        newfcn->fcn_ptr = fcn_ptr;
        RoomHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new room function\n");
+       syslog(LOG_INFO, "Registered a new room function\n");
 }
 
 
@@ -469,7 +486,7 @@ void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
 
        for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
                while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered room function\n");
+                       syslog(LOG_INFO, "Unregistered room function\n");
                        p = cur->next;
                        if (cur == RoomHookTable) {
                                RoomHookTable = p;
@@ -488,7 +505,7 @@ void CtdlDestroyRoomHooks(void)
        cur = RoomHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed room function\n");
+               syslog(LOG_INFO, "Destroyed room function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -506,7 +523,7 @@ void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
        newfcn->h_function_pointer = handler;
        NetprocHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new netproc function\n");
+       syslog(LOG_INFO, "Registered a new netproc function\n");
 }
 
 
@@ -518,7 +535,7 @@ void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                handler == cur->h_function_pointer ) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered netproc function\n");
+                       syslog(LOG_INFO, "Unregistered netproc function\n");
                        p = cur->next;
                        if (cur == NetprocHookTable) {
                                NetprocHookTable = p;
@@ -536,7 +553,7 @@ void CtdlDestroyNetprocHooks(void)
        cur = NetprocHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed netproc function\n");
+               syslog(LOG_INFO, "Destroyed netproc function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -555,7 +572,7 @@ void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
        newfcn->h_function_pointer = handler;
        DeleteHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new delete function\n");
+       syslog(LOG_INFO, "Registered a new delete function\n");
 }
 
 
@@ -567,7 +584,7 @@ void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                handler == cur->h_function_pointer ) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered delete function\n");
+                       syslog(LOG_INFO, "Unregistered delete function\n");
                        p = cur->next;
                        if (cur == DeleteHookTable) {
                                DeleteHookTable = p;
@@ -584,7 +601,7 @@ void CtdlDestroyDeleteHooks(void)
        cur = DeleteHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed delete function\n");
+               syslog(LOG_INFO, "Destroyed delete function\n");
                p = cur->next;
                free(cur);
                cur = p;                
@@ -606,7 +623,7 @@ void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int
        safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
        FixedOutputTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
+       syslog(LOG_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
 }
 
 
@@ -617,7 +634,7 @@ void CtdlUnregisterFixedOutputHook(char *content_type)
        for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
                /* This will also remove duplicates if any */
                while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
+                       syslog(LOG_INFO, "Unregistered fixed output function for %s\n", content_type);
                        p = cur->next;
                        if (cur == FixedOutputTable) {
                                FixedOutputTable = p;
@@ -635,7 +652,7 @@ void CtdlDestroyFixedOutputHooks(void)
        cur = FixedOutputTable; 
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
+               syslog(LOG_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
                p = cur->next;
                free(cur);
                cur = p;
@@ -672,7 +689,7 @@ void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int o
        newfcn->order = order;
        newfcn->h_function_pointer = fcn_ptr;
        XmsgHookTable = newfcn;
-       CtdlLogPrintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
+       syslog(LOG_INFO, "Registered a new x-msg function (priority %d)\n", order);
 }
 
 
@@ -685,7 +702,7 @@ void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                order == cur->order) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered x-msg function "
+                       syslog(LOG_INFO, "Unregistered x-msg function "
                                        "(priority %d)\n", order);
                        p = cur->next;
                        if (cur == XmsgHookTable) {
@@ -704,7 +721,7 @@ void CtdlDestroyXmsgHooks(void)
        cur = XmsgHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed x-msg function "
+               syslog(LOG_INFO, "Destroyed x-msg function "
                        "(priority %d)\n", cur->order);
                p = cur->next;
                        
@@ -743,7 +760,7 @@ void CtdlRegisterServiceHook(int tcp_port,
                snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
        }
        else if (tcp_port <= 0) {       /* port -1 to disable */
-               CtdlLogPrintf(CTDL_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
+               syslog(LOG_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
                free (message);
                free(newfcn);
                return;
@@ -760,12 +777,12 @@ void CtdlRegisterServiceHook(int tcp_port,
        if (newfcn->msock > 0) {
                ServiceHookTable = newfcn;
                strcat(message, "registered.");
-               CtdlLogPrintf(CTDL_INFO, "%s\n", message);
+               syslog(LOG_INFO, "%s\n", message);
        }
        else {
                AddPortError(message, error);
                strcat(message, "FAILED.");
-               CtdlLogPrintf(CTDL_CRIT, "%s\n", message);
+               syslog(LOG_CRIT, "%s\n", message);
                free(newfcn);
        }
        free(message);
@@ -792,12 +809,12 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
                                tcp_port == cur->tcp_port) {
                        close(cur->msock);
                        if (sockpath) {
-                               CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+                               syslog(LOG_INFO, "Closed UNIX domain socket %s\n",
                                                sockpath);
                        } else if (tcp_port) {
-                               CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
+                               syslog(LOG_INFO, "Closed TCP port %d\n", tcp_port);
                        } else {
-                               CtdlLogPrintf(CTDL_INFO, "Unregistered service \"%s\"\n", cur->ServiceName);
+                               syslog(LOG_INFO, "Unregistered service \"%s\"\n", cur->ServiceName);
                        }
                        p = cur->next;
                        if (cur == ServiceHookTable) {
@@ -823,11 +840,11 @@ void CtdlShutdownServiceHooks(void)
                        close(cur->msock);
                        cur->msock = -1;
                        if (cur->sockpath != NULL){
-                               CtdlLogPrintf(CTDL_INFO, "[%s] Closed UNIX domain socket %s\n",
+                               syslog(LOG_INFO, "[%s] Closed UNIX domain socket %s\n",
                                              cur->ServiceName,
                                              cur->sockpath);
                        } else {
-                               CtdlLogPrintf(CTDL_INFO, "[%s] closing service\n", 
+                               syslog(LOG_INFO, "[%s] closing service\n", 
                                              cur->ServiceName);
                        }
                }
@@ -844,12 +861,12 @@ void CtdlDestroyServiceHook(void)
        {
                close(cur->msock);
                if (cur->sockpath) {
-                       CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+                       syslog(LOG_INFO, "Closed UNIX domain socket %s\n",
                                cur->sockpath);
                } else if (cur->tcp_port) {
-                       CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
+                       syslog(LOG_INFO, "Closed TCP port %d\n", cur->tcp_port);
                } else {
-                       CtdlLogPrintf(CTDL_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
+                       syslog(LOG_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
                }
                p = cur->next;
                free(cur);
@@ -873,7 +890,7 @@ void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), c
        newfcn->fcn_ptr = fcn_ptr;
        SearchFunctionHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new search function (%s)\n", name);
+       syslog(LOG_INFO, "Registered a new search function (%s)\n", name);
 }
 
 void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name)
@@ -882,7 +899,7 @@ void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *),
        
        for (cur = SearchFunctionHookTable; cur != NULL; cur = cur->next) {
                while (fcn_ptr && (cur->fcn_ptr == fcn_ptr) && name && !strcmp(name, cur->name)) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered search function(%s)\n", name);
+                       syslog(LOG_INFO, "Unregistered search function(%s)\n", name);
                        p = cur->next;
                        if (cur == SearchFunctionHookTable) {
                                SearchFunctionHookTable = p;
@@ -952,11 +969,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.
-       CtdlLogPrintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
+       syslog(LOG_DEBUG, "** Event type is %d, flags are %d\n",
                EventType, msg->cm_flags);
         */
        if (msg->cm_flags & CM_SKIP_HOOKS) {
-               CtdlLogPrintf(CTDL_DEBUG, "Skipping hooks\n");
+               syslog(LOG_DEBUG, "Skipping hooks\n");
                return(0);
        }
 
@@ -982,7 +999,7 @@ int PerformRoomHooks(struct ctdlroom *target_room)
        struct RoomFunctionHook *fcn;
        int total_retval = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
+       syslog(LOG_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
 
        for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
                total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
index d4558f86d5299c3061406adbe70a3d869d474ceb..86cf5b0b031eb7d1c0dc2792ac9d6bda00f6336c 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * citserver's main() function lives here.
  * 
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -105,9 +105,9 @@ int main(int argc, char **argv)
        int home=0;
        int dbg=0;
        int have_log=0;
-       int have_minus_x=0;
        char relhome[PATH_MAX]="";
        char ctdldir[PATH_MAX]=CTDLDIR;
+       int syslog_facility = LOG_DAEMON;
 #ifdef HAVE_RUN_DIR
        struct stat filestats;
 #endif
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
 
 
        /* initialise semaphores here. Patch by Matt and davew
-        * its called here as they are needed by CtdlLogPrintf for thread safety
+        * its called here as they are needed by syslog for thread safety
         */
        InitialiseSemaphores();
        
@@ -136,7 +136,6 @@ int main(int argc, char **argv)
                if (!strncmp(argv[a], "-l", 2)) {
                        safestrncpy(facility, &argv[a][2], sizeof(facility));
                        syslog_facility = SyslogFacility(facility);
-                       enable_syslog = 1;
                }
 
                /* run in the background if -d was specified */
@@ -149,12 +148,6 @@ int main(int argc, char **argv)
                        statcount = atoi(&argv[a][2]);
                }
 
-               /* -x specifies the desired logging level */
-               else if (!strncmp(argv[a], "-x", 2)) {
-                       verbosity = atoi(&argv[a][2]);
-                       have_minus_x = 1;
-               }
-
                else if (!strncmp(argv[a], "-h", 2)) {
                        relh=argv[a][2]!='/';
                        if (!relh) safestrncpy(ctdl_home_directory, &argv[a][2],
@@ -165,10 +158,14 @@ int main(int argc, char **argv)
                        home=1;
                }
 
+               else if (!strncmp(argv[a], "-x", 2)) {
+                       /* deprecated */
+               }
+
                else if (!strncmp(argv[a], "-t", 2)) {
                        if (freopen(&argv[a][2], "w", stderr) != stderr)
                        {
-                               CtdlLogPrintf(CTDL_EMERG, 
+                               syslog(LOG_EMERG, 
                                              "unable to open your trace log [%s]: %s", 
                                              &argv[a][2], 
                                              strerror(errno));
@@ -189,19 +186,22 @@ int main(int argc, char **argv)
 
                /* any other parameter makes it crash and burn */
                else {
-                       CtdlLogPrintf(CTDL_EMERG,       "citserver: usage: "
+                       fprintf(stderr, "citserver: usage: "
                                        "citserver "
                                        "[-lLogFacility] "
-                                       "[-d] [-D] [-s]"
-                                       " [-tTraceFile]"
-                                       " [-xLogLevel] [-hHomeDir]\n");
+                                       "[-d] [-D] [-s] "
+                                       "[-tTraceFile] "
+                                       "[-hHomeDir]\n"
+                       );
                        exit(1);
                }
 
        }
 
-       if (have_minus_x && running_as_daemon && have_log)
-               print_to_logfile = 1;
+       openlog("citserver",
+               ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
+               syslog_facility
+       );
 
        calc_dirs_n_files(relh, home, relhome, ctdldir, dbg);
        /* daemonize, if we were asked to */
@@ -226,36 +226,26 @@ int main(int argc, char **argv)
        eCrash_RegisterThread("MasterThread", 0);
 #endif
 
-       /* Initialize the syslogger.  Yes, we are really using 0 as the
-        * facility, because we are going to bitwise-OR the facility to
-        * the severity of each message, allowing us to write to other
-        * facilities when we need to...
-        */
-       if (enable_syslog) {
-               openlog("citadel", LOG_NDELAY, 0);
-               setlogmask(LOG_UPTO(verbosity));
-       }
-       
        /* Tell 'em who's in da house */
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_NOTICE,
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_NOTICE,
                "*** Citadel server engine v%d.%02d (build %s) ***\n",
                (REV_LEVEL/100), (REV_LEVEL%100), svn_revision());
-       CtdlLogPrintf(CTDL_NOTICE, "Copyright (C) 1987-2010 by the Citadel development team.\n");
-       CtdlLogPrintf(CTDL_NOTICE, "This program is distributed under the terms of the GNU "
+       syslog(LOG_NOTICE, "Copyright (C) 1987-2010 by the Citadel development team.\n");
+       syslog(LOG_NOTICE, "This program is distributed under the terms of the GNU "
                                        "General Public License.\n");
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_DEBUG, "Called as: %s\n", argv[0]);
-       CtdlLogPrintf(CTDL_INFO, "%s\n", libcitadel_version_string());
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_DEBUG, "Called as: %s\n", argv[0]);
+       syslog(LOG_INFO, "%s\n", libcitadel_version_string());
 
        /* Load site-specific parameters, and set the ipgm secret */
-       CtdlLogPrintf(CTDL_INFO, "Loading citadel.config\n");
+       syslog(LOG_INFO, "Loading citadel.config\n");
        get_config();
        config.c_ipgm_secret = rand();
 
        /* get_control() MUST MUST MUST be called BEFORE the databases are opened!! */
-       CtdlLogPrintf(CTDL_INFO, "Acquiring control record\n");
+       syslog(LOG_INFO, "Acquiring control record\n");
        get_control();
 
        put_config();
@@ -275,12 +265,12 @@ int main(int argc, char **argv)
 #endif // HAVE_GETPWUID_R
 
                if ((mkdir(ctdl_run_dir, 0755) != 0) && (errno != EEXIST))
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to create run directory [%s]: %s", 
                                      ctdl_run_dir, strerror(errno));
 
                if (chown(ctdl_run_dir, config.c_ctdluid, (pwp==NULL)?-1:pw.pw_gid) != 0)
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to set the access rights for [%s]: %s", 
                                      ctdl_run_dir, strerror(errno));
        }
@@ -304,7 +294,7 @@ int main(int argc, char **argv)
        /*
         * Run any upgrade entry points
         */
-       CtdlLogPrintf(CTDL_INFO, "Upgrading modules.\n");
+       syslog(LOG_INFO, "Upgrading modules.\n");
        upgrade_modules();
        
 /**
@@ -344,7 +334,7 @@ int main(int argc, char **argv)
        /*
         * Load any server-side extensions available here.
         */
-       CtdlLogPrintf(CTDL_INFO, "Initializing server extensions\n");
+       syslog(LOG_INFO, "Initializing server extensions\n");
        size = strlen(ctdl_home_directory) + 9;
        
        initialise_modules(0);
@@ -384,18 +374,18 @@ int main(int argc, char **argv)
 #endif // HAVE_GETPWUID_R
 
                if (pwp == NULL)
-                       CtdlLogPrintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
+                       syslog(LOG_CRIT, "WARNING: getpwuid(%ld): %s\n"
                                   "Group IDs will be incorrect.\n", (long)CTDLUID,
                                strerror(errno));
                else {
                        initgroups(pw.pw_name, pw.pw_gid);
                        if (setgid(pw.pw_gid))
-                               CtdlLogPrintf(CTDL_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
+                               syslog(LOG_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
                                        strerror(errno));
                }
-               CtdlLogPrintf(CTDL_INFO, "Changing uid to %ld\n", (long)CTDLUID);
+               syslog(LOG_INFO, "Changing uid to %ld\n", (long)CTDLUID);
                if (setuid(CTDLUID) != 0) {
-                       CtdlLogPrintf(CTDL_CRIT, "setuid() failed: %s\n", strerror(errno));
+                       syslog(LOG_CRIT, "setuid() failed: %s\n", strerror(errno));
                }
 #if defined (HAVE_SYS_PRCTL_H) && defined (PR_SET_DUMPABLE)
                prctl(PR_SET_DUMPABLE, 1);
index 8ead78e0a65b08e63b90653a874d459f19d20e51..bc415bceb1597ad6c87b5adccd953ed172d6e89c 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Citadel "system dependent" stuff.
- * See COPYING for copyright information.
  *
  * Here's where we (hopefully) have most parts of the Citadel server that
  * would need to be altered to run the server in a non-POSIX environment.
@@ -8,6 +7,21 @@
  * If we ever port to a different platform and either have multiple
  * variants of this file or simply load it up with #ifdefs.
  *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -87,89 +101,6 @@ struct igheap *igheap = NULL;
 #endif
 
 
-int verbosity = DEFAULT_VERBOSITY;             /* Logging level */
-
-int syslog_facility = LOG_DAEMON;
-int enable_syslog = 0;
-int print_to_logfile = 1;
-
-/*
- * CtdlLogPrintf()  ...   Write logging information
- */
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {   
-       va_list arg_ptr;
-       va_start(arg_ptr, format);
-       vCtdlLogPrintf(loglevel, format, arg_ptr);
-       va_end(arg_ptr);
-}
-
-void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr)
-{
-
-       if (enable_syslog) {
-               vsyslog((syslog_facility | loglevel), format, arg_ptr);
-       }
-
-       /* stderr output code */
-       if (enable_syslog || !print_to_logfile) return;
-
-       /* if we run in forground and syslog is disabled, log to terminal */
-       if (loglevel <= verbosity) { 
-               struct timeval tv;
-               struct tm tim;
-               time_t unixtime;
-               CitContext *CCC = CC;
-               ThreadTSD *cTSD = CTP;
-               CtdlThreadNode *node = NULL;
-               long lwpid = 0;
-               char formatbuf[SIZ];
-               char LWP[64];
-               char SESS[64];
-
-               if (cTSD != NULL) {
-                       node = cTSD->self;
-               }
-
-               if ((node != NULL) && (node->reltid != 0)) {
-                       lwpid = node->reltid;
-               }
-
-               gettimeofday(&tv, NULL);
-
-               /* Promote to time_t; types differ on some OSes (like darwin) */
-               unixtime = tv.tv_sec;
-               localtime_r(&unixtime, &tim);
-
-               *LWP = '\0';
-               if (lwpid != 0) {
-                       snprintf(LWP, 64, "[LWP:%ld] ", lwpid);
-               }
-                       
-               *SESS = '\0';
-               if (CCC != NULL) {
-                       if (CCC->cs_pid != 0) {
-                               snprintf(SESS, 64, " [%3d] ", CCC->cs_pid);
-                       }
-                       else if (CCC->user.usernum != 0) {
-                               snprintf(SESS, 64, " [:%ld] ", CCC->user.usernum);
-                       }
-               }
-
-               snprintf(formatbuf, SIZ, 
-                        "%04d/%02d/%02d %2d:%02d:%02d.%06ld %s%s%s",
-                        tim.tm_year + 1900, tim.tm_mon + 1,
-                        tim.tm_mday, tim.tm_hour, tim.tm_min,
-                        tim.tm_sec, (long)tv.tv_usec, 
-                        LWP, SESS, format
-               );
-
-               vfprintf(stderr, formatbuf, arg_ptr);   
-               fflush(stderr);
-       }
-}   
-
-
-
 /*
  * Signal handler to shut down the server.
  */
@@ -185,7 +116,7 @@ static RETSIGTYPE signal_cleanup(int signum) {
                CT->signal = signum;
        else
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
+               syslog(LOG_DEBUG, "Caught signal %d; shutting down.\n", signum);
                exit_signal = signum;
        }
 }
@@ -225,7 +156,7 @@ void init_sysdep(void) {
         * session to which the calling thread is currently bound.
         */
        if (citthread_key_create(&MyConKey, NULL) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "Can't create TSD key: %s\n",
+               syslog(LOG_CRIT, "Can't create TSD key: %s\n",
                        strerror(errno));
        }
 
@@ -301,7 +232,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                        snprintf(errormessage, SIZ,
                                 "Error binding to [%s] : %s", ip_addr, strerror(errno)
                        );
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+                       syslog(LOG_ALERT, "%s\n", errormessage);
                        return (-1);
                }
        }
@@ -312,7 +243,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                        snprintf(errormessage, SIZ,
                                 "Error binding to [%s] : %s", ip_addr, strerror(errno)
                        );
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+                       syslog(LOG_ALERT, "%s\n", errormessage);
                        return (-1);
                }
        }
@@ -321,7 +252,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't start: no port number specified."
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        sin6.sin6_port = htons((u_short) port_number);
@@ -334,7 +265,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't create a listening socket: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        /* Set some socket options that make sense. */
@@ -352,7 +283,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't bind: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
 
@@ -362,7 +293,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't listen: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        return (s);
@@ -393,7 +324,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, "citserver: can't unlink %s: %s",
                        sockpath, strerror(errno)
                );
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -406,7 +337,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't create a socket: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -414,7 +345,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't bind: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -423,7 +354,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't set socket to non-blocking: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                close(s);
                return(-1);
        }
@@ -432,7 +363,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't listen: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -560,7 +491,7 @@ int client_write(const char *buf, int nbytes)
                        if (select(1, NULL, &wset, NULL, NULL) == -1) {
                                if (errno == EINTR)
                                {
-                                       CtdlLogPrintf(CTDL_DEBUG, "client_write(%d bytes) select() interrupted.\n", nbytes-bytes_written);
+                                       syslog(LOG_DEBUG, "client_write(%d bytes) select() interrupted.\n", nbytes-bytes_written);
                                        if (CtdlThreadCheckStop()) {
                                                CC->kill_me = 1;
                                                return (-1);
@@ -569,7 +500,7 @@ int client_write(const char *buf, int nbytes)
                                                continue;
                                        }
                                } else {
-                                       CtdlLogPrintf(CTDL_ERR,
+                                       syslog(LOG_ERR,
                                                "client_write(%d bytes) select failed: %s (%d)\n",
                                                nbytes - bytes_written,
                                                strerror(errno), errno);
@@ -583,12 +514,12 @@ int client_write(const char *buf, int nbytes)
                retval = write(Ctx->client_socket, &buf[bytes_written],
                        nbytes - bytes_written);
                if (retval < 1) {
-                       CtdlLogPrintf(CTDL_ERR,
+                       syslog(LOG_ERR,
                                "client_write(%d bytes) failed: %s (%d)\n",
                                nbytes - bytes_written,
                                strerror(errno), errno);
                        cit_backtrace();
-                       // CtdlLogPrintf(CTDL_DEBUG, "Tried to send: %s",  &buf[bytes_written]);
+                       // syslog(LOG_DEBUG, "Tried to send: %s",  &buf[bytes_written]);
                        Ctx->kill_me = 1;
                        return -1;
                }
@@ -657,7 +588,7 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
 #endif
                retval = client_read_sslblob(Target, bytes, timeout);
                if (retval < 0) {
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed\n",
                                      __FUNCTION__);
                }
@@ -702,7 +633,7 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                                                O_TERM,
                                                &Error);
                if (retval < 0) {
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed: %s\n",
                                      __FUNCTION__, 
                                      Error);
@@ -886,7 +817,7 @@ int CtdlClientGetLine(StrBuf *Target)
                 fclose(fd);
 
                if (rc < 0)
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed\n",
                                      __FUNCTION__);
 #endif
@@ -944,7 +875,7 @@ int CtdlClientGetLine(StrBuf *Target)
                 fclose(fd);
 
                if ((rc < 0) && (Error != NULL))
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed: %s\n",
                                      __FUNCTION__,
                                      Error);
@@ -1009,13 +940,13 @@ void close_masters (void)
 
                if (serviceptr->tcp_port > 0)
                {
-                       CtdlLogPrintf(CTDL_INFO, "Closing listener on port %d\n",
+                       syslog(LOG_INFO, "Closing listener on port %d\n",
                                serviceptr->tcp_port);
                        serviceptr->tcp_port = 0;
                }
                
                if (serviceptr->sockpath != NULL)
-                       CtdlLogPrintf(CTDL_INFO, "Closing listener on '%s'\n",
+                       syslog(LOG_INFO, "Closing listener on '%s'\n",
                                serviceptr->sockpath);
 
                close(serviceptr->msock);
@@ -1086,7 +1017,7 @@ void start_daemon(int unused) {
         * to be reused for other files.
         */
        if (chdir(ctdl_run_dir) != 0)
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to change into directory [%s]: %s", 
                              ctdl_run_dir, strerror(errno));
 
@@ -1104,7 +1035,7 @@ void start_daemon(int unused) {
         if ((freopen("/dev/null", "r", stdin) != stdin) || 
            (freopen("/dev/null", "w", stdout) != stdout) || 
            (freopen("/dev/null", "w", stderr) != stderr))
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to reopen stdin/out/err %s", 
                              strerror(errno));
                
@@ -1166,7 +1097,7 @@ void checkcrash(void)
                StrBuf *CrashMail;
 
                CrashMail = NewStrBuf();
-               CtdlLogPrintf(CTDL_ALERT, "Posting crash message\n");
+               syslog(LOG_ALERT, "Posting crash message\n");
                StrBufPrintf(CrashMail, 
                        " \n"
                        " The Citadel server process (citserver) terminated unexpectedly."
@@ -1309,16 +1240,16 @@ do_select:      force_purge = 0;
                 */
                if (retval < 0) {
                        if (errno == EBADF) {
-                               CtdlLogPrintf(CTDL_NOTICE, "select() failed: (%s)\n",
+                               syslog(LOG_NOTICE, "select() failed: (%s)\n",
                                        strerror(errno));
                                goto do_select;
                        }
                        if (errno != EINTR) {
-                               CtdlLogPrintf(CTDL_EMERG, "Exiting (%s)\n", strerror(errno));
+                               syslog(LOG_EMERG, "Exiting (%s)\n", strerror(errno));
                                CtdlThreadStopAll();
                                continue;
                        } else {
-                               CtdlLogPrintf(CTDL_DEBUG, "Interrupted CtdlThreadSelect.\n");
+                               syslog(LOG_DEBUG, "Interrupted CtdlThreadSelect.\n");
                                if (CtdlThreadCheckStop()) return(NULL);
                                goto do_select;
                        }
@@ -1451,15 +1382,15 @@ void *select_on_master (void *arg)
                 */
                if (retval < 0) {
                        if (errno == EBADF) {
-                               CtdlLogPrintf(CTDL_NOTICE, "select() failed: (%s)\n",
+                               syslog(LOG_NOTICE, "select() failed: (%s)\n",
                                        strerror(errno));
                                continue;
                        }
                        if (errno != EINTR) {
-                               CtdlLogPrintf(CTDL_EMERG, "Exiting (%s)\n", strerror(errno));
+                               syslog(LOG_EMERG, "Exiting (%s)\n", strerror(errno));
                                CtdlThreadStopAll();
                        } else {
-                               CtdlLogPrintf(CTDL_DEBUG, "Interrupted CtdlThreadSelect.\n");
+                               syslog(LOG_DEBUG, "Interrupted CtdlThreadSelect.\n");
                                if (CtdlThreadCheckStop()) return(NULL);
                                continue;
                        }
@@ -1477,7 +1408,7 @@ void *select_on_master (void *arg)
                        if (FD_ISSET(serviceptr->msock, &master_fds)) {
                                ssock = accept(serviceptr->msock, NULL, 0);
                                if (ssock >= 0) {
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                "New client socket %d\n",
                                                ssock);
 
@@ -1486,7 +1417,7 @@ void *select_on_master (void *arg)
                                         * operations barf on FreeBSD.  Not a fatal error.
                                         */
                                        if (fcntl(ssock, F_SETFL, 0) < 0) {
-                                               CtdlLogPrintf(CTDL_EMERG,
+                                               syslog(LOG_EMERG,
                                                        "citserver: Can't set socket to blocking: %s\n",
                                                        strerror(errno));
                                        }
@@ -1568,7 +1499,6 @@ int SyslogFacility(char *name)
                if(!strcasecmp(name, facTbl[i].name))
                        return facTbl[i].facility;
        }
-       enable_syslog = 0;
        return LOG_DAEMON;
 }
 
@@ -1674,7 +1604,7 @@ void dump_heap(void) {
        struct igheap *thisheap;
 
        for (thisheap = igheap; thisheap != NULL; thisheap = thisheap->next) {
-               CtdlLogPrintf(CTDL_CRIT, "UNFREED: %30s : %d\n",
+               syslog(LOG_CRIT, "UNFREED: %30s : %d\n",
                        thisheap->file, thisheap->line);
        }
 }
index 663e9b50b0b0108683cd90099af0b94fbf17704f..f0343c728adae0c117cc6e3a2acf36d7edca79b3 100644 (file)
@@ -47,12 +47,6 @@ void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)
 void cprintf (const char *format, ...);
 #endif
 
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
-void vCtdlLogPrintf (enum LogLevel loglevel, const char *format, va_list arg_ptr);
-
-extern int enable_syslog;
-extern int print_to_logfile;
-
 void init_sysdep (void);
 int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errormessage);
 int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage);
@@ -87,10 +81,7 @@ extern int verbosity;
 extern int rescan[];
 
 
-
-
 extern int SyslogFacility(char *name);
-extern int syslog_facility;
 
 
 /*
index 91a2d786cb6c1c4ebaae0eb9b96532cc988033e2..94ca65341bd8b62e59fecc0d1556e0815b597762 100644 (file)
@@ -128,12 +128,12 @@ int enable_syslog = 0;
 
 
 /*
- * CtdlLogPrintf()  ...   Write logging information; 
+ * syslog()  ...   Write logging information; 
  *                  simple here to have the same 
  *                  symbols in the client.
  */
 
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {   
+void syslog(enum LogLevel loglevel, const char *format, ...) {   
        va_list arg_ptr;
 
        va_start(arg_ptr, format);
index b886beeb4f5f9fcdee22cfca7a68ebe6f9938689..ff47e976930578277245c900a296f934d42bcf25 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Thread handling stuff for Citadel server
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <syslog.h>
 
 #include "sysdep.h"
 #if TIME_WITH_SYS_TIME
@@ -135,7 +136,7 @@ int try_critical_section(int which_one)
  */
 void begin_critical_section(int which_one)
 {
-       /* CtdlLogPrintf(CTDL_DEBUG, "begin_critical_section(%d)\n", which_one); */
+       /* syslog(LOG_DEBUG, "begin_critical_section(%d)\n", which_one); */
 
        /* For all types of critical sections except those listed here,
         * ensure nobody ever tries to do a critical section within a
@@ -181,7 +182,7 @@ void ctdl_thread_internal_init_tsd(void)
        int ret;
        
        if ((ret = citthread_key_create(&ThreadKey, ctdl_thread_internal_dest_tsd))) {
-               CtdlLogPrintf(CTDL_EMERG, "citthread_key_create: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "citthread_key_create: %s\n", strerror(ret));
                exit(CTDLEXIT_DB);
        }
 }
@@ -262,7 +263,7 @@ void ctdl_thread_internal_init(void)
        /* Get ourself a thread entry */
        this_thread = malloc(sizeof(CtdlThreadNode));
        if (this_thread == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
                return;
        }
        // Ensuring this is zero'd means we make sure the thread doesn't start doing its thing until we are ready.
@@ -277,7 +278,7 @@ void ctdl_thread_internal_init(void)
        this_thread->state = CTDL_THREAD_RUNNING;
        
        if ((ret = citthread_attr_init(&this_thread->attr))) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
                free(this_thread);
                return;
        }
@@ -373,7 +374,7 @@ void CtdlThreadStopAll(void)
                citthread_cond_signal(&this_thread->ThreadCond);
                citthread_cond_signal(&this_thread->SleepCond);
                this_thread->stop_ticker = time(NULL);
-               CtdlLogPrintf(CTDL_DEBUG, "Thread system stopping thread \"%s\" (0x%08lx).\n",
+               syslog(LOG_DEBUG, "Thread system stopping thread \"%s\" (0x%08lx).\n",
                        this_thread->name, this_thread->tid);
                this_thread = this_thread->next;
        }
@@ -388,7 +389,7 @@ void CtdlThreadWakeAll(void)
 {
        CtdlThreadNode *this_thread;
        
-       CtdlLogPrintf(CTDL_DEBUG, "Thread system waking all threads.\n");
+       syslog(LOG_DEBUG, "Thread system waking all threads.\n");
        
        begin_critical_section(S_THREAD_LIST);
        this_thread = CtdlThreadList;
@@ -474,7 +475,7 @@ const char *CtdlThreadName(const char *name)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_WARNING, "Thread system WARNING. Attempt to CtdlThreadRename() a non thread. %s\n", name);
+               syslog(LOG_WARNING, "Thread system WARNING. Attempt to CtdlThreadRename() a non thread. %s\n", name);
                return NULL;
        }
        old_name = CT->name;
@@ -497,14 +498,14 @@ void CtdlThreadCancel(CtdlThreadNode *thread)
                this_thread = thread;
        if (!this_thread)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() a non thread.\n");
+               syslog(LOG_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() a non thread.\n");
                CtdlThreadStopAll();
                return;
        }
        
        if (!this_thread->thread_func)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() the garbage collector.\n");
+               syslog(LOG_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() the garbage collector.\n");
                CtdlThreadStopAll();
                return;
        }
@@ -523,7 +524,7 @@ int CtdlThreadCheckStop(void)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, CtdlThreadCheckStop() called by a non thread.\n");
+               syslog(LOG_EMERG, "Thread system PANIC, CtdlThreadCheckStop() called by a non thread.\n");
                CtdlThreadStopAll();
                return -1;
        }
@@ -532,7 +533,7 @@ int CtdlThreadCheckStop(void)
 
        if (CT->signal)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Thread \"%s\" caught signal %d.\n", CT->name, CT->signal);
+               syslog(LOG_DEBUG, "Thread \"%s\" caught signal %d.\n", CT->name, CT->signal);
                if (CT->signal == SIGHUP)
                        CT->state = CTDL_THREAD_STOP_REQ;
                CT->signal = 0;
@@ -587,7 +588,7 @@ void CtdlThreadSleep(int secs)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlThreadSleep() called by something that is not a thread. Should we die?\n");
+               syslog(LOG_WARNING, "CtdlThreadSleep() called by something that is not a thread. Should we die?\n");
                return;
        }
        
@@ -620,11 +621,11 @@ static void ctdl_internal_thread_cleanup(void *arg)
                const char *name = CT->name;
                const pid_t tid = CT->tid;
 
-               CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, (unsigned long) tid);
+               syslog(LOG_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, (unsigned long) tid);
        }
        else 
        {
-               CtdlLogPrintf(CTDL_NOTICE, "some ((unknown ? ? ?) Thread exited.\n");
+               syslog(LOG_NOTICE, "some ((unknown ? ? ?) Thread exited.\n");
        }
        
        #ifdef HAVE_BACKTRACE
@@ -664,7 +665,7 @@ void ctdl_thread_internal_calc_loadavg(void)
                        workers++;
                }
 #ifdef WITH_THREADLOG
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlThread, \"%s\" (%lu) \"%s\" %.2f %.2f %.2f %.2f\n",
+               syslog(LOG_DEBUG, "CtdlThread, \"%s\" (%lu) \"%s\" %.2f %.2f %.2f %.2f\n",
                        that_thread->name,
                        that_thread->tid,
                        CtdlThreadStates[that_thread->state],
@@ -679,7 +680,7 @@ void ctdl_thread_internal_calc_loadavg(void)
        CtdlThreadLoadAvg = load_avg/num_threads;
        CtdlThreadWorkerAvg = worker_avg/workers;
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_INFO, "System load average %.2f, workers averag %.2f, threads %d, workers %d, sessions %d\n", CtdlThreadGetLoadAvg(), CtdlThreadWorkerAvg, num_threads, num_workers, num_sessions);
+       syslog(LOG_INFO, "System load average %.2f, workers averag %.2f, threads %d, workers %d, sessions %d\n", CtdlThreadGetLoadAvg(), CtdlThreadWorkerAvg, num_threads, num_workers, num_sessions);
 #endif
 }
 
@@ -701,7 +702,7 @@ void CtdlThreadGC (void)
                CtdlThreadList->state = CTDL_THREAD_EXITED;
        
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_DEBUG, "Thread system running garbage collection.\n");
+       syslog(LOG_DEBUG, "Thread system running garbage collection.\n");
 #endif
        /*
         * Woke up to do garbage collection
@@ -715,7 +716,7 @@ void CtdlThreadGC (void)
                if ((that_thread->state == CTDL_THREAD_STOP_REQ || that_thread->state == CTDL_THREAD_STOPPING)
                        && (!citthread_equal(that_thread->tid, citthread_self())))
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
+                       syslog(LOG_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
                        terminate_stuck_sessions();
                }
                else
@@ -729,9 +730,9 @@ void CtdlThreadGC (void)
                
                if (that_thread->stop_ticker + 5 == time(NULL))
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread System: The thread \"%s\" (0x%08lx) failed to self terminate within 5 ticks. It would be cancelled now.\n", that_thread->name, that_thread->tid);
+                       syslog(LOG_DEBUG, "Thread System: The thread \"%s\" (0x%08lx) failed to self terminate within 5 ticks. It would be cancelled now.\n", that_thread->name, that_thread->tid);
                        if ((that_thread->flags & CTDLTHREAD_WORKER) == 0)
-                               CtdlLogPrintf(CTDL_INFO, "Thread System: A non worker thread would have been canceled this may cause message loss.\n");
+                               syslog(LOG_INFO, "Thread System: A non worker thread would have been canceled this may cause message loss.\n");
 //                     that_thread->state = CTDL_THREAD_CANCELLED;
                        that_thread->stop_ticker++;
 //                     citthread_cancel(that_thread->tid);
@@ -749,7 +750,7 @@ void CtdlThreadGC (void)
                if (citthread_equal(that_thread->tid, citthread_self()) && that_thread->thread_func)
                {       /* Sanity check */
                        end_critical_section(S_THREAD_LIST);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, a thread is trying to clean up after itself.\n");
+                       syslog(LOG_EMERG, "Thread system PANIC, a thread is trying to clean up after itself.\n");
                        abort();
                        return;
                }
@@ -757,7 +758,7 @@ void CtdlThreadGC (void)
                if (num_threads <= 0)
                {       /* Sanity check */
                        end_critical_section(S_THREAD_LIST);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, num_threads <= 0 and trying to do Garbage Collection.\n");
+                       syslog(LOG_EMERG, "Thread system PANIC, num_threads <= 0 and trying to do Garbage Collection.\n");
                        abort();
                        return;
                }
@@ -784,17 +785,17 @@ void CtdlThreadGC (void)
                 */
                ret = citthread_join (that_thread->tid, NULL);
                if (ret == EDEADLK)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection on own thread.\n");
+                       syslog(LOG_DEBUG, "Garbage collection on own thread.\n");
                else if (ret == EINVAL)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, that thread already joined on.\n");
+                       syslog(LOG_DEBUG, "Garbage collection, that thread already joined on.\n");
                else if (ret == ESRCH)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, no thread to join on.\n");
+                       syslog(LOG_DEBUG, "Garbage collection, no thread to join on.\n");
                else if (ret != 0)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, citthread_join returned an unknown error(%d).\n", ret);
+                       syslog(LOG_DEBUG, "Garbage collection, citthread_join returned an unknown error(%d).\n", ret);
                /*
                 * Now we own that thread entry
                 */
-               CtdlLogPrintf(CTDL_INFO, "Garbage Collection for thread \"%s\" (0x%08lx).\n",
+               syslog(LOG_INFO, "Garbage Collection for thread \"%s\" (0x%08lx).\n",
                        that_thread->name, that_thread->tid);
                citthread_mutex_destroy(&that_thread->ThreadMutex);
                citthread_cond_destroy(&that_thread->ThreadCond);
@@ -809,7 +810,7 @@ void CtdlThreadGC (void)
        /* Sanity check number of worker threads */
        if (workers != sys_workers)
        {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "Thread system PANIC, discrepancy in number of worker threads. Counted %d, should be %d.\n",
                        workers, sys_workers
                        );
@@ -866,7 +867,7 @@ static void *ctdl_internal_thread_func (void *arg)
 #if defined(HAVE_SYSCALL_H) && defined (SYS_gettid)
        this_thread->reltid = syscall(SYS_gettid);
 #endif
-       CtdlLogPrintf(CTDL_NOTICE, "Created a new thread \"%s\" (0x%08lx).\n",
+       syslog(LOG_NOTICE, "Created a new thread \"%s\" (0x%08lx).\n",
                this_thread->name, this_thread->tid);
        
        /*
@@ -911,7 +912,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
                citthread_cond_destroy(&(this_thread->ThreadCond));
                citthread_mutex_destroy(&(this_thread->SleepMutex));
                citthread_cond_destroy(&(this_thread->SleepCond));
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
                free(this_thread);
                return NULL;
        }
@@ -923,7 +924,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
        if (flags & CTDLTHREAD_BIGSTACK)
        {
 #ifdef WITH_THREADLOG
-               CtdlLogPrintf(CTDL_INFO, "Thread system. Creating BIG STACK thread.\n");
+               syslog(LOG_INFO, "Thread system. Creating BIG STACK thread.\n");
 #endif
                if ((ret = citthread_attr_setstacksize(&this_thread->attr, THREADSTACKSIZE))) {
                        citthread_mutex_unlock(&this_thread->ThreadMutex);
@@ -932,7 +933,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
                        citthread_mutex_destroy(&(this_thread->SleepMutex));
                        citthread_cond_destroy(&(this_thread->SleepCond));
                        citthread_attr_destroy(&this_thread->attr);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_setstacksize: %s\n",
+                       syslog(LOG_EMERG, "Thread system, citthread_attr_setstacksize: %s\n",
                                strerror(ret));
                        free(this_thread);
                        return NULL;
@@ -961,13 +962,13 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
 
        if (num_threads >= 32767)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system. Thread list full.\n");
+               syslog(LOG_EMERG, "Thread system. Thread list full.\n");
                return NULL;
        }
                
        this_thread = malloc(sizeof(CtdlThreadNode));
        if (this_thread == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
                return NULL;
        }
        
@@ -975,7 +976,7 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
        if (ctdl_internal_init_thread_struct(this_thread, flags) == NULL)
        {
                free(this_thread);
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't initialise CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't initialise CtdlThreadNode, exiting\n");
                return NULL;
        }
        /*
@@ -1005,7 +1006,7 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
        if ((ret = citthread_create(&this_thread->tid, &this_thread->attr, ctdl_internal_thread_func, this_thread) != 0))
        {
                end_critical_section(S_THREAD_LIST);
-               CtdlLogPrintf(CTDL_ALERT, "Thread system, Can't create thread: %s\n",
+               syslog(LOG_ALERT, "Thread system, Can't create thread: %s\n",
                        strerror(ret));
                citthread_mutex_unlock(&this_thread->ThreadMutex);
                citthread_mutex_destroy(&(this_thread->ThreadMutex));
@@ -1060,7 +1061,7 @@ CtdlThreadNode *ctdl_thread_internal_start_scheduled (CtdlThreadNode *this_threa
        if ((ret = citthread_create(&this_thread->tid, &this_thread->attr, ctdl_internal_thread_func, this_thread) != 0))
        {
                end_critical_section(S_THREAD_LIST);
-               CtdlLogPrintf(CTDL_DEBUG, "Failed to start scheduled thread \"%s\": %s\n", this_thread->name, strerror(ret));
+               syslog(LOG_DEBUG, "Failed to start scheduled thread \"%s\": %s\n", this_thread->name, strerror(ret));
                citthread_mutex_destroy(&(this_thread->ThreadMutex));
                citthread_cond_destroy(&(this_thread->ThreadCond));
                citthread_mutex_destroy(&(this_thread->SleepMutex));
@@ -1104,7 +1105,7 @@ void ctdl_thread_internal_check_scheduled(void)
        now = time(NULL);
        
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_DEBUG, "Checking for scheduled threads to start.\n");
+       syslog(LOG_DEBUG, "Checking for scheduled threads to start.\n");
 #endif
 
        this_thread = CtdlThreadSchedList;
@@ -1125,14 +1126,14 @@ void ctdl_thread_internal_check_scheduled(void)
                                
                        that_thread->next = that_thread->prev = NULL;
 #ifdef WITH_THREADLOG
-                       CtdlLogPrintf(CTDL_DEBUG, "About to start scheduled thread \"%s\".\n", that_thread->name);
+                       syslog(LOG_DEBUG, "About to start scheduled thread \"%s\".\n", that_thread->name);
 #endif
                        if (CT->state > CTDL_THREAD_STOP_REQ)
                        {       /* Only start it if the system is not stopping */
                                if (ctdl_thread_internal_start_scheduled (that_thread))
                                {
 #ifdef WITH_THREADLOG
-                                       CtdlLogPrintf(CTDL_INFO, "Thread system, Started a scheduled thread \"%s\" (0x%08lx).\n",
+                                       syslog(LOG_INFO, "Thread system, Started a scheduled thread \"%s\" (0x%08lx).\n",
                                                that_thread->name, that_thread->tid);
 #endif
                                }
@@ -1141,7 +1142,7 @@ void ctdl_thread_internal_check_scheduled(void)
 #ifdef WITH_THREADLOG
                else
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread \"%s\" will start in %ld seconds.\n",
+                       syslog(LOG_DEBUG, "Thread \"%s\" will start in %ld seconds.\n",
                                that_thread->name, that_thread->when - time(NULL));
                }
 #endif
@@ -1183,7 +1184,7 @@ int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds
                citthread_mutex_lock(&CT->ThreadMutex); /* To prevent race condition of a sleeping thread */
                if (GC_thread->state > CTDL_THREAD_STOP_REQ && CT->state <= CTDL_THREAD_STOP_REQ)
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread %s (0x%08lx) refused stop request.\n", CT->name, CT->tid);
+                       syslog(LOG_DEBUG, "Thread %s (0x%08lx) refused stop request.\n", CT->name, CT->tid);
                        CT->state = CTDL_THREAD_RUNNING;
                }
                citthread_mutex_unlock(&CT->ThreadMutex);
@@ -1245,7 +1246,7 @@ void go_threading(void)
                CtdlThreadCreate("select_on_master", CTDLTHREAD_BIGSTACK, select_on_master, NULL);
        }
        else {
-               CtdlLogPrintf(CTDL_EMERG, "Running connection simulation stats\n");
+               syslog(LOG_EMERG, "Running connection simulation stats\n");
                gettimeofday(&start, NULL);
                CtdlThreadCreate("Connection simulation master", CTDLTHREAD_BIGSTACK, simulation_thread, NULL);
        }
@@ -1254,7 +1255,7 @@ void go_threading(void)
        /*
         * This thread is now used for garbage collection of other threads in the thread list
         */
-       CtdlLogPrintf(CTDL_INFO, "Startup thread %ld becoming garbage collector,\n", (long) citthread_self());
+       syslog(LOG_INFO, "Startup thread %ld becoming garbage collector,\n", (long) citthread_self());
 
        /*
         * We do a lot of locking and unlocking of the thread list in here.
@@ -1302,7 +1303,7 @@ void go_threading(void)
                        if (last_worker)
                        {
 #ifdef WITH_THREADLOG
-                               CtdlLogPrintf(CTDL_DEBUG, "Thread system, stopping excess worker thread \"%s\" (0x%08lx).\n",
+                               syslog(LOG_DEBUG, "Thread system, stopping excess worker thread \"%s\" (0x%08lx).\n",
                                        last_worker->name,
                                        last_worker->tid
                                        );
@@ -1334,7 +1335,7 @@ void go_threading(void)
                                }
                        }
                        else
-                               CtdlLogPrintf (CTDL_WARNING, "Server strangled due to machine load average too high.\n");
+                               syslog(LOG_WARNING, "Server strangled due to machine load average too high.\n");
                }
                }
 
@@ -1361,7 +1362,7 @@ void go_threading(void)
                gettimeofday(&now, NULL);
                timersub(&now, &start, &result);
                last_duration = (double)result.tv_sec + ((double)result.tv_usec / (double) 1000000);
-               CtdlLogPrintf(CTDL_EMERG, "Simulated %ld connections in %f seconds\n", stats_done, last_duration);
+               syslog(LOG_EMERG, "Simulated %ld connections in %f seconds\n", stats_done, last_duration);
        }
 }
 
index 3cecc10e7acd29a8401ef60f568437e0a63ba755..5e0219f53f4fd14565e61ff38164740a11c3788c 100644 (file)
@@ -1,5 +1,21 @@
 /* 
  * Server functions which perform operations on user objects.
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -13,6 +29,7 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <syslog.h>
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 #include "threads.h"
 #include "citadel_ldap.h"
 #include "context.h"
-
 #include "ctdl_module.h"
-
-////#define CTDL_INLINE_USR INLINE
 #include "user_ops.h"
 
 /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
@@ -216,10 +230,10 @@ int rename_user(char *oldname, char *newname) {
                else {          /* Sanity checks succeeded.  Now rename the user. */
                        if (usbuf.usernum == 0)
                        {
-                               CtdlLogPrintf (CTDL_DEBUG, "Can not rename user \"Citadel\".\n");
+                               syslog(LOG_DEBUG, "Can not rename user \"Citadel\".\n");
                                retcode = RENAMEUSER_NOT_FOUND;
                        } else {
-                               CtdlLogPrintf(CTDL_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
+                               syslog(LOG_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
                                cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
                                safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
                                CtdlPutUser(&usbuf);
@@ -403,11 +417,11 @@ int CtdlGetUserByNumber(struct ctdluser *usbuf, long number)
 
        cdbun = cdb_fetch(CDB_USERSBYNUMBER, &number, sizeof(long));
        if (cdbun == NULL) {
-               CtdlLogPrintf(CTDL_INFO, "User %ld not found\n", number);
+               syslog(LOG_INFO, "User %ld not found\n", number);
                return(-1);
        }
 
-       CtdlLogPrintf(CTDL_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
+       syslog(LOG_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
        r = CtdlGetUser(usbuf, cdbun->ptr);
        cdb_free(cdbun);
        return(r);
@@ -456,7 +470,7 @@ void rebuild_ubn_for_user(struct ctdluser *usbuf, void *data) {
        }
 
        while (u != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Rebuilding usersbynumber index %10ld : %s\n",
+               syslog(LOG_DEBUG, "Rebuilding usersbynumber index %10ld : %s\n",
                        u->usernum, u->username);
                cdb_store(CDB_USERSBYNUMBER, &u->usernum, sizeof(long), u->username, strlen(u->username)+1);
 
@@ -517,7 +531,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
        int found_user;
        long len;
 
-       CtdlLogPrintf(9, "CtdlLoginExistingUser(%s, %s)\n", authname, trythisname);
+       syslog(LOG_DEBUG, "CtdlLoginExistingUser(%s, %s)\n", authname, trythisname);
 
        if ((CC->logged_in)) {
                return login_already_logged_in;
@@ -527,7 +541,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
        
        if (!strncasecmp(trythisname, "SYS_", 4))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "System user \"%s\" is not allowed to log in.\n", trythisname);
+               syslog(LOG_DEBUG, "System user \"%s\" is not allowed to log in.\n", trythisname);
                return login_not_found;
        }
 
@@ -556,21 +570,21 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                struct passwd *tempPwdPtr;
                char pwdbuffer[256];
        
-               CtdlLogPrintf(CTDL_DEBUG, "asking host about <%s>\n", username);
+               syslog(LOG_DEBUG, "asking host about <%s>\n", username);
 #ifdef HAVE_GETPWNAM_R
 #ifdef SOLARIS_GETPWUID
-               CtdlLogPrintf(CTDL_DEBUG, "Calling getpwnam_r()\n");
+               syslog(LOG_DEBUG, "Calling getpwnam_r()\n");
                tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer);
 #else // SOLARIS_GETPWUID
-               CtdlLogPrintf(CTDL_DEBUG, "Calling getpwnam_r()\n");
+               syslog(LOG_DEBUG, "Calling getpwnam_r()\n");
                getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
 #endif // SOLARIS_GETPWUID
 #else // HAVE_GETPWNAM_R
-               CtdlLogPrintf(CTDL_DEBUG, "SHOULD NEVER GET HERE!!!\n");
+               syslog(LOG_DEBUG, "SHOULD NEVER GET HERE!!!\n");
                tempPwdPtr = NULL;
 #endif // HAVE_GETPWNAM_R
                if (tempPwdPtr == NULL) {
-                       CtdlLogPrintf(CTDL_DEBUG, "no such user <%s>\n", username);
+                       syslog(LOG_DEBUG, "no such user <%s>\n", username);
                        return login_not_found;
                }
        
@@ -578,7 +592,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                 * If not found, make one attempt to create it.
                 */
                found_user = getuserbyuid(&CC->user, pd.pw_uid);
-               CtdlLogPrintf(CTDL_DEBUG, "found it: uid=%ld, gecos=%s here: %d\n",
+               syslog(LOG_DEBUG, "found it: uid=%ld, gecos=%s here: %d\n",
                        (long)pd.pw_uid, pd.pw_gecos, found_user);
                if (found_user != 0) {
                        len = cutuserkey(username);
@@ -661,11 +675,11 @@ void cmd_user(char *cmdbuf)
        char username[256];
        int a;
 
-       CtdlLogPrintf(CTDL_DEBUG, "cmd_user(%s)\n", cmdbuf);
+       syslog(LOG_DEBUG, "cmd_user(%s)\n", cmdbuf);
        extract_token(username, cmdbuf, 0, '|', sizeof username);
-       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
+       syslog(LOG_DEBUG, "username: %s\n", username);
        striplt(username);
-       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
+       syslog(LOG_DEBUG, "username: %s\n", username);
 
        a = CtdlLoginExistingUser(NULL, username);
        switch (a) {
@@ -699,7 +713,7 @@ void cmd_user(char *cmdbuf)
 void do_login(void)
 {
        CC->logged_in = 1;
-       CtdlLogPrintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
+       syslog(LOG_NOTICE, "<%s> logged in\n", CC->curr_user);
 
        CtdlGetUserLock(&CC->user, CC->curr_user);
        ++(CC->user.timescalled);
@@ -829,11 +843,11 @@ static int validpw(uid_t uid, const char *pass)
        int rv = 0;
 
        if (IsEmptyStr(pass)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Refusing to chkpwd for uid=%d with empty password.\n", uid);
+               syslog(LOG_DEBUG, "Refusing to chkpwd for uid=%d with empty password.\n", uid);
                return 0;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
+       syslog(LOG_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
 
        begin_critical_section(S_CHKPWD);
        rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
@@ -842,11 +856,11 @@ static int validpw(uid_t uid, const char *pass)
        end_critical_section(S_CHKPWD);
 
        if (!strncmp(buf, "PASS", 4)) {
-               CtdlLogPrintf(CTDL_DEBUG, "...pass\n");
+               syslog(LOG_DEBUG, "...pass\n");
                return(1);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "...fail\n");
+       syslog(LOG_DEBUG, "...fail\n");
        return 0;
 }
 
@@ -858,7 +872,7 @@ void start_chkpwd_daemon(void) {
        struct stat filestats;
        int i;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Starting chkpwd daemon for host authentication mode\n");
+       syslog(LOG_DEBUG, "Starting chkpwd daemon for host authentication mode\n");
 
        if ((stat(file_chkpwd, &filestats)==-1) ||
            (filestats.st_size==0)){
@@ -866,29 +880,29 @@ void start_chkpwd_daemon(void) {
                abort();
        }
        if (pipe(chkpwd_write_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
        if (pipe(chkpwd_read_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
 
        chkpwd_pid = fork();
        if (chkpwd_pid < 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to fork chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to fork chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
        if (chkpwd_pid == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling dup2() write\n");
+               syslog(LOG_DEBUG, "Now calling dup2() write\n");
                dup2(chkpwd_write_pipe[0], 0);
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling dup2() write\n");
+               syslog(LOG_DEBUG, "Now calling dup2() write\n");
                dup2(chkpwd_read_pipe[1], 1);
-               CtdlLogPrintf(CTDL_DEBUG, "Now closing stuff\n");
+               syslog(LOG_DEBUG, "Now closing stuff\n");
                for (i=2; i<256; ++i) close(i);
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling execl(%s)\n", file_chkpwd);
+               syslog(LOG_DEBUG, "Now calling execl(%s)\n", file_chkpwd);
                execl(file_chkpwd, file_chkpwd, NULL);
-               CtdlLogPrintf(CTDL_EMERG, "Unable to exec chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to exec chkpwd daemon: %s\n", strerror(errno));
                abort();
                exit(errno);
        }
@@ -900,19 +914,19 @@ int CtdlTryPassword(const char *password, long len)
        int code;
 
        if ((CC->logged_in)) {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlTryPassword: already logged in\n");
+               syslog(LOG_WARNING, "CtdlTryPassword: already logged in\n");
                return pass_already_logged_in;
        }
        if (!strcmp(CC->curr_user, NLI)) {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlTryPassword: no user selected\n");
+               syslog(LOG_WARNING, "CtdlTryPassword: no user selected\n");
                return pass_no_user;
        }
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               CtdlLogPrintf(CTDL_ERR, "CtdlTryPassword: internal error\n");
+               syslog(LOG_ERR, "CtdlTryPassword: internal error\n");
                return pass_internal_error;
        }
        if (password == NULL) {
-               CtdlLogPrintf(CTDL_INFO, "CtdlTryPassword: NULL password string supplied\n");
+               syslog(LOG_INFO, "CtdlTryPassword: NULL password string supplied\n");
                return pass_wrong_password;
        }
        code = (-1);
@@ -984,7 +998,7 @@ int CtdlTryPassword(const char *password, long len)
                do_login();
                return pass_ok;
        } else {
-               CtdlLogPrintf(CTDL_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
+               syslog(LOG_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
                return pass_wrong_password;
        }
 }
@@ -1035,7 +1049,7 @@ int purge_user(char pname[])
                return (ERROR + NO_SUCH_USER);
 
        if (CtdlGetUser(&usbuf, pname) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "Cannot purge user <%s> - not found\n", pname);
+               syslog(LOG_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
@@ -1043,12 +1057,12 @@ int purge_user(char pname[])
         * during the next purge.
         */
        if (CtdlIsUserLoggedInByNum(usbuf.usernum)) {
-               CtdlLogPrintf(CTDL_WARNING, "User <%s> is logged in; not deleting.\n", pname);
+               syslog(LOG_WARNING, "User <%s> is logged in; not deleting.\n", pname);
                usbuf.axlevel = AxDeleted;
                CtdlPutUser(&usbuf);
                return (1);
        }
-       CtdlLogPrintf(CTDL_NOTICE, "Deleting user <%s>\n", pname);
+       syslog(LOG_NOTICE, "Deleting user <%s>\n", pname);
 
 /*
  * FIXME:
@@ -1228,7 +1242,7 @@ int create_user(const char *newusername, long len, int become_user)
                CC->cs_addr
        );
        CtdlAideMessage(buf, "User Creation Notice");
-       CtdlLogPrintf(CTDL_NOTICE, "New user <%s> created\n", username);
+       syslog(LOG_NOTICE, "New user <%s> created\n", username);
        return (0);
 }
 
@@ -1306,7 +1320,7 @@ void CtdlSetPassword(char *new_pw)
        CtdlGetUserLock(&CC->user, CC->curr_user);
        safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
        CtdlPutUserLock(&CC->user);
-       CtdlLogPrintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
+       syslog(LOG_INFO, "Password changed for user <%s>\n", CC->curr_user);
        PerformSessionHooks(EVT_SETPASS);
 }
 
index 90c7ea8c2a0bf58e94bed9e5093bb8723e7925e4..bbddd4e885b731f3eaf0bfe6944218f5f22250a8 100644 (file)
@@ -2,6 +2,7 @@
 #define __USER_OPS_H__
 
 #include <ctype.h>
+#include <syslog.h>
 int hash (char *str);
 /* getuser is deprecated, use CtdlGetUser instead */
 int getuser (struct ctdluser *, char *) __attribute__ ((deprecated));
@@ -68,7 +69,7 @@ static INLINE long cutuserkey(char *username) {
        len = strlen(username);
        if (len >= USERNAME_SIZE)
        {
-               CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username);
+               syslog(LOG_EMERG, "Username to long: %s", username);
                cit_backtrace ();
                len = USERNAME_SIZE - 1; 
                ((char*)username)[USERNAME_SIZE - 1]='\0';
@@ -86,7 +87,7 @@ static INLINE void makeuserkey(char *key, const char *username, long len) {
 
        if (len >= USERNAME_SIZE)
        {
-               CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username);
+               syslog(LOG_EMERG, "Username to long: %s", username);
                cit_backtrace ();
                len = USERNAME_SIZE - 1; 
        }
index 402f6ca600b3d837e985061805f44faf3d0386c5..e2670d29d122e19e7a30d550cef55de4593bc2d5 100644 (file)
@@ -218,7 +218,7 @@ int main(int argc, char **argv)
        /* Start the logger */
        openlog("webcit",
                ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
-               LOG_NEWS
+               LOG_DAEMON
        );
 
        if (optind < argc) {