random boilerplate
[citadel.git] / citadel / context.c
index f95a7a2f7cab24e9a867aa92f4f95b6f993c6e72..1a2816f5491aaa555b7e858862fb3066e27e9bdb 100644 (file)
@@ -1,22 +1,15 @@
-/*
- * Citadel context management stuff.
- * Here's where we (hopefully) have all the code that manipulates contexts.
- *
- * Copyright (c) 1987-2015 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+//
+// Citadel context management stuff.
+// Here's where we (hopefully) have all the code that manipulates contexts.
+//
+// Copyright (c) 1987-2020 by the citadel.org team
+//
+// This program is open source software.  Use, duplication, or disclosure
+// is subject to the terms of the GNU General Public License, version 3.
+// The program is distributed without any warranty, expressed or implied.
 
 #include "ctdl_module.h"
 #include "serv_extensions.h"
-#include "ecrash.h"
-
 #include "citserver.h"
 #include "user_ops.h"
 #include "locate_host.h"
@@ -52,6 +45,7 @@ int CtdlTrySingleUser(void)
        return can_do;
 }
 
+
 void CtdlEndSingleUser(void)
 {
        begin_critical_section(S_SINGLE_USER);
@@ -65,21 +59,19 @@ int CtdlWantSingleUser(void)
        return want_single_user;
 }
 
+
 int CtdlIsSingleUser(void)
 {
        if (want_single_user)
        {
                /* check for only one context here */
                if (num_sessions == 1)
-                       return TRUE;
+                       return 1;
        }
-       return FALSE;
+       return 0;
 }
 
 
-
-
-
 /*
  * Locate a context by its session number and terminate it if the user is able.
  * User can NOT terminate their current session.
@@ -295,7 +287,6 @@ void RemoveContext (CitContext *con)
                c = "WTF?";
        }
        syslog(LOG_DEBUG, "context: RemoveContext(%s) session %d", c, con->cs_pid);
-///    cit_backtrace();
 
        /* Run any cleanup routines registered by loadable modules.
         * Note: We have to "become_session()" because the cleanup functions
@@ -494,16 +485,12 @@ void begin_session(CitContext *con)
        strcpy(con->lastcmdname, "    ");
        strcpy(con->cs_clientname, "(unknown)");
        strcpy(con->curr_user, NLI);
-       *con->net_node = '\0';
-       *con->fake_username = '\0';
-       *con->fake_hostname = '\0';
-       *con->fake_roomname = '\0';
        *con->cs_clientinfo = '\0';
        safestrncpy(con->cs_host, CtdlGetConfigStr("c_fqdn"), sizeof con->cs_host);
        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
@@ -547,20 +534,15 @@ void begin_session(CitContext *con)
 #endif
        }
        con->cs_flags = 0;
-       con->upload_type = UPL_FILE;
-       con->dl_is_net = 0;
 
        con->nologin = 0;
        if (((CtdlGetConfigInt("c_maxsessions") > 0)&&(num_sessions > CtdlGetConfigInt("c_maxsessions"))) || CtdlWantSingleUser()) {
                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);
@@ -581,16 +563,16 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        context->cs_pid = 0;
        strcpy (sysname, "SYS_");
        strcat (sysname, name);
-       len = cutuserkey(sysname);
+       len = strlen(sysname);
        memcpy(context->curr_user, sysname, len + 1);
        context->client_socket = (-1);
        context->state = CON_SYS;
        context->ServiceName = name;
 
-       /* internal_create_user has the side effect of loading the user regardless of wether they
+       /* internal_create_user has the side effect of loading the user regardless of whether they
         * already existed or needed to be created
         */
-       internal_create_user (sysname, len, &(context->user), -1) ;
+       internal_create_user(sysname, &(context->user), -1) ;
        
        /* Check to see if the system user needs upgrading */
        if (context->user.usernum == 0)