/*
- * $Id$
- *
* Main source module for the Citadel server
*
* Copyright (c) 1987-2010 by the citadel.org team
strings = backtrace_symbols(stack_frames, size);
for (i = 0; i < size; i++) {
if (strings != NULL)
- CtdlLogPrintf(1, "%s\n", strings[i]);
+ CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
else
- CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+ CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
}
free(strings);
#endif
strings = backtrace_symbols(stack_frames, size);
for (i = 0; i < size; i++) {
if (strings != NULL)
- CtdlLogPrintf(1, "%s\n", strings[i]);
+ CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
else
- CtdlLogPrintf(1, "%p\n", stack_frames[i]);
+ CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
}
free(strings);
#endif
else {
cprintf("0\n"); /* OpenID is disabled when using non-native auth */
}
+
+ cprintf("%d\n", config.c_guest_logins);
cprintf("000\n");
}
int rev_level;
char desc[128];
char from_host[128];
- struct in_addr addr;
- int do_lookup = 0;
if (num_parms(argbuf)<4) {
cprintf("%d usage error\n", ERROR + ILLEGAL_VALUE);
safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
CC->cs_clientname[31] = 0;
- if (!IsEmptyStr(from_host)) {
- if (CC->is_local_socket) do_lookup = 1;
- else if (is_public_client()) do_lookup = 1;
- }
-
- if (do_lookup) {
- CtdlLogPrintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
- if ((addr.s_addr = inet_addr(from_host)) != -1) {
- locate_host(CC->cs_host, sizeof CC->cs_host,
- CC->cs_addr, sizeof CC->cs_addr,
- &addr);
- }
- else {
- safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
- CC->cs_host[sizeof CC->cs_host - 1] = 0;
- }
+ /* For local sockets and public clients, trust the hostname supplied by the client */
+ if ( (CC->is_local_socket) || (is_public_client()) ) {
+ safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
+ CC->cs_host[sizeof CC->cs_host - 1] = 0;
+ CC->cs_addr[0] = 0;
}
CtdlLogPrintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
return(-1);
}
+ if ((required_level >= ac_logged_in_or_guest) && (CC->logged_in == 0) && (!config.c_guest_logins)) {
+ cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
+ return(-1);
+ }
+
if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
return(-1);
*con->fake_username = '\0';
*con->fake_hostname = '\0';
*con->fake_roomname = '\0';
+ *con->cs_clientinfo = '\0';
generate_nonce(con);
safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
con->cs_host[sizeof con->cs_host - 1] = 0;
len = sizeof sin;
if (!CC->is_local_socket) {
- if (!getpeername(con->client_socket, (struct sockaddr *) &sin, &len)) {
- locate_host(con->cs_host, sizeof con->cs_host,
- con->cs_addr, sizeof con->cs_addr,
- &sin.sin_addr
- );
- }
+ locate_host(con->cs_host, sizeof con->cs_host,
+ con->cs_addr, sizeof con->cs_addr,
+ con->client_socket
+ );
}
else {
- strcpy(con->cs_host, "");
+ con->cs_host[0] = 0;
+ con->cs_addr[0] = 0;
#ifdef HAVE_STRUCT_UCRED
{
/* as http://www.wsinnovations.com/softeng/articles/uds.html told us... */
database, after a reverse lookup on the UID to get the account name.
We can take this opportunity to check to see if this is a legit account.
*/
+ snprintf(con->cs_clientinfo, sizeof(con->cs_clientinfo),
+ "PID: "F_PID_T"; UID: "F_UID_T"; GID: "F_XPID_T" ",
+ credentials.pid,
+ credentials.uid,
+ credentials.gid);
}
}
#endif
}
if (!CC->is_local_socket) {
- CtdlLogPrintf(CTDL_NOTICE, "Session started from %s [%s].\n", con->cs_host, con->cs_addr);
+ CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started from %s (%s).\n", con->ServiceName, con->cs_host, con->cs_addr);
}
else {
- CtdlLogPrintf(CTDL_NOTICE, "Session started via local socket.\n");
+ CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started via local socket UID:%d.\n", con->ServiceName, con->cs_UDSclientUID);
}
/* Run any session startup routines registered by loadable modules */
/* Log the server command, but don't show passwords... */
if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) {
- CtdlLogPrintf(CTDL_INFO, "%s\n", cmdbuf);
+ CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
}
else {
- CtdlLogPrintf(CTDL_INFO, "<password command hidden from log>\n");
+ CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
}
buffer_output();
CtdlRegisterProtoHook(cmd_scdn, "SCDN", "schedule or cancel a server shutdown");
CtdlRegisterProtoHook(cmd_time, "TIME", "fetch the date and time from the server");
}
- /* return our Subversion id for the Log */
- return "$Id$";
+ /* return our id for the Log */
+ return "citserver";
}