* waiting on the specified port for incoming HTTP connections. When a
* connection is established, it calls context_loop() from context_loop.c.
*
- * Copyright (c) 1996-2009 by the citadel.org developers.
+ * Copyright (c) 1996-2010 by the citadel.org developers.
* This program is released under the terms of the GNU General Public License v3.
*
*/
extern int ig_tcp_server(char *ip_addr, int port_number, int queue_len);
extern int ig_uds_server(char *sockpath, int queue_len);
+extern void drop_root(uid_t UID);
char ctdl_key_dir[PATH_MAX]=SSL_DIR;
char file_crpt_file_key[PATH_MAX]="";
*/
int main(int argc, char **argv)
{
+ uid_t UID = -1;
size_t basesize = 2; /* how big should strbufs be on creation? */
pthread_t SessThread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */
const char *I18nDumpFile = NULL;
FILE *rvfp = NULL;
+ int rv = 0;
WildFireInitBacktrace(argv[0], 2);
/* Parse command line */
#ifdef HAVE_OPENSSL
- while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfsZ")) != EOF)
+ while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:dD:G:cfsS:Z")) != EOF)
#else
- while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfZ")) != EOF)
+ while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:dD:G:cfZ")) != EOF)
#endif
switch (a) {
+ case 'u':
+ UID = atol(optarg);
+ break;
case 'h':
hdir = strdup(optarg);
relh=hdir[0]!='/';
- if (!relh) safestrncpy(webcitdir, hdir,
- sizeof webcitdir);
- else
- safestrncpy(relhome, relhome,
- sizeof relhome);
+ if (!relh) {
+ safestrncpy(webcitdir, hdir, sizeof webcitdir);
+ }
+ else {
+ safestrncpy(relhome, relhome, sizeof relhome);
+ }
/* free(hdir); TODO: SHOULD WE DO THIS? */
home_specified = 1;
home=1;
}
}
break;
+#ifdef HAVE_OPENSSL
case 's':
is_https = 1;
break;
+ case 'S':
+ is_https = 1;
+ ssl_cipher_list = strdup(optarg);
+ break;
+#endif
case 'G':
DumpTemplateI18NStrings = 1;
I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
"[-T Templatedebuglevel] "
"[-d] [-Z] [-G i18ndumpfile] "
#ifdef HAVE_OPENSSL
- "[-s] "
+ "[-s] [-S cipher_suites]"
#endif
"[remotehost [remoteport]]\n");
return 1;
/* Tell 'em who's in da house */
lprintf(1, PACKAGE_STRING "\n");
- lprintf(1, "Copyright (C) 1996-2009 by the Citadel development team.\n"
+ lprintf(1, "Copyright (C) 1996-2010 by the Citadel development team.\n"
"This software is distributed under the terms of the "
"GNU General Public License.\n\n"
);
lprintf(1, "********************************************************************************\n");
return -1;
}
- fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd);
+ rv = fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd);
fclose(fd);
return 0;
}
lprintf(2, "Attempting to bind to port %d...\n", http_port);
msock = ig_tcp_server(ip_addr, http_port, LISTEN_QUEUE_LENGTH);
}
+ if (msock < 0)
+ {
+ ShutDownWebcit();
+ return -msock;
+ }
lprintf(2, "Listening on socket %d\n", msock);
signal(SIGPIPE, SIG_IGN);
init_ssl();
}
#endif
+ drop_root(UID);
/* Start a few initial worker threads */
for (i = 0; i < (MIN_WORKER_THREADS); ++i) {
}
}
else
+#endif
{
int fdflags;
fdflags = fcntl(ssock, F_GETFL);
lprintf(1, "unable to get server socket flags! %s \n",
strerror(errno));
fdflags = fdflags | O_NONBLOCK;
- if (fcntl(ssock, F_SETFD, fdflags) < 0)
+ if (fcntl(ssock, F_SETFL, fdflags) < 0)
lprintf(1, "unable to set server socket nonblocking flags! %s \n",
strerror(errno));
}
-#endif
if (fail_this_transaction == 0) {
Hdr.http_sock = ssock;