]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_rwho.c
* Replaced most of the very repetitive and very redundant access level checks
[citadel.git] / citadel / serv_rwho.c
index a836e8d19f5b2518671673d576db78442c3de08e..3c7979e0799001fbb45f70e4760177b125280852 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * $Id$
  *
- * This module implements the RWHO (Read WHO's online) server command.
+ * This module implementsserver commands related to the display and
+ * manipulation of the "Who's online" list.
  *
  */
 
@@ -36,9 +37,8 @@
 
 
 
-
 /*
- * who's online
+ * display who's online
  */
 void cmd_rwho(char *argbuf) {
        struct CitContext *cptr;
@@ -122,9 +122,110 @@ void cmd_rwho(char *argbuf) {
        }
 
 
+/*
+ * Masquerade roomname
+ */
+void cmd_rchg(char *argbuf)
+{
+       char newroomname[256];
+
+       extract(newroomname, argbuf, 0);
+       newroomname[ROOMNAMELEN-1] = 0;
+       if (strlen(newroomname) > 0) {
+               safestrncpy(CC->fake_roomname, newroomname,
+                       sizeof(CC->fake_roomname) );
+               }
+       else {
+               strcpy(CC->fake_roomname, "");
+               }
+       cprintf("%d OK\n", OK);
+}
+
+/*
+ * Masquerade hostname 
+ */
+void cmd_hchg(char *argbuf)
+{
+       char newhostname[256];
+
+       extract(newhostname, argbuf, 0);
+       if (strlen(newhostname) > 0) {
+               safestrncpy(CC->fake_hostname, newhostname,
+                       sizeof(CC->fake_hostname) );
+               }
+       else {
+               strcpy(CC->fake_hostname, "");
+               }
+       cprintf("%d OK\n", OK);
+}
+
+
+/*
+ * Masquerade username (aides only)
+ */
+void cmd_uchg(char *argbuf)
+{
+
+       char newusername[256];
+
+       extract(newusername, argbuf, 0);
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       if (strlen(newusername) > 0) {
+               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",OK);
+}
+
+
+
+
+/*
+ * enter or exit "stealth mode"
+ */
+void cmd_stel(char *cmdbuf)
+{
+       int requested_mode;
+
+       requested_mode = extract_int(cmdbuf,0);
+       if (requested_mode !=0) requested_mode = 1;
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       if (CC->cs_flags & CS_STEALTH) {
+               if (requested_mode == 0)
+                       CC->cs_flags = CC->cs_flags-CS_STEALTH;
+               }
+       else {
+               if (requested_mode == 1)
+                       CC->cs_flags = CC->cs_flags|CS_STEALTH;
+               }
+
+       cprintf("%d Ok\n",OK);
+       }
+
+
+
+
+
+
 
 char *Dynamic_Module_Init(void)
 {
         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");
         return "$Id$";
 }