Accept the origin host as indicated by the client, if the connection is from 127...
[citadel.git] / citadel / sysdep.c
index d17e2bf1521db56730f309a97dafd96f37834aa0..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.
@@ -376,7 +376,6 @@ int client_write(const char *buf, int nbytes)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                fprintf(fd, "Sending: BufSize: %d BufContent: [", nbytes);
@@ -419,7 +418,6 @@ int client_write(const char *buf, int nbytes)
                                        }
                                } else {
                                        syslog(LOG_ERR, "sysdep: client_write(%d bytes) select failed: %m", nbytes - bytes_written);
-                                       cit_backtrace();
                                        client_close();
                                        Ctx->kill_me = KILLME_SELECT_FAILED;
                                        return -1;
@@ -430,7 +428,6 @@ int client_write(const char *buf, int nbytes)
                retval = write(Ctx->client_socket, &buf[bytes_written], nbytes - bytes_written);
                if (retval < 1) {
                        syslog(LOG_ERR, "sysdep: client_write(%d bytes) failed: %m", nbytes - bytes_written);
-                       cit_backtrace();
                        client_close();
                        Ctx->kill_me = KILLME_WRITE_FAILED;
                        return -1;
@@ -492,7 +489,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                fprintf(fd, "Reading BLOB: BufSize: %d ", bytes);
@@ -512,7 +508,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                fprintf(fd, "Read: %d BufContent: [", StrLength(Target));
@@ -534,7 +529,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                fprintf(fd, "Reading BLOB: BufSize: %d ",
@@ -563,7 +557,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                fprintf(fd, "Read: %d BufContent: [",
@@ -622,7 +615,6 @@ int client_read_random_blob(StrBuf *Target, int timeout)
                                fd = fopen(fn, "a+");
                                if (fd == NULL) {
                                        syslog(LOG_ERR, "%s: %m", fn);
-                                       cit_backtrace();
                                        exit(1);
                                }
                                fprintf(fd, "Read: BufSize: %d BufContent: [",
@@ -707,7 +699,6 @@ int CtdlClientGetLine(StrBuf *Target)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                pch = ChrPtr(CCC->RecvBuf.Buf);
@@ -765,7 +756,6 @@ int CtdlClientGetLine(StrBuf *Target)
                fd = fopen(fn, "a+");
                if (fd == NULL) {
                        syslog(LOG_ERR, "%s: %m", fn);
-                       cit_backtrace();
                        exit(1);
                }
                pch = ChrPtr(CCC->RecvBuf.Buf);
@@ -932,7 +922,6 @@ void sysdep_master_cleanup(void) {
        CtdlDestroyProtoHooks();
        CtdlDestroyDeleteHooks();
        CtdlDestroyXmsgHooks();
-       CtdlDestroyNetprocHooks();
        CtdlDestroyUserHooks();
        CtdlDestroyMessageHook();
        CtdlDestroyCleanupHooks();
@@ -941,9 +930,6 @@ void sysdep_master_cleanup(void) {
        CtdlDestroyServiceHook();
        CtdlDestroyRoomHooks();
        CtdlDestroySearchHooks();
-       #ifdef HAVE_BACKTRACE
-///    eCrash_Uninit();
-       #endif
 }
 
 
@@ -1123,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;
@@ -1306,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 */