Began removing $Id$ tags. This will be an ongoing process.
[citadel.git] / citadel / citserver.c
index cd13b3e3c297c2e5fd6f8be04c25ed0e55ed5627..48e4deae038439e250011538a2e800934481aa86 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- *
  * Main source module for the Citadel server
  *
  * Copyright (c) 1987-2010 by the citadel.org team
@@ -297,6 +295,8 @@ void cmd_info(char *cmdbuf) {
        else {
                cprintf("0\n"); /* OpenID is disabled when using non-native auth */
        }
+
+       cprintf("%d\n", config.c_guest_logins);
        
        cprintf("000\n");
 }
@@ -443,8 +443,6 @@ void cmd_iden(char *argbuf)
        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);
@@ -466,22 +464,11 @@ void cmd_iden(char *argbuf)
        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",
@@ -920,15 +907,14 @@ void begin_session(CitContext *con)
        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... */
@@ -968,10 +954,10 @@ void begin_session(CitContext *con)
        }
 
        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 */
@@ -1118,6 +1104,6 @@ CTDL_MODULE_INIT(citserver)
                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";
 }