4 * Main source module for the Citadel server
14 #include <sys/types.h>
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #include <libcitadel.h>
46 #include "sysdep_decls.h"
47 #include "citserver.h"
50 #include "housekeeping.h"
54 #include "locate_host.h"
59 #include "euidindex.h"
65 #include "ctdl_module.h"
68 struct CitContext *ContextList = NULL;
69 struct CitContext* next_session = NULL;
70 char *unique_session_numbers;
71 int ScheduledShutdown = 0;
73 time_t server_startup_time;
77 * \brief print the actual stack frame.
79 void cit_backtrace(void)
82 void *stack_frames[50];
87 size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
88 strings = backtrace_symbols(stack_frames, size);
89 for (i = 0; i < size; i++) {
91 lprintf(1, "%s\n", strings[i]);
93 lprintf(1, "%p\n", stack_frames[i]);
100 * \brief print the actual stack frame.
102 void cit_panic_backtrace(int SigNum)
104 #ifdef HAVE_BACKTRACE
105 void *stack_frames[10];
109 printf("caught signal 11\n");
110 size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
111 strings = backtrace_symbols(stack_frames, size);
112 for (i = 0; i < size; i++) {
114 lprintf(1, "%s\n", strings[i]);
116 lprintf(1, "%p\n", stack_frames[i]);
124 * Various things that need to be initialized at startup
126 void master_startup(void) {
130 struct ctdlroom qrbuf;
132 lprintf(CTDL_DEBUG, "master_startup() started\n");
133 time(&server_startup_time);
135 lprintf(CTDL_INFO, "Opening databases\n");
138 ctdl_thread_internal_init_tsd();
140 CtdlThreadAllocTSD();
148 lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
149 create_room(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
150 create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
151 create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
152 create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
154 /* The "Local System Configuration" room doesn't need to be visible */
155 if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
156 qrbuf.QRflags2 |= QR2_SYSTEM;
160 lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
161 urandom = fopen("/dev/urandom", "r");
162 if (urandom != NULL) {
163 fread(&seed, sizeof seed, 1, urandom);
167 gettimeofday(&tv, NULL);
172 lprintf(CTDL_INFO, "Initializing ipgm secret\n");
174 config.c_ipgm_secret = rand();
177 lprintf(CTDL_DEBUG, "master_startup() finished\n");
182 * Cleanup routine to be called when the server is shutting down.
184 void master_cleanup(int exitcode) {
185 struct CleanupFunctionHook *fcn;
186 static int already_cleaning_up = 0;
188 if (already_cleaning_up) while(1) sleep(1);
189 already_cleaning_up = 1;
191 /* Run any cleanup routines registered by loadable modules */
192 for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
193 (*fcn->h_function_pointer)();
196 /* Close the AdjRefCount queue file */
199 /* Close databases */
200 lprintf(CTDL_INFO, "Closing databases\n");
203 /* Do system-dependent stuff */
204 sysdep_master_cleanup();
206 #ifdef DEBUG_MEMORY_LEAKS
210 /* If the operator requested a halt but not an exit, halt here. */
211 if (shutdown_and_halt) {
212 lprintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
213 fflush(stdout); fflush(stderr);
222 lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
223 fflush(stdout); fflush(stderr);
225 if (restart_server != 0)
233 * Terminate a session.
235 void RemoveContext (struct CitContext *con)
239 "WARNING: RemoveContext() called with NULL!\n");
242 lprintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
244 /* Run any cleanup routines registered by loadable modules.
245 * Note: We have to "become_session()" because the cleanup functions
246 * might make references to "CC" assuming it's the right one.
249 PerformSessionHooks(EVT_STOP);
250 become_session(NULL);
252 /* Now handle all of the administrivia. */
253 lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
256 lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
258 /* If the client is still connected, blow 'em away. */
259 lprintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
260 close(con->client_socket);
262 lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
270 * cmd_info() - tell the client about this server
272 void cmd_info(void) {
273 cprintf("%d Server info:\n", LISTING_FOLLOWS);
274 cprintf("%d\n", CC->cs_pid);
275 cprintf("%s\n", config.c_nodename);
276 cprintf("%s\n", config.c_humannode);
277 cprintf("%s\n", config.c_fqdn);
278 cprintf("%s\n", CITADEL);
279 cprintf("%d\n", REV_LEVEL);
280 cprintf("%s\n", config.c_site_location);
281 cprintf("%s\n", config.c_sysadm);
282 cprintf("%d\n", SERVER_TYPE);
283 cprintf("%s\n", config.c_moreprompt);
284 cprintf("1\n"); /* 1 = yes, this system supports floors */
285 cprintf("1\n"); /* 1 = we support the extended paging options */
286 cprintf("%s\n", CC->cs_nonce);
287 cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */
290 cprintf("1\n"); /* 1 = yes, this server is LDAP-enabled */
292 cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */
295 if (config.c_auth_mode == 1) {
296 cprintf("1\n"); /* "create new user" never works with host auth */
299 cprintf("%d\n", config.c_disable_newu); /* otherwise, site defined */
302 cprintf("%s\n", config.c_default_cal_zone);
303 /* Output load averages */
304 cprintf("%f\n", CtdlThreadLoadAvg);
305 cprintf("%f\n", CtdlThreadWorkerAvg);
306 cprintf("%d\n", CtdlThreadGetCount());
313 * returns an asterisk if there are any instant messages waiting,
316 char CtdlCheckExpress(void) {
317 if (CC->FirstExpressMessage == NULL) {
331 localtime_r(&tv, &tmp);
333 /* timezone and daylight global variables are not portable. */
334 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
335 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
337 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
343 * Check originating host against the public_clients file. This determines
344 * whether the client is allowed to change the hostname for this session
345 * (for example, to show the location of the user rather than the location
348 int is_public_client(void)
355 static time_t pc_timestamp = 0;
356 static char public_clients[SIZ];
357 static char public_clients_file[SIZ];
359 snprintf(public_clients_file,
360 sizeof public_clients_file,
365 * Check the time stamp on the public_clients file. If it's been
366 * updated since the last time we were here (or if this is the first
367 * time we've been through the loop), read its contents and learn
368 * the IP addresses of the listed hosts.
370 if (stat(public_clients_file, &statbuf) != 0) {
371 /* No public_clients file exists, so bail out */
372 lprintf(CTDL_WARNING, "Warning: '%s' does not exist\n",
373 public_clients_file);
377 if (statbuf.st_mtime > pc_timestamp) {
378 begin_critical_section(S_PUBLIC_CLIENTS);
379 lprintf(CTDL_INFO, "Loading %s\n", public_clients_file);
381 safestrncpy(public_clients, "127.0.0.1", sizeof public_clients);
382 if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
383 strcat(public_clients, "|");
384 strcat(public_clients, addrbuf);
387 fp = fopen(public_clients_file, "r");
388 if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
391 while (!IsEmptyStr(ptr)) {
399 while (ptr>buf && isspace(*ptr)) {
402 if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
403 if ((strlen(public_clients) +
405 < sizeof(public_clients)) {
406 strcat(public_clients, "|");
407 strcat(public_clients, addrbuf);
412 pc_timestamp = time(NULL);
413 end_critical_section(S_PUBLIC_CLIENTS);
416 lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
418 for (i=0; i<num_parms(public_clients); ++i) {
419 extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
420 if (!strcasecmp(CC->cs_addr, addrbuf)) {
421 lprintf(CTDL_DEBUG, "... yes it is.\n");
426 /* No hits. This is not a public client. */
427 lprintf(CTDL_DEBUG, "... no it isn't.\n");
433 * the client is identifying itself to the server
435 void cmd_iden(char *argbuf)
445 if (num_parms(argbuf)<4) {
446 cprintf("%d usage error\n", ERROR + ILLEGAL_VALUE);
450 dev_code = extract_int(argbuf,0);
451 cli_code = extract_int(argbuf,1);
452 rev_level = extract_int(argbuf,2);
453 extract_token(desc, argbuf, 3, '|', sizeof desc);
455 safestrncpy(from_host, config.c_fqdn, sizeof from_host);
456 from_host[sizeof from_host - 1] = 0;
457 if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host);
459 CC->cs_clientdev = dev_code;
460 CC->cs_clienttyp = cli_code;
461 CC->cs_clientver = rev_level;
462 safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
463 CC->cs_clientname[31] = 0;
465 if (!IsEmptyStr(from_host)) {
466 if (CC->is_local_socket) do_lookup = 1;
467 else if (is_public_client()) do_lookup = 1;
471 lprintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
472 if ((addr.s_addr = inet_addr(from_host)) != -1) {
473 locate_host(CC->cs_host, sizeof CC->cs_host,
474 CC->cs_addr, sizeof CC->cs_addr,
478 safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
479 CC->cs_host[sizeof CC->cs_host - 1] = 0;
483 lprintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
490 cprintf("%d Ok\n",CIT_OK);
495 * display system messages or help
497 void cmd_mesg(char *mname)
507 extract_token(buf, mname, 0, '|', sizeof buf);
509 dirs[0] = strdup(ctdl_message_dir);
510 dirs[1] = strdup(ctdl_hlp_dir);
512 snprintf(buf2, sizeof buf2, "%s.%d.%d",
513 buf, CC->cs_clientdev, CC->cs_clienttyp);
515 /* If the client requested "?" then produce a listing */
516 if (!strcmp(buf, "?")) {
517 cprintf("%d %s\n", LISTING_FOLLOWS, buf);
518 dp = opendir(dirs[1]);
520 while (d = readdir(dp), d != NULL) {
521 if (d->d_name[0] != '.') {
522 cprintf(" %s\n", d->d_name);
533 /* Otherwise, look for the requested file by name. */
535 mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
536 if (IsEmptyStr(targ)) {
537 snprintf(buf2, sizeof buf2, "%s.%d",
538 buf, CC->cs_clientdev);
539 mesg_locate(targ, sizeof targ, buf2, 2,
540 (const char **)dirs);
541 if (IsEmptyStr(targ)) {
542 mesg_locate(targ, sizeof targ, buf, 2,
543 (const char **)dirs);
551 if (IsEmptyStr(targ)) {
552 cprintf("%d '%s' not found. (Searching in %s and %s)\n",
553 ERROR + FILE_NOT_FOUND,
561 mfp = fopen(targ, "r");
563 cprintf("%d Cannot open '%s': %s\n",
564 ERROR + INTERNAL_ERROR, targ, strerror(errno));
567 cprintf("%d %s\n", LISTING_FOLLOWS,buf);
569 while (fgets(buf, (sizeof buf - 1), mfp) != NULL) {
570 buf[strlen(buf)-1] = 0;
581 * enter system messages or help
583 void cmd_emsg(char *mname)
593 if (CtdlAccessCheck(ac_aide)) return;
595 extract_token(buf, mname, 0, '|', sizeof buf);
596 for (a=0; !IsEmptyStr(&buf[a]); ++a) { /* security measure */
597 if (buf[a] == '/') buf[a] = '.';
600 dirs[0] = strdup(ctdl_message_dir);
601 dirs[1] = strdup(ctdl_hlp_dir);
603 mesg_locate(targ, sizeof targ, buf, 2, (const char**)dirs);
607 if (IsEmptyStr(targ)) {
608 snprintf(targ, sizeof targ,
613 mfp = fopen(targ,"w");
615 cprintf("%d Cannot open '%s': %s\n",
616 ERROR + INTERNAL_ERROR, targ, strerror(errno));
619 cprintf("%d %s\n", SEND_LISTING, targ);
621 while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
622 fprintf(mfp, "%s\n", buf);
629 /* Don't show the names of private rooms unless the viewing
630 * user also knows the rooms.
632 void GenerateRoomDisplay(char *real_room,
633 struct CitContext *viewed,
634 struct CitContext *viewer) {
638 strcpy(real_room, viewed->room.QRname);
639 if (viewed->room.QRflags & QR_MAILBOX) {
640 strcpy(real_room, &real_room[11]);
642 if (viewed->room.QRflags & QR_PRIVATE) {
643 CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
644 if ( (ra & UA_KNOWN) == 0) {
645 strcpy(real_room, "<private room>");
649 if (viewed->cs_flags & CS_CHAT) {
650 while (strlen(real_room) < 14)
651 strcat(real_room, " ");
653 strcpy(&real_room[14], "<chat>");
659 * Convenience function.
661 int CtdlAccessCheck(int required_level) {
663 if (CC->internal_pgm) return(0);
664 if (required_level >= ac_internal) {
665 cprintf("%d This is not a user-level command.\n",
666 ERROR + HIGHER_ACCESS_REQUIRED);
670 if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
671 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
675 if (CC->user.axlevel >= 6) return(0);
676 if (required_level >= ac_aide) {
677 cprintf("%d This command requires Aide access.\n",
678 ERROR + HIGHER_ACCESS_REQUIRED);
682 if (is_room_aide()) return(0);
683 if (required_level >= ac_room_aide) {
684 cprintf("%d This command requires Aide or Room Aide access.\n",
685 ERROR + HIGHER_ACCESS_REQUIRED);
689 /* shhh ... succeed quietly */
696 * Terminate another running session
698 void cmd_term(char *cmdbuf)
701 struct CitContext *ccptr;
705 session_num = extract_int(cmdbuf, 0);
706 if (session_num == CC->cs_pid) {
707 cprintf("%d You can't kill your own session.\n", ERROR + ILLEGAL_VALUE);
711 lprintf(CTDL_DEBUG, "Locating session to kill\n");
712 begin_critical_section(S_SESSION_TABLE);
713 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
714 if (session_num == ccptr->cs_pid) {
716 if ((ccptr->user.usernum == CC->user.usernum)
717 || (CC->user.axlevel >= 6)) {
726 end_critical_section(S_SESSION_TABLE);
730 cprintf("%d Session terminated.\n", CIT_OK);
733 cprintf("%d You are not allowed to do that.\n",
734 ERROR + HIGHER_ACCESS_REQUIRED);
738 cprintf("%d No such session.\n", ERROR + ILLEGAL_VALUE);
747 * get the paginator prompt
749 void cmd_more(void) {
750 cprintf("%d %s\n", CIT_OK, config.c_moreprompt);
756 void cmd_echo(char *etext)
758 cprintf("%d %s\n", CIT_OK, etext);
764 * identify as internal program
766 void cmd_ipgm(char *argbuf)
770 secret = extract_int(argbuf, 0);
772 /* For security reasons, we do NOT allow this command to run
773 * over the network. Local sockets only.
775 if (!CC->is_local_socket) {
777 cprintf("%d Authentication failed.\n",
778 ERROR + PASSWORD_REQUIRED);
780 else if (secret == config.c_ipgm_secret) {
781 CC->internal_pgm = 1;
782 strcpy(CC->curr_user, "<internal program>");
783 CC->cs_flags = CC->cs_flags|CS_STEALTH;
784 cprintf("%d Authenticated as an internal program.\n", CIT_OK);
788 cprintf("%d Authentication failed.\n",
789 ERROR + PASSWORD_REQUIRED);
790 lprintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
794 /* Now change the ipgm secret for the next round.
795 * (Disabled because it breaks concurrent scripts. The fact that
796 * we no longer accept IPGM over the network should be sufficient
797 * to prevent brute-force attacks. If you don't agree, uncomment
800 config.c_ipgm_secret = rand();
807 * Shut down the server
809 void cmd_down(char *argbuf) {
810 char *Reply ="%d Shutting down server. Goodbye.\n";
812 if (CtdlAccessCheck(ac_aide)) return;
814 if (!IsEmptyStr(argbuf))
817 restart_server = extract_int(argbuf, 0);
819 if (restart_server > 0)
820 Reply = "%d Restarting server. See you soon.\n";
821 if ((restart_server > 0) && !running_as_daemon)
823 lprintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
824 Reply = "%d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
827 cprintf(Reply, state);
831 cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN);
837 * Halt the server without exiting the server process.
839 void cmd_halt(void) {
841 if (CtdlAccessCheck(ac_aide)) return;
843 cprintf("%d Halting server. Goodbye.\n", CIT_OK);
845 shutdown_and_halt = 1;
849 * Schedule or cancel a server shutdown
851 void cmd_scdn(char *argbuf)
855 char *Reply = "%d %d\n";
857 if (CtdlAccessCheck(ac_aide)) return;
859 new_state = extract_int(argbuf, 0);
860 if ((new_state == 2) || (new_state == 3))
863 if (!running_as_daemon)
865 lprintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
866 Reply = "%d %d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
870 restart_server = extract_int(argbuf, 0);
873 if ((new_state == 0) || (new_state == 1)) {
874 ScheduledShutdown = new_state;
876 cprintf(Reply, state, ScheduledShutdown);
881 * Set or unset asynchronous protocol mode
883 void cmd_asyn(char *argbuf)
887 new_state = extract_int(argbuf, 0);
888 if ((new_state == 0) || (new_state == 1)) {
889 CC->is_async = new_state;
891 cprintf("%d %d\n", CIT_OK, CC->is_async);
896 * Generate a "nonce" for APOP-style authentication.
898 * RFC 1725 et al specify a PID to be placed in front of the nonce.
899 * Quoth BTX: That would be stupid.
901 void generate_nonce(struct CitContext *con) {
904 memset(con->cs_nonce, NONCE_SIZE, 0);
905 gettimeofday(&tv, NULL);
906 memset(con->cs_nonce, NONCE_SIZE, 0);
907 snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
908 rand(), (long)tv.tv_usec, config.c_fqdn);
915 * Back-end function for starting a session
917 void begin_session(struct CitContext *con)
920 struct sockaddr_in sin;
923 * Initialize some variables specific to our context.
926 con->internal_pgm = 0;
927 con->download_fp = NULL;
928 con->upload_fp = NULL;
929 con->FirstExpressMessage = NULL;
931 time(&con->lastidle);
932 strcpy(con->lastcmdname, " ");
933 strcpy(con->cs_clientname, "(unknown)");
934 strcpy(con->curr_user, NLI);
935 *con->net_node = '\0';
936 *con->fake_username = '\0';
937 *con->fake_hostname = '\0';
938 *con->fake_roomname = '\0';
940 safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
941 safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
942 con->cs_host[sizeof con->cs_host - 1] = 0;
944 if (!CC->is_local_socket) {
945 if (!getpeername(con->client_socket, (struct sockaddr *) &sin, &len)) {
946 locate_host(con->cs_host, sizeof con->cs_host,
947 con->cs_addr, sizeof con->cs_addr,
953 strcpy(con->cs_host, "");
956 con->upload_type = UPL_FILE;
960 if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) {
964 lprintf(CTDL_NOTICE, "Session started.\n");
966 /* Run any session startup routines registered by loadable modules */
967 PerformSessionHooks(EVT_START);
971 void citproto_begin_session() {
972 if (CC->nologin==1) {
973 cprintf("%d %s: Too many users are already online (maximum is %d)\n",
974 ERROR + MAX_SESSIONS_EXCEEDED,
975 config.c_nodename, config.c_maxsessions
980 cprintf("%d %s Citadel server ready.\n",
981 CIT_OK, config.c_nodename);
989 * This loop recognizes all server commands.
991 void do_command_loop(void) {
995 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
996 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
997 lprintf(CTDL_ERR, "Client disconnected: ending session.\n");
1002 /* Log the server command, but don't show passwords... */
1003 if ( (strncasecmp(cmdbuf, "PASS", 4))
1004 && (strncasecmp(cmdbuf, "SETP", 4)) ) {
1005 lprintf(CTDL_INFO, "%s\n", cmdbuf);
1008 lprintf(CTDL_INFO, "<password command sent>\n");
1014 * Let other clients see the last command we executed, and
1015 * update the idle time, but not NOOP, QNOP, PEXP, GEXP, RWHO, or TIME.
1017 if ( (strncasecmp(cmdbuf, "NOOP", 4))
1018 && (strncasecmp(cmdbuf, "QNOP", 4))
1019 && (strncasecmp(cmdbuf, "PEXP", 4))
1020 && (strncasecmp(cmdbuf, "GEXP", 4))
1021 && (strncasecmp(cmdbuf, "RWHO", 4))
1022 && (strncasecmp(cmdbuf, "TIME", 4)) ) {
1023 strcpy(CC->lastcmdname, " ");
1024 safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname));
1025 time(&CC->lastidle);
1028 if ((strncasecmp(cmdbuf, "ENT0", 4))
1029 && (strncasecmp(cmdbuf, "MESG", 4))
1030 && (strncasecmp(cmdbuf, "MSGS", 4)))
1032 CC->cs_flags &= ~CS_POSTING;
1035 if (!strncasecmp(cmdbuf, "NOOP", 4)) {
1036 cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
1039 else if (!strncasecmp(cmdbuf, "QNOP", 4)) {
1040 /* do nothing, this command returns no response */
1043 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
1044 cprintf("%d Goodbye.\n", CIT_OK);
1048 else if (!strncasecmp(cmdbuf,"ASYN",4)) {
1049 cmd_asyn(&cmdbuf[5]);
1052 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
1053 if (CC->logged_in) logout(CC);
1054 cprintf("%d logged out.\n", CIT_OK);
1057 else if (!strncasecmp(cmdbuf,"USER",4)) {
1058 cmd_user(&cmdbuf[5]);
1061 else if (!strncasecmp(cmdbuf,"PASS",4)) {
1062 cmd_pass(&cmdbuf[5]);
1065 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
1066 cmd_newu(&cmdbuf[5]);
1069 else if (!strncasecmp(cmdbuf,"CREU",4)) {
1070 cmd_creu(&cmdbuf[5]);
1073 else if (!strncasecmp(cmdbuf,"SETP",4)) {
1074 cmd_setp(&cmdbuf[5]);
1077 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
1078 cmd_lrms(&cmdbuf[5]);
1081 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
1082 cmd_lkra(&cmdbuf[5]);
1085 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
1086 cmd_lkrn(&cmdbuf[5]);
1089 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
1090 cmd_lkro(&cmdbuf[5]);
1093 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
1094 cmd_lzrm(&cmdbuf[5]);
1097 else if (!strncasecmp(cmdbuf,"LPRM",4)) {
1098 cmd_lprm(&cmdbuf[5]);
1101 else if (!strncasecmp(cmdbuf,"GETU",4)) {
1105 else if (!strncasecmp(cmdbuf,"SETU",4)) {
1106 cmd_setu(&cmdbuf[5]);
1109 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
1110 cmd_goto(&cmdbuf[5]);
1113 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
1114 cmd_msgs(&cmdbuf[5]);
1117 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
1121 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
1125 else if (!strncasecmp(cmdbuf,"EUID",4)) {
1126 cmd_euid(&cmdbuf[5]);
1129 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
1130 cmd_msg0(&cmdbuf[5]);
1133 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
1134 cmd_msg2(&cmdbuf[5]);
1137 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
1138 cmd_msg3(&cmdbuf[5]);
1141 else if (!strncasecmp(cmdbuf,"MSG4",4)) {
1142 cmd_msg4(&cmdbuf[5]);
1145 else if (!strncasecmp(cmdbuf,"MSGP",4)) {
1146 cmd_msgp(&cmdbuf[5]);
1149 else if (!strncasecmp(cmdbuf,"OPNA",4)) {
1150 cmd_opna(&cmdbuf[5]);
1153 else if (!strncasecmp(cmdbuf,"DLAT",4)) {
1154 cmd_dlat(&cmdbuf[5]);
1157 else if (!strncasecmp(cmdbuf,"INFO",4)) {
1161 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
1162 cmd_slrp(&cmdbuf[5]);
1165 else if (!strncasecmp(cmdbuf,"INVT",4)) {
1166 cmd_invt_kick(&cmdbuf[5],1);
1169 else if (!strncasecmp(cmdbuf,"KICK",4)) {
1170 cmd_invt_kick(&cmdbuf[5],0);
1173 else if (!strncasecmp(cmdbuf,"GETR",4)) {
1177 else if (!strncasecmp(cmdbuf,"SETR",4)) {
1178 cmd_setr(&cmdbuf[5]);
1181 else if (!strncasecmp(cmdbuf,"GETA",4)) {
1185 else if (!strncasecmp(cmdbuf,"SETA",4)) {
1186 cmd_seta(&cmdbuf[5]);
1189 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
1190 cmd_ent0(&cmdbuf[5]);
1193 else if (!strncasecmp(cmdbuf,"RINF",4)) {
1197 else if (!strncasecmp(cmdbuf,"DELE",4)) {
1198 cmd_dele(&cmdbuf[5]);
1201 else if (!strncasecmp(cmdbuf,"KILL",4)) {
1202 cmd_kill(&cmdbuf[5]);
1205 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
1206 cmd_cre8(&cmdbuf[5]);
1209 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
1210 cmd_move(&cmdbuf[5]);
1213 else if (!strncasecmp(cmdbuf,"FORG",4)) {
1217 else if (!strncasecmp(cmdbuf,"MESG",4)) {
1218 cmd_mesg(&cmdbuf[5]);
1221 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
1222 cmd_emsg(&cmdbuf[5]);
1225 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
1229 else if (!strncasecmp(cmdbuf,"VALI",4)) {
1230 cmd_vali(&cmdbuf[5]);
1233 else if (!strncasecmp(cmdbuf,"EINF",4)) {
1234 cmd_einf(&cmdbuf[5]);
1237 else if (!strncasecmp(cmdbuf,"LIST",4)) {
1238 cmd_list(&cmdbuf[5]);
1241 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
1245 else if (!strncasecmp(cmdbuf,"DELF",4)) {
1246 cmd_delf(&cmdbuf[5]);
1249 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
1250 cmd_movf(&cmdbuf[5]);
1253 else if (!strncasecmp(cmdbuf,"NETF",4)) {
1254 cmd_netf(&cmdbuf[5]);
1257 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
1258 cmd_open(&cmdbuf[5]);
1261 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
1265 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
1266 cmd_uopn(&cmdbuf[5]);
1269 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
1270 cmd_ucls(&cmdbuf[5]);
1273 else if (!strncasecmp(cmdbuf,"READ",4)) {
1274 cmd_read(&cmdbuf[5]);
1277 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
1278 cmd_writ(&cmdbuf[5]);
1281 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
1282 cmd_qusr(&cmdbuf[5]);
1285 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
1286 cmd_echo(&cmdbuf[5]);
1289 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
1290 cmd_oimg(&cmdbuf[5]);
1293 else if (!strncasecmp(cmdbuf,"MORE",4)) {
1297 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
1298 cmd_ndop(&cmdbuf[5]);
1301 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
1302 cmd_nuop(&cmdbuf[5]);
1305 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
1309 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
1310 cmd_cflr(&cmdbuf[5]);
1313 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
1314 cmd_kflr(&cmdbuf[5]);
1317 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
1318 cmd_eflr(&cmdbuf[5]);
1321 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
1322 cmd_iden(&cmdbuf[5]);
1325 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1326 cmd_ipgm(&cmdbuf[5]);
1329 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1330 cmd_term(&cmdbuf[5]);
1333 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1334 cmd_down(&cmdbuf[5]);
1337 else if (!strncasecmp(cmdbuf,"HALT",4)) {
1341 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1342 cmd_scdn(&cmdbuf[5]);
1345 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1346 cmd_uimg(&cmdbuf[5]);
1349 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1353 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1354 cmd_agup(&cmdbuf[5]);
1357 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1358 cmd_asup(&cmdbuf[5]);
1361 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1362 cmd_gpex(&cmdbuf[5]);
1365 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1366 cmd_spex(&cmdbuf[5]);
1369 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1370 cmd_conf(&cmdbuf[5]);
1373 else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
1374 cmd_seen(&cmdbuf[5]);
1377 else if (!strncasecmp(cmdbuf, "GTSN", 4)) {
1378 cmd_gtsn(&cmdbuf[5]);
1381 else if (!strncasecmp(cmdbuf, "VIEW", 4)) {
1382 cmd_view(&cmdbuf[5]);
1385 else if (!strncasecmp(cmdbuf, "ISME", 4)) {
1386 cmd_isme(&cmdbuf[5]);
1389 else if (!DLoader_Exec_Cmd(cmdbuf)) {
1390 cprintf("%d Unrecognized or unsupported command.\n",
1391 ERROR + CMD_NOT_SUPPORTED);
1396 /* Run any after-each-command routines registered by modules */
1397 PerformSessionHooks(EVT_CMD);
1402 * This loop performs all asynchronous functions.
1404 void do_async_loop(void) {
1405 PerformSessionHooks(EVT_ASYNC);