From: Art Cancro Date: Wed, 19 Jun 2019 18:38:13 +0000 (-0400) Subject: Accept the origin host as indicated by the client, if the connection is from 127... X-Git-Tag: v939~291 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=cb5275786332fa50897200781d3100449b5f71dd Accept the origin host as indicated by the client, if the connection is from 127.0.0.1 or ::1 (or on a local socket, as before) --- diff --git a/citadel/context.c b/citadel/context.c index 6593870a4..f5efd5c1c 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -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); diff --git a/citadel/context.h b/citadel/context.h index 65c7515f4..95fa16d90 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -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; diff --git a/citadel/modules/ctdlproto/serv_session.c b/citadel/modules/ctdlproto/serv_session.c index fa8186635..b1b6d4235 100644 --- a/citadel/modules/ctdlproto/serv_session.c +++ b/citadel/modules/ctdlproto/serv_session.c @@ -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; diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 8f0a12466..971d729c4 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -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 */