Accept the origin host as indicated by the client, if the connection is from 127...
authorArt Cancro <ajc@citadel.org>
Wed, 19 Jun 2019 18:38:13 +0000 (14:38 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 19 Jun 2019 18:38:13 +0000 (14:38 -0400)
citadel/context.c
citadel/context.h
citadel/modules/ctdlproto/serv_session.c
citadel/sysdep.c

index 6593870a4f9038ffa361d5ed7fc1d5cea3982f58..f5efd5c1c5c2781db643f91e5cd27fa024c93267 100644 (file)
@@ -495,7 +495,7 @@ void begin_session(CitContext *con)
        safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
        con->cs_UDSclientUID = -1;
        con->cs_host[sizeof con->cs_host - 1] = 0;
-       if (!CC->is_local_socket) {
+       if (!CC->is_local_client) {
                locate_host(con->cs_host, sizeof con->cs_host,
                        con->cs_addr, sizeof con->cs_addr,
                        con->client_socket
@@ -545,12 +545,9 @@ void begin_session(CitContext *con)
                con->nologin = 1;
        }
 
-       if (!CC->is_local_socket) {
-               syslog(LOG_INFO, "context: session (%s) started from %s (%s)", con->ServiceName, con->cs_host, con->cs_addr);
-       }
-       else {
-               syslog(LOG_INFO, "context: session (%s) started via local socket with uid=%d", con->ServiceName, con->cs_UDSclientUID);
-       }
+       syslog(LOG_INFO, "context: session (%s) started from %s (%s) uid=%d",
+               con->ServiceName, con->cs_host, con->cs_addr, con->cs_UDSclientUID
+       );
 
        /* Run any session startup routines registered by loadable modules */
        PerformSessionHooks(EVT_START);
index 65c7515f4f184265e8bb443f6b2ca747bfe9add6..95fa16d90d70be27216ffbf55105807f9e531a78 100644 (file)
@@ -57,7 +57,7 @@ struct CitContext {
        StrBuf *sMigrateBuf;    /* Our block buffered read buffer */
 
        int client_socket;
-       int is_local_socket;    /* set to 1 if client is on unix domain sock */
+       int is_local_client;    /* set to 1 if client is running on the same host */
        /* Redirect this session's output to a memory buffer? */
        StrBuf *redirect_buffer;                /* the buffer */
        StrBuf *StatusMessage;
index fa8186635381a62e51bccfd064165f57d6c4ee66..b1b6d42350f87d7590614a04f91f747c84caec81 100644 (file)
@@ -152,7 +152,7 @@ void cmd_iden(char *argbuf)
        CC->cs_clientname[31] = 0;
 
        /* For local sockets, allow the client to supply the user's origin address */
-       if (CC->is_local_socket) {
+       if ((CC->is_local_client) || (!IsEmptyStr(CC->cs_addr) && (!strcmp(CC->cs_addr, "127.0.0.1")) || (!strcmp(CC->cs_addr, "::1")))) {
                safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
                CC->cs_host[sizeof CC->cs_host - 1] = 0;
                CC->cs_addr[0] = 0;
index 8f0a124669c0ebca9dca77e2a080c3456f0879aa..971d729c4c282de588a791b04dd7de96eddbd679 100644 (file)
@@ -4,7 +4,7 @@
  * Here's where we (hopefully) have most parts of the Citadel server that
  * might need tweaking when run on different operating system variants.
  *
- * Copyright (c) 1987-2017 by the citadel.org team
+ * Copyright (c) 1987-2019 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -1109,12 +1109,12 @@ void HuntBadSession(void)
                        {
                                /* Gotcha! */
                                syslog(LOG_ERR,
-                                      "sysdep: killing session CC[%d] bad FD: [%d:%d] User[%s] Host[%s:%s]",
-                                      ptr->cs_pid,
-                                      ptr->client_socket,
-                                      ptr->is_local_socket,
-                                      ptr->curr_user,
-                                      ptr->cs_host,ptr->cs_addr
+                                      "sysdep: killing session CC[%d] bad FD: [%d] User[%s] Host[%s:%s]",
+                                       ptr->cs_pid,
+                                       ptr->client_socket,
+                                       ptr->curr_user,
+                                       ptr->cs_host,
+                                       ptr->cs_addr
                                );
                                ptr->kill_me = 1;
                                ptr->client_socket = -1;
@@ -1292,9 +1292,9 @@ do_select:        force_purge = 0;
                                        con->h_greeting_function = serviceptr->h_greeting_function;
                                        con->ServiceName = serviceptr->ServiceName;
                                        
-                                       /* Determine whether it's a local socket */
+                                       /* Connections on a local client are always from the same host */
                                        if (serviceptr->sockpath != NULL) {
-                                               con->is_local_socket = 1;
+                                               con->is_local_client = 1;
                                        }
        
                                        /* Set the SO_REUSEADDR socket option */