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) {
993 char *old_name = NULL;
995 old_name = CtdlThreadName("do_command_loop");
998 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
999 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
1000 lprintf(CTDL_ERR, "Client disconnected: ending session.\n");
1002 CtdlThreadName(old_name);
1006 /* Log the server command, but don't show passwords... */
1007 if ( (strncasecmp(cmdbuf, "PASS", 4))
1008 && (strncasecmp(cmdbuf, "SETP", 4)) ) {
1009 lprintf(CTDL_INFO, "%s\n", cmdbuf);
1012 lprintf(CTDL_INFO, "<password command sent>\n");
1018 * Let other clients see the last command we executed, and
1019 * update the idle time, but not NOOP, QNOP, PEXP, GEXP, RWHO, or TIME.
1021 if ( (strncasecmp(cmdbuf, "NOOP", 4))
1022 && (strncasecmp(cmdbuf, "QNOP", 4))
1023 && (strncasecmp(cmdbuf, "PEXP", 4))
1024 && (strncasecmp(cmdbuf, "GEXP", 4))
1025 && (strncasecmp(cmdbuf, "RWHO", 4))
1026 && (strncasecmp(cmdbuf, "TIME", 4)) ) {
1027 strcpy(CC->lastcmdname, " ");
1028 safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname));
1029 time(&CC->lastidle);
1032 CtdlThreadName(cmdbuf);
1034 if ((strncasecmp(cmdbuf, "ENT0", 4))
1035 && (strncasecmp(cmdbuf, "MESG", 4))
1036 && (strncasecmp(cmdbuf, "MSGS", 4)))
1038 CC->cs_flags &= ~CS_POSTING;
1041 if (!strncasecmp(cmdbuf, "NOOP", 4)) {
1042 cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
1045 else if (!strncasecmp(cmdbuf, "QNOP", 4)) {
1046 /* do nothing, this command returns no response */
1049 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
1050 cprintf("%d Goodbye.\n", CIT_OK);
1054 else if (!strncasecmp(cmdbuf,"ASYN",4)) {
1055 cmd_asyn(&cmdbuf[5]);
1058 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
1059 if (CC->logged_in) logout(CC);
1060 cprintf("%d logged out.\n", CIT_OK);
1063 else if (!strncasecmp(cmdbuf,"USER",4)) {
1064 cmd_user(&cmdbuf[5]);
1067 else if (!strncasecmp(cmdbuf,"PASS",4)) {
1068 cmd_pass(&cmdbuf[5]);
1071 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
1072 cmd_newu(&cmdbuf[5]);
1075 else if (!strncasecmp(cmdbuf,"CREU",4)) {
1076 cmd_creu(&cmdbuf[5]);
1079 else if (!strncasecmp(cmdbuf,"SETP",4)) {
1080 cmd_setp(&cmdbuf[5]);
1083 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
1084 cmd_lrms(&cmdbuf[5]);
1087 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
1088 cmd_lkra(&cmdbuf[5]);
1091 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
1092 cmd_lkrn(&cmdbuf[5]);
1095 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
1096 cmd_lkro(&cmdbuf[5]);
1099 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
1100 cmd_lzrm(&cmdbuf[5]);
1103 else if (!strncasecmp(cmdbuf,"LPRM",4)) {
1104 cmd_lprm(&cmdbuf[5]);
1107 else if (!strncasecmp(cmdbuf,"GETU",4)) {
1111 else if (!strncasecmp(cmdbuf,"SETU",4)) {
1112 cmd_setu(&cmdbuf[5]);
1115 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
1116 cmd_goto(&cmdbuf[5]);
1119 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
1120 cmd_msgs(&cmdbuf[5]);
1123 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
1127 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
1131 else if (!strncasecmp(cmdbuf,"EUID",4)) {
1132 cmd_euid(&cmdbuf[5]);
1135 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
1136 cmd_msg0(&cmdbuf[5]);
1139 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
1140 cmd_msg2(&cmdbuf[5]);
1143 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
1144 cmd_msg3(&cmdbuf[5]);
1147 else if (!strncasecmp(cmdbuf,"MSG4",4)) {
1148 cmd_msg4(&cmdbuf[5]);
1151 else if (!strncasecmp(cmdbuf,"MSGP",4)) {
1152 cmd_msgp(&cmdbuf[5]);
1155 else if (!strncasecmp(cmdbuf,"OPNA",4)) {
1156 cmd_opna(&cmdbuf[5]);
1159 else if (!strncasecmp(cmdbuf,"DLAT",4)) {
1160 cmd_dlat(&cmdbuf[5]);
1163 else if (!strncasecmp(cmdbuf,"INFO",4)) {
1167 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
1168 cmd_slrp(&cmdbuf[5]);
1171 else if (!strncasecmp(cmdbuf,"INVT",4)) {
1172 cmd_invt_kick(&cmdbuf[5],1);
1175 else if (!strncasecmp(cmdbuf,"KICK",4)) {
1176 cmd_invt_kick(&cmdbuf[5],0);
1179 else if (!strncasecmp(cmdbuf,"GETR",4)) {
1183 else if (!strncasecmp(cmdbuf,"SETR",4)) {
1184 cmd_setr(&cmdbuf[5]);
1187 else if (!strncasecmp(cmdbuf,"GETA",4)) {
1191 else if (!strncasecmp(cmdbuf,"SETA",4)) {
1192 cmd_seta(&cmdbuf[5]);
1195 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
1196 cmd_ent0(&cmdbuf[5]);
1199 else if (!strncasecmp(cmdbuf,"RINF",4)) {
1203 else if (!strncasecmp(cmdbuf,"DELE",4)) {
1204 cmd_dele(&cmdbuf[5]);
1207 else if (!strncasecmp(cmdbuf,"KILL",4)) {
1208 cmd_kill(&cmdbuf[5]);
1211 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
1212 cmd_cre8(&cmdbuf[5]);
1215 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
1216 cmd_move(&cmdbuf[5]);
1219 else if (!strncasecmp(cmdbuf,"FORG",4)) {
1223 else if (!strncasecmp(cmdbuf,"MESG",4)) {
1224 cmd_mesg(&cmdbuf[5]);
1227 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
1228 cmd_emsg(&cmdbuf[5]);
1231 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
1235 else if (!strncasecmp(cmdbuf,"VALI",4)) {
1236 cmd_vali(&cmdbuf[5]);
1239 else if (!strncasecmp(cmdbuf,"EINF",4)) {
1240 cmd_einf(&cmdbuf[5]);
1243 else if (!strncasecmp(cmdbuf,"LIST",4)) {
1244 cmd_list(&cmdbuf[5]);
1247 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
1251 else if (!strncasecmp(cmdbuf,"DELF",4)) {
1252 cmd_delf(&cmdbuf[5]);
1255 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
1256 cmd_movf(&cmdbuf[5]);
1259 else if (!strncasecmp(cmdbuf,"NETF",4)) {
1260 cmd_netf(&cmdbuf[5]);
1263 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
1264 cmd_open(&cmdbuf[5]);
1267 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
1271 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
1272 cmd_uopn(&cmdbuf[5]);
1275 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
1276 cmd_ucls(&cmdbuf[5]);
1279 else if (!strncasecmp(cmdbuf,"READ",4)) {
1280 cmd_read(&cmdbuf[5]);
1283 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
1284 cmd_writ(&cmdbuf[5]);
1287 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
1288 cmd_qusr(&cmdbuf[5]);
1291 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
1292 cmd_echo(&cmdbuf[5]);
1295 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
1296 cmd_oimg(&cmdbuf[5]);
1299 else if (!strncasecmp(cmdbuf,"MORE",4)) {
1303 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
1304 cmd_ndop(&cmdbuf[5]);
1307 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
1308 cmd_nuop(&cmdbuf[5]);
1311 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
1315 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
1316 cmd_cflr(&cmdbuf[5]);
1319 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
1320 cmd_kflr(&cmdbuf[5]);
1323 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
1324 cmd_eflr(&cmdbuf[5]);
1327 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
1328 cmd_iden(&cmdbuf[5]);
1331 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1332 cmd_ipgm(&cmdbuf[5]);
1335 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1336 cmd_term(&cmdbuf[5]);
1339 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1340 cmd_down(&cmdbuf[5]);
1343 else if (!strncasecmp(cmdbuf,"HALT",4)) {
1347 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1348 cmd_scdn(&cmdbuf[5]);
1351 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1352 cmd_uimg(&cmdbuf[5]);
1355 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1359 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1360 cmd_agup(&cmdbuf[5]);
1363 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1364 cmd_asup(&cmdbuf[5]);
1367 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1368 cmd_gpex(&cmdbuf[5]);
1371 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1372 cmd_spex(&cmdbuf[5]);
1375 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1376 cmd_conf(&cmdbuf[5]);
1379 else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
1380 cmd_seen(&cmdbuf[5]);
1383 else if (!strncasecmp(cmdbuf, "GTSN", 4)) {
1384 cmd_gtsn(&cmdbuf[5]);
1387 else if (!strncasecmp(cmdbuf, "VIEW", 4)) {
1388 cmd_view(&cmdbuf[5]);
1391 else if (!strncasecmp(cmdbuf, "ISME", 4)) {
1392 cmd_isme(&cmdbuf[5]);
1395 else if (!DLoader_Exec_Cmd(cmdbuf)) {
1396 cprintf("%d Unrecognized or unsupported command.\n",
1397 ERROR + CMD_NOT_SUPPORTED);
1402 /* Run any after-each-command routines registered by modules */
1403 PerformSessionHooks(EVT_CMD);
1404 CtdlThreadName(old_name);
1409 * This loop performs all asynchronous functions.
1411 void do_async_loop(void) {
1412 PerformSessionHooks(EVT_ASYNC);