Syslog: adjust loglevels to sane values.
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 5 Feb 2013 22:32:14 +0000 (23:32 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 5 Feb 2013 22:32:14 +0000 (23:32 +0100)
 - by Benjamin Bochmann

webcit/context_loop.c
webcit/crypto.c
webcit/preferences.c
webcit/webcit.c
webcit/webserver.c

index 47c5610f33d712c9f22c0be48b419b98c1069e27..8218d1d9accf5b01667f383db4a314bb58b016c0 100644 (file)
@@ -119,7 +119,7 @@ void check_thread_pool_size(void)
                (num_threads_executing >= num_threads_existing)
                && (num_threads_existing < MAX_WORKER_THREADS)
        ) {
-               syslog(3, "%d of %d threads are executing.  Adding another worker thread.",
+               syslog(LOG_DEBUG, "%d of %d threads are executing.  Adding another worker thread.",
                        num_threads_executing,
                        num_threads_existing
                );
@@ -225,11 +225,11 @@ wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHtt
         */     
        if (Hdr->HR.desired_session == 0) {
                TheSession->wc_session = GenerateSessionID();
-               syslog(3, "Created new session %d", TheSession->wc_session);
+               syslog(LOG_DEBUG, "Created new session %d", TheSession->wc_session);
        }
        else {
                TheSession->wc_session = Hdr->HR.desired_session;
-               syslog(3, "Re-created session %d", TheSession->wc_session);
+               syslog(LOG_DEBUG, "Re-created session %d", TheSession->wc_session);
        }
        Hdr->HR.Static = Static;
        session_new_modules(TheSession);
@@ -405,7 +405,7 @@ int ReadHTTPRequest (ParsedHttpHdrs *Hdr)
                        memset(pHdr, 0, sizeof(OneHttpHeader));
                        pHdr->Val = Line;
                        Put(Hdr->HTTPHeaders, HKEY("GET /"), pHdr, DestroyHttpHeaderHandler);
-                       syslog(9, "%s", ChrPtr(Line));
+                       syslog(LOG_DEBUG, "%s", ChrPtr(Line));
                        isbogus = ReadHttpSubject(Hdr, Line, HeaderName);
                        if (isbogus) break;
                        continue;
@@ -516,7 +516,7 @@ void context_loop(ParsedHttpHdrs *Hdr)
                wcsession *Bogus;
                Bogus = CreateSession(0, 1, NULL, Hdr, NULL);
                do_404();
-               syslog(9, "HTTP: 404 [%ld.%06ld] %s %s",
+               syslog(LOG_WARNING, "HTTP: 404 [%ld.%06ld] %s %s",
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
                        ReqStrs[Hdr->HR.eReqType],
@@ -537,7 +537,7 @@ void context_loop(ParsedHttpHdrs *Hdr)
                /* How long did this transaction take? */
                gettimeofday(&tx_finish, NULL);
                
-               syslog(9, "HTTP: 200 [%ld.%06ld] %s %s",
+               syslog(LOG_DEBUG, "HTTP: 200 [%ld.%06ld] %s %s",
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
                        ReqStrs[Hdr->HR.eReqType],
@@ -618,7 +618,7 @@ void context_loop(ParsedHttpHdrs *Hdr)
        /* How long did this transaction take? */
        gettimeofday(&tx_finish, NULL);
 
-       syslog(9, "HTTP: 200 [%ld.%06ld] %s %s",
+       syslog(LOG_DEBUG, "HTTP: 200 [%ld.%06ld] %s %s",
                ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
                ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
                ReqStrs[Hdr->HR.eReqType],
index 8792a341e0780c3515dcfe201e2ca41f32c8b444..aa509887b733f9afb3a61d759460a0ddb1db2cc0 100644 (file)
@@ -68,12 +68,12 @@ void init_ssl(void)
        }
 
        if (!RAND_status()) {
-               syslog(3, "PRNG not adequately seeded, won't do SSL/TLS\n");
+               syslog(LOG_WARNING, "PRNG not adequately seeded, won't do SSL/TLS\n");
                return;
        }
        SSLCritters = malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t *));
        if (!SSLCritters) {
-               syslog(1, "citserver: can't allocate memory!!\n");
+               syslog(LOG_ERR, "citserver: can't allocate memory!!\n");
                /* Nothing's been initialized, just die */
                ShutDownWebcit();
                exit(WC_EXIT_SSL);
@@ -100,13 +100,13 @@ void init_ssl(void)
        SSL_load_error_strings();
        ssl_method = SSLv23_server_method();
        if (!(ssl_ctx = SSL_CTX_new(ssl_method))) {
-               syslog(3, "SSL_CTX_new failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+               syslog(LOG_WARNING, "SSL_CTX_new failed: %s\n", ERR_reason_error_string(ERR_get_error()));
                return;
        }
 
-       syslog(9, "Requesting cipher list: %s\n", ssl_cipher_list);
+       syslog(LOG_INFO, "Requesting cipher list: %s\n", ssl_cipher_list);
        if (!(SSL_CTX_set_cipher_list(ssl_ctx, ssl_cipher_list))) {
-               syslog(3, "SSL_CTX_set_cipher_list failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+               syslog(LOG_WARNING, "SSL_CTX_set_cipher_list failed: %s\n", ERR_reason_error_string(ERR_get_error()));
                return;
        }
 
@@ -143,14 +143,14 @@ void init_ssl(void)
         * If we still don't have a private key, generate one.
         */
        if (access(CTDL_KEY_PATH, R_OK) != 0) {
-               syslog(5, "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) {
-                       syslog(3, "Key generation failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+                       syslog(LOG_WARNING, "Key generation failed: %s\n", ERR_reason_error_string(ERR_get_error()));
                }
                if (rsa != NULL) {
                        fp = fopen(CTDL_KEY_PATH, "w");
@@ -164,14 +164,14 @@ void init_ssl(void)
                                                        NULL,   /* no callbk */
                                                        NULL    /* no callbk */
                                ) != 1) {
-                                       syslog(3, "Cannot write key: %s\n",
+                                       syslog(LOG_WARNING, "Cannot write key: %s\n",
                                                ERR_reason_error_string(ERR_get_error()));
                                        unlink(CTDL_KEY_PATH);
                                }
                                fclose(fp);
                        }
                        else {
-                               syslog(3, "Cannot write key: %s\n", CTDL_KEY_PATH);
+                               syslog(LOG_WARNING, "Cannot write key: %s\n", CTDL_KEY_PATH);
                                ShutDownWebcit();
                                exit(0);
                        }
@@ -185,7 +185,7 @@ void init_ssl(void)
         * the CSR in this step so that the next step may commence.
         */
        if ( (access(CTDL_CER_PATH, R_OK) != 0) && (access(CTDL_CSR_PATH, R_OK) != 0) ) {
-               syslog(5, "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
@@ -266,7 +266,7 @@ void init_ssl(void)
 
                                        /* Sign the CSR */
                                        if (!X509_REQ_sign(req, pk, EVP_md5())) {
-                                               syslog(3, "X509_REQ_sign(): error\n");
+                                               syslog(LOG_WARNING, "X509_REQ_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -277,7 +277,7 @@ void init_ssl(void)
                                                        fclose(fp);
                                                }
                                                else {
-                                                       syslog(3, "Cannot write key: %s\n", CTDL_CSR_PATH);
+                                                       syslog(LOG_WARNING, "Cannot write key: %s\n", CTDL_CSR_PATH);
                                                        ShutDownWebcit();
                                                        exit(0);
                                                }
@@ -291,7 +291,7 @@ void init_ssl(void)
                }
 
                else {
-                       syslog(3, "Unable to read private key.\n");
+                       syslog(LOG_WARNING, "Unable to read private key.\n");
                }
        }
 
@@ -301,7 +301,7 @@ void init_ssl(void)
         * Generate a self-signed certificate if we don't have one.
         */
        if (access(CTDL_CER_PATH, R_OK) != 0) {
-               syslog(5, "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.
@@ -342,7 +342,7 @@ void init_ssl(void)
                                        
                                        /* Sign the cert */
                                        if (!X509_sign(cer, pk, EVP_md5())) {
-                                               syslog(3, "X509_sign(): error\n");
+                                               syslog(LOG_WARNING, "X509_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -353,7 +353,7 @@ void init_ssl(void)
                                                        fclose(fp);
                                                }
                                                else {
-                                                       syslog(3, "Cannot write key: %s\n", CTDL_CER_PATH);
+                                                       syslog(LOG_WARNING, "Cannot write key: %s\n", CTDL_CER_PATH);
                                                        ShutDownWebcit();
                                                        exit(0);
                                                }
@@ -374,7 +374,7 @@ void init_ssl(void)
        SSL_CTX_use_certificate_chain_file(ssl_ctx, CTDL_CER_PATH);
        SSL_CTX_use_PrivateKey_file(ssl_ctx, CTDL_KEY_PATH, SSL_FILETYPE_PEM);
        if ( !SSL_CTX_check_private_key(ssl_ctx) ) {
-               syslog(3, "Cannot install certificate: %s\n",
+               syslog(LOG_WARNING, "Cannot install certificate: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
        }
        
@@ -394,11 +394,11 @@ int starttls(int sock) {
                return(1);
        }
        if (!(newssl = SSL_new(ssl_ctx))) {
-               syslog(3, "SSL_new failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+               syslog(LOG_WARNING, "SSL_new failed: %s\n", ERR_reason_error_string(ERR_get_error()));
                return(2);
        }
        if (!(SSL_set_fd(newssl, sock))) {
-               syslog(3, "SSL_set_fd failed: %s\n", ERR_reason_error_string(ERR_get_error()));
+               syslog(LOG_WARNING, "SSL_set_fd failed: %s\n", ERR_reason_error_string(ERR_get_error()));
                SSL_free(newssl);
                return(3);
        }
@@ -415,10 +415,10 @@ int starttls(int sock) {
                errval = SSL_get_error(newssl, retval);
                ssl_error_reason = ERR_reason_error_string(ERR_get_error());
                if (ssl_error_reason == NULL) {
-                       syslog(3, "SSL_accept failed: errval=%ld, retval=%d %s\n", errval, retval, strerror(errval));
+                       syslog(LOG_WARNING, "SSL_accept failed: errval=%ld, retval=%d %s\n", errval, retval, strerror(errval));
                }
                else {
-                       syslog(3, "SSL_accept failed: %s\n", ssl_error_reason);
+                       syslog(LOG_WARNING, "SSL_accept failed: %s\n", ssl_error_reason);
                }
                sleeeeeeeeeep(1);
                retval = SSL_accept(newssl);
@@ -430,27 +430,27 @@ int starttls(int sock) {
                errval = SSL_get_error(newssl, retval);
                ssl_error_reason = ERR_reason_error_string(ERR_get_error());
                if (ssl_error_reason == NULL) {
-                       syslog(3, "SSL_accept failed: errval=%ld, retval=%d (%s)\n", errval, retval, strerror(errval));
+                       syslog(LOG_WARNING, "SSL_accept failed: errval=%ld, retval=%d (%s)\n", errval, retval, strerror(errval));
                }
                else {
-                       syslog(3, "SSL_accept failed: %s\n", ssl_error_reason);
+                       syslog(LOG_WARNING, "SSL_accept failed: %s\n", ssl_error_reason);
                }
                SSL_free(newssl);
                newssl = NULL;
                return(4);
        }
        else {
-               syslog(15, "SSL_accept success\n");
+               syslog(LOG_INFO, "SSL_accept success\n");
        }
        /*r = */BIO_set_close(newssl->rbio, BIO_NOCLOSE);
        bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(newssl), &alg_bits);
-       syslog(15, "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(newssl)),
                SSL_CIPHER_get_version(SSL_get_current_cipher(newssl)),
                bits, alg_bits);
 
        pthread_setspecific(ThreadSSL, newssl);
-       syslog(15, "SSL started\n");
+       syslog(LOG_INFO, "SSL started\n");
        return(0);
 }
 
@@ -468,7 +468,7 @@ void endtls(void)
 
        if (THREADSSL == NULL) return;
 
-       syslog(15, "Ending SSL/TLS\n");
+       syslog(LOG_INFO, "Ending SSL/TLS\n");
        SSL_shutdown(THREADSSL);
        /*ctx = */SSL_get_SSL_CTX(THREADSSL);
 
@@ -517,7 +517,7 @@ void client_write_ssl(const StrBuf *Buf)
        while (nremain > 0) {
                if (SSL_want_write(THREADSSL)) {
                        if ((SSL_read(THREADSSL, junk, 0)) < 1) {
-                               syslog(9, "SSL_read in client_write: %s\n",
+                               syslog(LOG_WARNING, "SSL_read in client_write: %s\n",
                                                ERR_reason_error_string(ERR_get_error()));
                        }
                }
@@ -530,9 +530,9 @@ void client_write_ssl(const StrBuf *Buf)
                                sleeeeeeeeeep(1);
                                continue;
                        }
-                       syslog(9, "SSL_write got error %ld, ret %d\n", errval, retval);
+                       syslog(LOG_WARNING, "SSL_write got error %ld, ret %d\n", errval, retval);
                        if (retval == -1) {
-                               syslog(9, "errno is %d\n", errno);
+                               syslog(LOG_WARNING, "errno is %d\n", errno);
                        }
                        endtls();
                        return;
@@ -557,7 +557,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
        while (1) {
                if (SSL_want_read(pssl)) {
                        if ((SSL_write(pssl, junk, 0)) < 1) {
-                               syslog(9, "SSL_write in client_read\n");
+                               syslog(LOG_WARNING, "SSL_write in client_read\n");
                        }
                }
                rlen = SSL_read(pssl, sbuf, sizeof(sbuf));
@@ -569,7 +569,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
                                sleeeeeeeeeep(1);
                                continue;
                        }
-                       syslog(9, "SSL_read got error %ld\n", errval);
+                       syslog(LOG_WARNING, "SSL_read got error %ld\n", errval);
                        endtls();
                        return (-1);
                }
index 242dbbddbbe22e2c9cb1d16797f597b60f89d447..ae381cc1e5b45afe68b9246c695f154a51b872a9 100644 (file)
@@ -119,7 +119,7 @@ void GetPrefTypes(HashList *List)
                        Pref->Type = PrefType;
                        Pref->eFlatPrefType = Pref->Type->eType;
 
-                       syslog(1, "Loading [%s]with type [%d] [\"%s\"]\n",
+                       syslog(LOG_DEBUG, "Loading [%s]with type [%d] [\"%s\"]\n",
                                ChrPtr(Pref->Key),
                                Pref->Type->eType,
                                ChrPtr(Pref->Val));
@@ -147,7 +147,7 @@ void GetPrefTypes(HashList *List)
 
                        if (PrefType->OnLoad != NULL){
 
-                               syslog(1, "Loading with: -> %s(\"%s\", %ld)\n",
+                               syslog(LOG_DEBUG, "Loading with: -> %s(\"%s\", %ld)\n",
                                        ChrPtr(PrefType->OnLoadName),
                                        ChrPtr(Pref->Val),
                                        Pref->lval);
@@ -208,7 +208,7 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
                        else 
                        {
                                StrBufTrim(ReadBuf);
-                               syslog(1, "ignoring spurious preference line: [%s]\n", 
+                               syslog(LOG_INFO, "ignoring spurious preference line: [%s]\n", 
                                        ChrPtr(ReadBuf));
                                DestroyPreference(Data);
                                LastData = NULL;
@@ -571,7 +571,7 @@ void set_preference_backend(const char *key, size_t keylen,
                Pref->Type = PrefType;
                Pref->eFlatPrefType = PrefType->eType;
                if (Pref->Type->eType != lPrefType)
-                       syslog(1, "warning: saving preference with wrong type [%s] %d != %ld \n",
+                       syslog(LOG_WARNING, "warning: saving preference with wrong type [%s] %d != %ld \n",
                                key, Pref->Type->eType, lPrefType);
                switch (Pref->Type->eType)
                {
index 78d08f18172f79c3768c52fb03235e44c5a9d7ad..d02f8084e3e78207f70d6817af6c08ee2159cb54 100644 (file)
@@ -233,7 +233,7 @@ void http_redirect(const char *whichpage) {
  */
 void http_transmit_thing(const char *content_type, int is_static)
 {
-       syslog(9, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
+       syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
        output_headers(0, 0, 0, 0, 0, is_static);
 
        hprintf("Content-type: %s\r\n"
index 99e4574035801954412276640f312dcd4cc39d2a..c2a0bd8cdbb12f2124ceca475ca601628bf69ac9 100644 (file)
@@ -226,17 +226,17 @@ int main(int argc, char **argv)
        LoadIconDir(static_icon_dir);
 
        /* Tell 'em who's in da house */
-       syslog(1, "%s", PACKAGE_STRING);
-       syslog(1, "Copyright (C) 1996-2012 by the citadel.org team");
-       syslog(1, " ");
-       syslog(1, "This program is open source software: you can redistribute it and/or");
-       syslog(1, "modify it under the terms of the GNU General Public License, version 3.");
-       syslog(1, " ");
-       syslog(1, "This program is distributed in the hope that it will be useful,");
-       syslog(1, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
-       syslog(1, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
-       syslog(1, "GNU General Public License for more details.");
-       syslog(1, " ");
+       syslog(LOG_NOTICE, "%s", PACKAGE_STRING);
+       syslog(LOG_NOTICE, "Copyright (C) 1996-2012 by the citadel.org team");
+       syslog(LOG_NOTICE, " ");
+       syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
+       syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
+       syslog(LOG_NOTICE, " ");
+       syslog(LOG_NOTICE, "This program is distributed in the hope that it will be useful,");
+       syslog(LOG_NOTICE, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
+       syslog(LOG_NOTICE, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
+       syslog(LOG_NOTICE, "GNU General Public License for more details.");
+       syslog(LOG_NOTICE, " ");
 
        /* initialize various subsystems */