computer's syslog facility instead of to a trace file.
$Log$
+ Revision 614.2 2004/01/17 03:17:34 ajc
+ * New server command-line option "-l" to send log output to the host
+ computer's syslog facility instead of to a trace file.
+
Revision 614.1 2004/01/02 22:13:59 ajc
* Link to OpenLDAP client library (-lldap) and set HAVE_LDAP if present.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <syslog.h>
/* #include <dlfcn.h> */
#include <netdb.h>
#include <sys/types.h>
logout(con);
unlink(con->temp);
- lprintf(3, "Session ended.\n");
- syslog(LOG_NOTICE,"Session %d: ended.", con->cs_pid);
+ lprintf(3, "Session %d: ended.\n", con->cs_pid);
/* Deallocate any user-data attached to this session */
deallocate_user_data(con);
}
}
- lprintf(7, "Client %d/%d/%01d.%02d (%s)\n",
- dev_code,
- cli_code,
- (rev_level / 100),
- (rev_level % 100),
- desc);
-
- syslog(LOG_NOTICE,"Session %d: Client %d/%d/%01d.%02d (%s) from %s\n",
+ lprintf(3,"Session %d: Client %d/%d/%01d.%02d (%s) from %s\n",
CC->cs_pid,
dev_code,
cli_code,
if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions))
con->nologin = 1;
- lprintf(3, "Session started.\n");
- syslog(LOG_NOTICE, "Session %d: started.", con->cs_pid);
+ lprintf(3, "Session %d: started.\n", con->cs_pid);
/* Run any session startup routines registered by loadable modules */
PerformSessionHooks(EVT_START);
#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <syslog.h>
#include <sys/types.h>
#include "citadel.h"
#include "server.h"
<p>The next step is to arrange for the server to start. The <tt>citserver</tt>
program is the main Citadel server. Before we cover the recommended
method of starting the server, let's examine its usage options:</p>
-<pre>citserver [-hHomeDir] [-xDebugLevel] [-tTraceFile] [-d] [-f]<br></pre>
+<pre>citserver [-hHomeDir] [-xDebugLevel] [-tTraceFile] [-lLogFacility] [-d] [-f]<br></pre>
<p>The options are as follows:</p>
<p><tt>-hHomeDir</tt> - the directory your Citadel data files live in.
This should, of course, be a directory that you've run the <tt>setup</tt>
</ul>
<p><tt>-tTraceFile</tt> - Tell the server where to send its debug/trace
output. Normally it is sent to stdout.</p>
+<p><tt>-lLogFacility</tt> - Tell the server to send its debug/trace output
+to the <tt>syslog</tt> service on the host system <i>instead of</i> to a
+trace file. <tt>LogFacility</tt> must be one of: <tt><i>kern, user, mail,
+daemon, auth, syslog, lpr, news, uucp, local0, local1, local2, local3,
+local4, local5, local6, local7</i></tt>. Please note that use of the
+<tt>-l</tt> option will cancel any use of the <tt>-t</tt> option; that is,
+if you specify a trace file <i>and</i> a syslog facility, log output will
+only go to the syslog facility.
<p><tt>-d</tt> - Run as a daemon; i.e. in the background. This switch
would be necessary if you were starting the Citadel server, for
example, from an rc.local script (which is not recommended, because
#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <syslog.h>
#include "citadel.h"
#include "server.h"
#include "serv_extensions.h"
#include <ctype.h>
#include <string.h>
-#include <syslog.h>
#include <limits.h>
#include <errno.h>
#include <stdarg.h>
#include "citadel.h"
#include "server.h"
#include "serv_extensions.h"
-#include <syslog.h>
#include "serv_chat.h"
#include "sysdep_decls.h"
#include "citserver.h"
#include <limits.h>
#include "citadel.h"
#include "server.h"
-#include <syslog.h>
#include "sysdep_decls.h"
#include "citserver.h"
#include "support.h"
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
-#include <syslog.h>
#include <limits.h>
#include <ctype.h>
#include "citadel.h"
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <syslog.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
#include <pwd.h>
#include <errno.h>
#include <stdarg.h>
-#include <syslog.h>
#include <grp.h>
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
chmod(tracefile, 0600);
}
+ else if (!strncmp(argv[a], "-l", 2)) {
+ safestrncpy(tracefile, argv[a], sizeof tracefile);
+ strcpy(tracefile, &tracefile[2]);
+ syslog_facility = SyslogFacility(tracefile);
+ if (syslog_facility >= 0) {
+ openlog("citadel", LOG_PID, syslog_facility);
+ }
+ }
+
/* run in the background if -d was specified */
else if (!strcmp(argv[a], "-d")) {
start_daemon( (strlen(tracefile) > 0) ? 0 : 1 ) ;
/* any other parameter makes it crash and burn */
else {
lprintf(1, "citserver: usage: "
- "citserver [-tTraceFile] [-d] [-f]"
+ "citserver [-tTraceFile] "
+ "[-lLogFacility] "
+ "[-d] [-f]"
" [-xLogLevel] [-hHomeDir]\n");
exit(1);
}
/* Initialize... */
init_sysdep();
- openlog("citserver", LOG_PID, LOG_USER);
/* Load site-specific parameters, and set the ipgm secret */
lprintf(7, "Loading citadel.config\n");
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <sys/syslog.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
#include <pwd.h>
#include <errno.h>
#include <stdarg.h>
-#include <syslog.h>
#include <grp.h>
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
pthread_t initial_thread; /* tid for main() thread */
+int syslog_facility = (-1);
+
/*
* lprintf() ... Write logging information
vsnprintf(buf, sizeof(buf), format, arg_ptr);
va_end(arg_ptr);
- if (loglevel <= verbosity) {
+ if (syslog_facility >= 0) {
+ if (loglevel <= verbosity) {
+ syslog(LOG_NOTICE, buf);
+ }
+ }
+ else if (loglevel <= verbosity) {
struct timeval tv;
struct tm *tim;
time_t unixtime;
--num_threads;
return NULL;
}
+
+
+
+
+/*
+ * SyslogFacility()
+ * Translate text facility name to syslog.h defined value.
+ */
+int SyslogFacility(char *name)
+{
+ int i;
+ struct
+ {
+ int facility;
+ char *name;
+ } facTbl[] =
+ {
+ { LOG_KERN, "kern" },
+ { LOG_USER, "user" },
+ { LOG_MAIL, "mail" },
+ { LOG_DAEMON, "daemon" },
+ { LOG_AUTH, "auth" },
+ { LOG_SYSLOG, "syslog" },
+ { LOG_LPR, "lpr" },
+ { LOG_NEWS, "news" },
+ { LOG_UUCP, "uucp" },
+ { LOG_LOCAL0, "local0" },
+ { LOG_LOCAL1, "local1" },
+ { LOG_LOCAL2, "local2" },
+ { LOG_LOCAL3, "local3" },
+ { LOG_LOCAL4, "local4" },
+ { LOG_LOCAL5, "local5" },
+ { LOG_LOCAL6, "local6" },
+ { LOG_LOCAL7, "local7" },
+ { 0, NULL }
+ };
+ for(i = 0; facTbl[i].name != NULL; i++) {
+ if(!strcasecmp(name, facTbl[i].name))
+ return facTbl[i].facility;
+ }
+ return -1;
+}
+
pthread_t tid;
struct worker_node *next;
} *worker_list;
+
+
+extern int SyslogFacility(char *name);
+extern int syslog_facility;
#endif
#include <string.h>
-#include <syslog.h>
#include <limits.h>
#ifndef ENABLE_CHKPWD
#include "auth.h"
{
int i;
- syslog(LOG_NOTICE, "Session %d: %s logged in",
+ lprintf(3, "Session %d: %s logged in",
CC->cs_pid, CC->curr_user);
lgetuser(&CC->user, CC->curr_user);
#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <syslog.h>
#include "citadel.h"
#include "server.h"