the pid file. Updated setup.c to use this too.
* Bumped the version number to 7.02 in preparation for release...
WEBCIT for the Citadel System
WEBCIT for the Citadel System
Copyright (C) 1996-2006 by the authors. Portions written by:
Art Cancro
Copyright (C) 1996-2006 by the authors. Portions written by:
Art Cancro
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
if (!SSLCritters) {
lprintf(1, "citserver: can't allocate memory!!\n");
/* Nothing's been initialized, just die */
if (!SSLCritters) {
lprintf(1, "citserver: can't allocate memory!!\n");
/* Nothing's been initialized, just die */
lprintf(1,
"citserver: can't allocate memory!!\n");
/** Nothing's been initialized, just die */
lprintf(1,
"citserver: can't allocate memory!!\n");
/** Nothing's been initialized, just die */
}
pthread_mutex_init(SSLCritters[a], NULL);
}
}
pthread_mutex_init(SSLCritters[a], NULL);
}
- * install_init_scripts() -- Make sure "webserver" is in /etc/inittab
+ * install_init_scripts() -- Create and deploy SysV init scripts.
*
*/
void install_init_scripts(void)
*
*/
void install_init_scripts(void)
"\n"
"start) echo -n \"Starting WebCit... \"\n"
" if $WEBCIT_DIR/webserver "
"\n"
"start) echo -n \"Starting WebCit... \"\n"
" if $WEBCIT_DIR/webserver "
- "-d/var/run/webcit.pid "
+ "-D/var/run/webcit.pid "
"-t/dev/null "
"-p$HTTP_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
"-t/dev/null "
"-p$HTTP_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
#ifdef HAVE_OPENSSL
fprintf(fp, " echo -n \"Starting WebCit SSL... \"\n"
" if $WEBCIT_DIR/webserver "
#ifdef HAVE_OPENSSL
fprintf(fp, " echo -n \"Starting WebCit SSL... \"\n"
" if $WEBCIT_DIR/webserver "
- "-d/var/run/webcit-ssl.pid "
+ "-D/var/run/webcit-ssl.pid "
"-t/dev/null "
"-s -p$HTTPS_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
"-t/dev/null "
"-s -p$HTTPS_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
" then\n"
#define SLEEPING 180 /* TCP connection timeout */
#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
#define PORT_NUM 2000 /* port number to listen on */
#define SLEEPING 180 /* TCP connection timeout */
#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
#define PORT_NUM 2000 /* port number to listen on */
-#define SERVER "WebCit v7.00" /* who's in da house */
+#define SERVER "WebCit v7.02" /* who's in da house */
#define DEVELOPER_ID 0
#define CLIENT_ID 4
#define DEVELOPER_ID 0
#define CLIENT_ID 4
-#define CLIENT_VERSION 700 /* This version of WebCit */
+#define CLIENT_VERSION 702 /* This version of WebCit */
#define MINIMUM_CIT_VERSION 690 /* min required Citadel ver. */
#define DEFAULT_HOST "localhost" /* Default Citadel server */
#define DEFAULT_PORT "504"
#define MINIMUM_CIT_VERSION 690 /* min required Citadel ver. */
#define DEFAULT_HOST "localhost" /* Default Citadel server */
#define DEFAULT_PORT "504"
#define DEFAULT_HTTPAUTH_USER ""
#define DEFAULT_HTTPAUTH_PASS ""
#define DEFAULT_HTTPAUTH_USER ""
#define DEFAULT_HTTPAUTH_PASS ""
+
+/* Exit codes 101 through 109 are initialization failures so we don't want to
+ * just keep respawning indefinitely.
+ */
+#define WC_EXIT_BIND 101 /* Can't bind to the port */
+#define WC_EXIT_SSL 102 /* Can't initialize SSL */
if (port_number == 0) {
lprintf(1, "Cannot start: no port number specified.\n");
if (port_number == 0) {
lprintf(1, "Cannot start: no port number specified.\n");
}
sin.sin_port = htons((u_short) port_number);
s = socket(PF_INET, SOCK_STREAM, (getprotobyname("tcp")->p_proto));
if (s < 0) {
lprintf(1, "Can't create a socket: %s\n", strerror(errno));
}
sin.sin_port = htons((u_short) port_number);
s = socket(PF_INET, SOCK_STREAM, (getprotobyname("tcp")->p_proto));
if (s < 0) {
lprintf(1, "Can't create a socket: %s\n", strerror(errno));
}
/** Set some socket options that make sense. */
i = 1;
}
/** Set some socket options that make sense. */
i = 1;
if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
lprintf(1, "Can't bind: %s\n", strerror(errno));
if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
lprintf(1, "Can't bind: %s\n", strerror(errno));
}
if (listen(s, queue_len) < 0) {
lprintf(1, "Can't listen: %s\n", strerror(errno));
}
if (listen(s, queue_len) < 0) {
lprintf(1, "Can't listen: %s\n", strerror(errno));
if (i != 0) if (errno != ENOENT) {
lprintf(1, "citserver: can't unlink %s: %s\n",
sockpath, strerror(errno));
if (i != 0) if (errno != ENOENT) {
lprintf(1, "citserver: can't unlink %s: %s\n",
sockpath, strerror(errno));
}
memset(&addr, 0, sizeof(addr));
}
memset(&addr, 0, sizeof(addr));
if (s < 0) {
lprintf(1, "citserver: Can't create a socket: %s\n",
strerror(errno));
if (s < 0) {
lprintf(1, "citserver: Can't create a socket: %s\n",
strerror(errno));
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
lprintf(1, "citserver: Can't bind: %s\n",
strerror(errno));
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
lprintf(1, "citserver: Can't bind: %s\n",
strerror(errno));
}
if (listen(s, actual_queue_len) < 0) {
lprintf(1, "citserver: Can't listen: %s\n",
strerror(errno));
}
if (listen(s, actual_queue_len) < 0) {
lprintf(1, "citserver: Can't listen: %s\n",
strerror(errno));
child = fork();
if (child != 0) {
child = fork();
if (child != 0) {
- fp = fopen(pid_file, "w");
- if (fp != NULL) {
- fprintf(fp, "%d\n", child);
- fclose(fp);
+ if (pid_file) {
+ fp = fopen(pid_file, "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d\n", child);
+ fclose(fp);
+ }
+ if (pid_file) {
+ unlink(pid_file);
+ }
exit(WEXITSTATUS(status));
}
exit(WEXITSTATUS(status));
}
int home_specified=0;
char relhome[PATH_MAX]="";
char webcitdir[PATH_MAX] = DATADIR;
int home_specified=0;
char relhome[PATH_MAX]="";
char webcitdir[PATH_MAX] = DATADIR;
- char pidfile[PATH_MAX] = "";
char *hdir;
const char *basedir;
#ifdef ENABLE_NLS
char *hdir;
const char *basedir;
#ifdef ENABLE_NLS
/** Parse command line */
#ifdef HAVE_OPENSSL
/** Parse command line */
#ifdef HAVE_OPENSSL
- while ((a = getopt(argc, argv, "h:i:p:t:x:d:cfs")) != EOF)
+ while ((a = getopt(argc, argv, "h:i:p:t:x:dD:cfs")) != EOF)
- while ((a = getopt(argc, argv, "h:i:p:t:x:d:cf")) != EOF)
+ while ((a = getopt(argc, argv, "h:i:p:t:x:dD:cf")) != EOF)
#endif
switch (a) {
case 'h':
#endif
switch (a) {
case 'h':
- hdir = strdup(optarg);
- safestrncpy(pidfile, hdir,sizeof pidfile);
+ running_as_daemon = 1;
+ break;
+ case 'D':
+ pidfile = strdup(optarg);
running_as_daemon = 1;
break;
case 'i':
running_as_daemon = 1;
break;
case 'i':