more work on removing masqueraded user/room/host names
authorArt Cancro <ajc@citadel.org>
Sat, 16 Mar 2019 22:05:47 +0000 (18:05 -0400)
committerArt Cancro <ajc@citadel.org>
Sat, 16 Mar 2019 22:05:47 +0000 (18:05 -0400)
citadel/context.c
citadel/context.h
citadel/modules/instmsg/serv_instmsg.c
citadel/modules/rwho/serv_rwho.c
citadel/user_ops.c

index 88ddbe21bd6581f3693bfafa0f52612e5e29c021..6593870a4f9038ffa361d5ed7fc1d5cea3982f58 100644 (file)
@@ -2,7 +2,7 @@
  * Citadel context management stuff.
  * Here's where we (hopefully) have all the code that manipulates contexts.
  *
- * Copyright (c) 1987-2018 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.
@@ -490,9 +490,6 @@ void begin_session(CitContext *con)
        strcpy(con->lastcmdname, "    ");
        strcpy(con->cs_clientname, "(unknown)");
        strcpy(con->curr_user, NLI);
-       *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);
index 37ce184061791cad5179b058cda0e97209dab51e..65c7515f4f184265e8bb443f6b2ca747bfe9add6 100644 (file)
@@ -113,11 +113,6 @@ struct CitContext {
        int disable_exp;        /* Set to 1 to disable incoming pages */
        int newmail;            /* Other sessions increment this */
 
-       /* Masqueraded values in the 'who is online' list */
-       char fake_username[USERNAME_SIZE];
-       char fake_hostname[64];
-       char fake_roomname[ROOMNAMELEN];
-
        /* Preferred MIME formats */
        char preferred_formats[256];
        int msg4_dont_decode;
index 1bf8c728a9877ca1b6cd35fa7030b70214d73c39..dfa16cc689eb75ca34c3b51a2b2815b9cc433b40 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module handles instant messaging between users.
  * 
- * Copyright (c) 1987-2018 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.
@@ -235,7 +235,6 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        int message_sent = 0;           /* number of successful sends */
        struct CitContext *ccptr;
        struct ExpressMessage *newmsg = NULL;
-       char *un;
        int do_send = 0;                /* 1 = send message; 0 = only check for valid recipient */
        static int serial_number = 0;   /* this keeps messages from getting logged twice */
 
@@ -248,14 +247,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        ++serial_number;
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
 
-               if (ccptr->fake_username[0]) {
-                       un = ccptr->fake_username;
-               }
-               else {
-                       un = ccptr->user.fullname;
-               }
-
-               if ( ((!strcasecmp(un, x_user))
+               if ( ((!strcasecmp(ccptr->user.fullname, x_user))
                    || (!strcasecmp(x_user, "broadcast")))
                    && (ccptr->can_receive_im)
                    && ((ccptr->disable_exp == 0)
@@ -294,7 +286,6 @@ void cmd_sexp(char *argbuf)
        int message_sent = 0;
        char x_user[USERNAME_SIZE];
        char x_msg[1024];
-       char *lun;
        char *lem;
        char *x_big_msgbuf = NULL;
 
@@ -302,12 +293,6 @@ void cmd_sexp(char *argbuf)
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
                return;
        }
-       if (CC->fake_username[0]) {
-               lun = CC->fake_username;
-       }
-       else {
-               lun = CC->user.fullname;
-       }
 
        lem = CC->cs_inet_email;
 
@@ -325,7 +310,7 @@ void cmd_sexp(char *argbuf)
        }
        /* This loop handles text-transfer pages */
        if (!strcmp(x_msg, "-")) {
-               message_sent = PerformXmsgHooks(lun, lem, x_user, "");
+               message_sent = PerformXmsgHooks(CC->user.fullname, lem, x_user, "");
                if (message_sent == 0) {
                        if (CtdlGetUser(NULL, x_user))
                                cprintf("%d '%s' does not exist.\n",
@@ -349,12 +334,12 @@ void cmd_sexp(char *argbuf)
                                strcat(x_big_msgbuf, "\n");
                        strcat(x_big_msgbuf, x_msg);
                }
-               PerformXmsgHooks(lun, lem, x_user, x_big_msgbuf);
+               PerformXmsgHooks(CC->user.fullname, lem, x_user, x_big_msgbuf);
                free(x_big_msgbuf);
 
                /* This loop handles inline pages */
        } else {
-               message_sent = PerformXmsgHooks(lun, lem, x_user, x_msg);
+               message_sent = PerformXmsgHooks(CC->user.fullname, lem, x_user, x_msg);
 
                if (message_sent > 0) {
                        if (!IsEmptyStr(x_msg)) {
index 8967aca3610d2b50c01547aae540838dccdc658e..79ea2c6bda50acbb365e14605d21845d4383c289 100644 (file)
@@ -2,7 +2,7 @@
  * This module implements server commands related to the display and
  * manipulation of the "Who's online" list.
  *
- * Copyright (c) 1987-2012 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.
@@ -90,13 +90,9 @@ void cmd_rwho(char *argbuf) {
        struct CitContext *nptr;
        int nContexts, i;
        int spoofed = 0;
-       int user_spoofed = 0;
-       int room_spoofed = 0;
-       int host_spoofed = 0;
        int aide;
-       char un[40];
        char real_room[ROOMNAMELEN], room[ROOMNAMELEN];
-       char host[64], flags[5];
+       char flags[5];
        
        /* So that we don't keep the context list locked for a long time
         * we create a copy of it first
@@ -113,13 +109,9 @@ void cmd_rwho(char *argbuf) {
        aide = ( (CC->user.axlevel >= AxAideU) || (CC->internal_pgm) ) ;
        cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );
        
-       for (i=0; i<nContexts; i++) 
-       {
+       for (i=0; i<nContexts; i++)  {
                flags[0] = '\0';
                spoofed = 0;
-               user_spoofed = 0;
-               room_spoofed = 0;
-               host_spoofed = 0;
                
                if (!aide && nptr[i].state == CON_SYS)
                        continue;
@@ -127,40 +119,15 @@ void cmd_rwho(char *argbuf) {
                if (!aide && nptr[i].kill_me != 0)
                        continue;
 
-               if (nptr[i].cs_flags & CS_POSTING)
-                  strcat(flags, "*");
-               else
-                  strcat(flags, ".");
-                  
-               if (nptr[i].fake_username[0])
-               {
-                  strcpy(un, nptr[i].fake_username);
-                  spoofed = 1;
-                  user_spoofed = 1;
+               if (nptr[i].cs_flags & CS_POSTING) {
+                       strcat(flags, "*");
                }
-               else
-                  strcpy(un, nptr[i].curr_user);
-                  
-               if (nptr[i].fake_hostname[0])
-               {
-                  strcpy(host, nptr[i].fake_hostname);
-                  spoofed = 1;
-                  host_spoofed = 1;
+               else {
+                       strcat(flags, ".");
                }
-               else
-                  strcpy(host, nptr[i].cs_host);
-
+                  
                GenerateRoomDisplay(real_room, &nptr[i], CC);
 
-               if (nptr[i].fake_roomname[0]) {
-                       strcpy(room, nptr[i].fake_roomname);
-                       spoofed = 1;
-                       room_spoofed = 1;
-               }
-               else {
-                       strcpy(room, real_room);
-               }
-               
                 if ((aide) && (spoofed)) {
                        strcat(flags, "+");
                }
@@ -169,41 +136,24 @@ void cmd_rwho(char *argbuf) {
                        strcat(flags, "-");
                }
                
-               if (((nptr[i].cs_flags&CS_STEALTH)==0) || (aide))
-               {
+               if (((nptr[i].cs_flags&CS_STEALTH)==0) || (aide)) {
+
                        cprintf("%d|%s|%s|%s|%s|%ld|%s|%s|",
-                               nptr[i].cs_pid, un, room,
-                               host, nptr[i].cs_clientname,
+                               nptr[i].cs_pid, nptr[i].curr_user, room,
+                               nptr[i].cs_host, nptr[i].cs_clientname,
                                (long)(nptr[i].lastidle),
                                nptr[i].lastcmdname, flags
                        );
 
-                       if ((user_spoofed) && (aide)) {
-                               cprintf("%s|", nptr[i].curr_user);
-                       }
-                       else {
-                               cprintf("|");
-                       }
-       
-                       if ((room_spoofed) && (aide)) {
-                               cprintf("%s|", real_room);
-                       }
-                       else {
-                               cprintf("|");
-                       }
-       
-                       if ((host_spoofed) && (aide)) {
-                               cprintf("%s|", nptr[i].cs_host);
-                       }
-                       else {
-                               cprintf("|");
-                       }
+                       cprintf("|");   // no spoofed user names anymore
+                       cprintf("|");   // no spoofed room names anymore
+                       cprintf("|");   // no spoofed host names anymore
        
                        cprintf("%d\n", nptr[i].logged_in);
                }
        }
        
-       /* release out copy of the context list */
+       /* release our copy of the context list */
        free(nptr);
 
        /* Now it's magic time.  Before we finish, call any EVT_RWHO hooks
@@ -214,139 +164,6 @@ void cmd_rwho(char *argbuf) {
        cprintf("000\n");
 }
 
-#if 0
-/*
- * check for async io jobs that are stuck (didn't ping back for 10 mins)
- */
-void dead_io_check(void) {
-       struct CitContext *nptr;
-       int nContexts, i;
-       char real_room[ROOMNAMELEN];
-       
-       /* So that we don't keep the context list locked for a long time
-        * we create a copy of it first
-        */
-       nptr = CtdlGetContextArray(&nContexts) ;
-       if (!nptr)
-       {
-               /* Couldn't malloc so we have to bail but stick to the protocol */
-               return;
-       }
-
-       time_t now = time(NULL);
-       time_t idle;
-
-       for (i=0; i<nContexts; i++) 
-       {
-               if ((nptr[i].state != CON_SYS) || (nptr[i].IO == NULL) || (nptr[i].lastcmd == 0))
-                       continue;
-
-               if (nptr[i].kill_me != 0)
-                       continue;
-               idle = now - nptr[i].lastcmd;
-               if (idle < 600) 
-                       continue;
-
-               GenerateRoomDisplay(real_room, &nptr[i], CC);
-
-               syslog(LOG_WARNING,
-                      "Found stuck event context: CC[%d] "
-
-                      "Username: '%s' "
-                      "Room: '%s' "
-                      "while talking to host: '%s' "
-                      "Status: '%s' "
-                      "stuck in IO State: '%s' "
-
-                      "idle since: %d:%d "
-                      "Triggering context termination now!",
-
-                      nptr[i].cs_pid,
-
-                      nptr[i].curr_user,
-                      real_room,
-                      nptr[i].cs_host,
-                      nptr[i].cs_clientname,
-                      nptr[i].lastcmdname,
-
-                      (int) idle / 60,
-                      (int) idle % 60);
-
-               CtdlTerminateOtherSession(nptr[i].cs_pid);
-       }
-       
-       /* release out copy of the context list */
-       free(nptr);
-}
-#endif
-
-/*
- * Masquerade roomname
- */
-void cmd_rchg(char *argbuf)
-{
-       char newroomname[ROOMNAMELEN];
-
-       extract_token(newroomname, argbuf, 0, '|', sizeof newroomname);
-       newroomname[ROOMNAMELEN-1] = 0;
-       if (!IsEmptyStr(newroomname)) {
-               safestrncpy(CC->fake_roomname, newroomname,
-                       sizeof(CC->fake_roomname) );
-       }
-       else {
-               safestrncpy(CC->fake_roomname, "", sizeof CC->fake_roomname);
-       }
-       cprintf("%d OK\n", CIT_OK);
-}
-
-/*
- * Masquerade hostname 
- */
-void cmd_hchg(char *argbuf)
-{
-       char newhostname[64];
-
-       extract_token(newhostname, argbuf, 0, '|', sizeof newhostname);
-       if (!IsEmptyStr(newhostname)) {
-               safestrncpy(CC->fake_hostname, newhostname,
-                       sizeof(CC->fake_hostname) );
-       }
-       else {
-               safestrncpy(CC->fake_hostname, "", sizeof CC->fake_hostname);
-       }
-       cprintf("%d OK\n", CIT_OK);
-}
-
-
-/*
- * Masquerade username (aides only)
- */
-void cmd_uchg(char *argbuf)
-{
-
-       char newusername[USERNAME_SIZE];
-
-       extract_token(newusername, argbuf, 0, '|', sizeof newusername);
-
-       if (CtdlAccessCheck(ac_aide)) return;
-
-       if (!IsEmptyStr(newusername)) {
-               CC->cs_flags &= ~CS_STEALTH;
-               memset(CC->fake_username, 0, 32);
-               if (strncasecmp(newusername, CC->curr_user,
-                               strlen(CC->curr_user)))
-                       safestrncpy(CC->fake_username, newusername,
-                               sizeof(CC->fake_username));
-       }
-       else {
-               CC->fake_username[0] = '\0';
-               CC->cs_flags |= CS_STEALTH;
-       }
-       cprintf("%d\n",CIT_OK);
-}
-
-
-
 
 /*
  * enter or exit "stealth mode"
@@ -378,9 +195,6 @@ CTDL_MODULE_INIT(rwho)
        if(!threading)
        {
                CtdlRegisterProtoHook(cmd_rwho, "RWHO", "Display who is online");
-               CtdlRegisterProtoHook(cmd_hchg, "HCHG", "Masquerade hostname");
-               CtdlRegisterProtoHook(cmd_rchg, "RCHG", "Masquerade roomname");
-               CtdlRegisterProtoHook(cmd_uchg, "UCHG", "Masquerade username");
                CtdlRegisterProtoHook(cmd_stel, "STEL", "Enter/exit stealth mode");
                //CtdlRegisterSessionHook(dead_io_check, EVT_TIMER, PRIO_QUEUE + 50);
 
index 397907524e91c04d91a5f8dd4930be81cc4307d7..7f6ed1c15309ba3d8f7bde5efefbc77132968480 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * Server functions which perform operations on user objects.
  *
- * Copyright (c) 1987-2018 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.
@@ -700,9 +700,6 @@ void CtdlUserLogout(void)
         * since it's possible to log in again without reconnecting, we cannot
         * make that assumption.
         */
-       strcpy(CCC->fake_username, "");
-       strcpy(CCC->fake_hostname, "");
-       strcpy(CCC->fake_roomname, "");
        CCC->logged_in = 0;
 
        /* Check to see if the user was deleted while logged in and purge them if necessary */
@@ -716,9 +713,6 @@ void CtdlUserLogout(void)
        CCC->cs_inet_email[0] = 0;
        CCC->cs_inet_other_emails[0] = 0;
        CCC->cs_inet_fn[0] = 0;
-       CCC->fake_username[0] = 0;
-       CCC->fake_hostname[0] = 0;
-       CCC->fake_roomname[0] = 0;
 
        /* Free any output buffers */
        unbuffer_output();