]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_rwho.c
fix all the <time.h> vs. <sys/time.h> issues, hopefully
[citadel.git] / citadel / serv_rwho.c
index 7519c3175ebe66e625e8d2ad9200f13499f33bb7..582e1fd5b25c57affae687bac550a7fae02f469d 100644 (file)
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include <time.h>
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
@@ -43,6 +53,9 @@
 void cmd_rwho(char *argbuf) {
        struct CitContext *cptr;
        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];
@@ -55,6 +68,9 @@ void cmd_rwho(char *argbuf) {
        {
                flags[0] = '\0';
                spoofed = 0;
+               user_spoofed = 0;
+               room_spoofed = 0;
+               host_spoofed = 0;
                
                if (cptr->cs_flags & CS_POSTING)
                   strcat(flags, "*");
@@ -65,6 +81,7 @@ void cmd_rwho(char *argbuf) {
                {
                   strcpy(un, cptr->fake_username);
                   spoofed = 1;
+                  user_spoofed = 1;
                }
                else
                   strcpy(un, cptr->curr_user);
@@ -73,6 +90,7 @@ void cmd_rwho(char *argbuf) {
                {
                   strcpy(host, cptr->fake_hostname);
                   spoofed = 1;
+                  host_spoofed = 1;
                }
                else
                   strcpy(host, cptr->cs_host);
@@ -82,34 +100,50 @@ void cmd_rwho(char *argbuf) {
                if (cptr->fake_roomname[0]) {
                        strcpy(room, cptr->fake_roomname);
                        spoofed = 1;
+                       room_spoofed = 1;
                }
                else {
                        strcpy(room, real_room);
                }
                
-                if ((aide) && (spoofed))
-                   strcat(flags, "+");
+                if ((aide) && (spoofed)) {
+                       strcat(flags, "+");
+               }
                
-               if ((cptr->cs_flags & CS_STEALTH) && (aide))
-                  strcat(flags, "-");
+               if ((cptr->cs_flags & CS_STEALTH) && (aide)) {
+                       strcat(flags, "-");
+               }
                
                if (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
                {
-                       cprintf("%d|%s|%s|%s|%s|%ld|%s|%s\n",
+                       cprintf("%d|%s|%s|%s|%s|%ld|%s|%s|",
                                cptr->cs_pid, un, room,
                                host, cptr->cs_clientname,
                                (long)(cptr->lastidle),
                                cptr->lastcmdname, flags);
-               }
-               if ((spoofed) && (aide))
-               {
-                       cprintf("%d|%s|%s|%s|%s|%ld|%s|%s\n",
-                               cptr->cs_pid, cptr->curr_user,
-                               real_room,
-                               cptr->cs_host, cptr->cs_clientname,
-                               (long)(cptr->lastidle),
-                               cptr->lastcmdname, flags);
-               
+
+                       if ((user_spoofed) && (aide)) {
+                               cprintf("%s|", cptr->curr_user);
+                       }
+                       else {
+                               cprintf("|");
+                       }
+       
+                       if ((room_spoofed) && (aide)) {
+                               cprintf("%s|", real_room);
+                       }
+                       else {
+                               cprintf("|");
+                       }
+       
+                       if ((host_spoofed) && (aide)) {
+                               cprintf("%s|", cptr->cs_host);
+                       }
+                       else {
+                               cprintf("|");
+                       }
+       
+                       cprintf("\n");
                }
        }
 
@@ -127,7 +161,7 @@ void cmd_rwho(char *argbuf) {
  */
 void cmd_rchg(char *argbuf)
 {
-       char newroomname[256];
+       char newroomname[SIZ];
 
        extract(newroomname, argbuf, 0);
        newroomname[ROOMNAMELEN-1] = 0;
@@ -146,7 +180,7 @@ void cmd_rchg(char *argbuf)
  */
 void cmd_hchg(char *argbuf)
 {
-       char newhostname[256];
+       char newhostname[SIZ];
 
        extract(newhostname, argbuf, 0);
        if (strlen(newhostname) > 0) {
@@ -166,15 +200,11 @@ void cmd_hchg(char *argbuf)
 void cmd_uchg(char *argbuf)
 {
 
-       char newusername[256];
+       char newusername[SIZ];
 
        extract(newusername, argbuf, 0);
 
-       if (CC->usersupp.axlevel < 6) {
-               cprintf("%d You must be an Aide to masquerade your name.\n",
-                       ERROR+HIGHER_ACCESS_REQUIRED);
-               return;
-       }
+       if (CtdlAccessCheck(ac_aide)) return;
 
        if (strlen(newusername) > 0) {
                CC->cs_flags &= ~CS_STEALTH;
@@ -204,16 +234,7 @@ void cmd_stel(char *cmdbuf)
        requested_mode = extract_int(cmdbuf,0);
        if (requested_mode !=0) requested_mode = 1;
 
-       if (!CC->logged_in) {
-               cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
-               return;
-               }
-
-       if (CC->usersupp.axlevel < 6) {
-               cprintf("%d You must be an Aide to use stealth mode.\n",
-                       ERROR+HIGHER_ACCESS_REQUIRED);
-               return;
-               }
+       if (CtdlAccessCheck(ac_aide)) return;
 
        if (CC->cs_flags & CS_STEALTH) {
                if (requested_mode == 0)