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>
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
41 #include "sysdep_decls.h"
42 #include "citserver.h"
45 #include "housekeeping.h"
49 #include "locate_host.h"
55 #include "euidindex.h"
56 #include "serv_network.h"
62 struct CitContext *ContextList = NULL;
63 struct CitContext* next_session = NULL;
64 char *unique_session_numbers;
65 int ScheduledShutdown = 0;
67 time_t server_startup_time;
70 * Various things that need to be initialized at startup
72 void master_startup(void) {
76 struct ctdlroom qrbuf;
78 lprintf(CTDL_DEBUG, "master_startup() started\n");
79 time(&server_startup_time);
81 lprintf(CTDL_INFO, "Opening databases\n");
90 lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
91 create_room(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
92 create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
93 create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
94 create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
96 /* The "Local System Configuration" room doesn't need to be visible */
97 if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
98 qrbuf.QRflags2 |= QR2_SYSTEM;
102 lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
103 urandom = fopen("/dev/urandom", "r");
104 if (urandom != NULL) {
105 fread(&seed, sizeof seed, 1, urandom);
109 gettimeofday(&tv, NULL);
114 lprintf(CTDL_INFO, "Initializing ipgm secret\n");
116 config.c_ipgm_secret = rand();
119 lprintf(CTDL_DEBUG, "master_startup() finished\n");
124 * Cleanup routine to be called when the server is shutting down.
126 void master_cleanup(int exitcode) {
127 struct CleanupFunctionHook *fcn;
128 static int already_cleaning_up = 0;
130 if (already_cleaning_up) while(1) sleep(1);
131 already_cleaning_up = 1;
133 /* Run any cleanup routines registered by loadable modules */
134 for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
135 (*fcn->h_function_pointer)();
138 /* Close the AdjRefCount queue file */
141 /* Shut down the indexer thread */
142 lprintf(CTDL_INFO, "Waiting for the indexer thread to shut down\n");
143 pthread_join(indexer_thread_tid, NULL);
145 /* Shut down the checkpoint thread */
146 lprintf(CTDL_INFO, "Waiting for the checkpoint thread to shut down\n");
147 pthread_join(checkpoint_thread_tid, NULL);
149 /* Close databases */
150 lprintf(CTDL_INFO, "Closing databases\n");
153 /* flush the networker stuff */
154 destroy_network_queue_room();
156 /* Do system-dependent stuff */
157 sysdep_master_cleanup();
159 #ifdef DEBUG_MEMORY_LEAKS
163 /* If the operator requested a halt but not an exit, halt here. */
164 if (shutdown_and_halt) {
165 lprintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
166 fflush(stdout); fflush(stderr);
175 lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
176 fflush(stdout); fflush(stderr);
184 * Terminate a session.
186 void RemoveContext (struct CitContext *con)
190 "WARNING: RemoveContext() called with NULL!\n");
193 lprintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
195 /* Run any cleanup routines registered by loadable modules.
196 * Note: We have to "become_session()" because the cleanup functions
197 * might make references to "CC" assuming it's the right one.
200 PerformSessionHooks(EVT_STOP);
201 become_session(NULL);
203 /* Now handle all of the administrivia. */
204 lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
207 lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
209 /* If the client is still connected, blow 'em away. */
210 lprintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
211 close(con->client_socket);
213 lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
221 * cmd_info() - tell the client about this server
223 void cmd_info(void) {
224 cprintf("%d Server info:\n", LISTING_FOLLOWS);
225 cprintf("%d\n", CC->cs_pid);
226 cprintf("%s\n", config.c_nodename);
227 cprintf("%s\n", config.c_humannode);
228 cprintf("%s\n", config.c_fqdn);
229 cprintf("%s\n", CITADEL);
230 cprintf("%d\n", REV_LEVEL);
231 cprintf("%s\n", config.c_site_location);
232 cprintf("%s\n", config.c_sysadm);
233 cprintf("%d\n", SERVER_TYPE);
234 cprintf("%s\n", config.c_moreprompt);
235 cprintf("1\n"); /* 1 = yes, this system supports floors */
236 cprintf("1\n"); /* 1 = we support the extended paging options */
237 cprintf("%s\n", CC->cs_nonce);
238 cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */
241 cprintf("1\n"); /* 1 = yes, this server is LDAP-enabled */
243 cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */
246 if (config.c_auth_mode == 1) {
247 cprintf("1\n"); /* "create new user" never works with host auth */
250 cprintf("%d\n", config.c_disable_newu); /* otherwise, site defined */
253 cprintf("%s\n", config.c_default_cal_zone);
260 * returns an asterisk if there are any instant messages waiting,
263 char CtdlCheckExpress(void) {
264 if (CC->FirstExpressMessage == NULL) {
278 localtime_r(&tv, &tmp);
280 /* timezone and daylight global variables are not portable. */
281 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
282 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
284 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
290 * Check originating host against the public_clients file. This determines
291 * whether the client is allowed to change the hostname for this session
292 * (for example, to show the location of the user rather than the location
295 int is_public_client(void)
302 static time_t pc_timestamp = 0;
303 static char public_clients[SIZ];
304 static char public_clients_file[SIZ];
306 snprintf(public_clients_file,
307 sizeof public_clients_file,
312 * Check the time stamp on the public_clients file. If it's been
313 * updated since the last time we were here (or if this is the first
314 * time we've been through the loop), read its contents and learn
315 * the IP addresses of the listed hosts.
317 if (stat(public_clients_file, &statbuf) != 0) {
318 /* No public_clients file exists, so bail out */
319 lprintf(CTDL_WARNING, "Warning: '%s' does not exist\n",
320 public_clients_file);
324 if (statbuf.st_mtime > pc_timestamp) {
325 begin_critical_section(S_PUBLIC_CLIENTS);
326 lprintf(CTDL_INFO, "Loading %s\n", public_clients_file);
328 safestrncpy(public_clients, "127.0.0.1", sizeof public_clients);
329 if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
330 strcat(public_clients, "|");
331 strcat(public_clients, addrbuf);
334 fp = fopen(public_clients_file, "r");
335 if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
336 for (i=0; i<strlen(buf); ++i) {
337 if (buf[i] == '#') buf[i] = 0;
339 while (isspace((buf[strlen(buf)-1]))) {
340 buf[strlen(buf)-1] = 0;
342 if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
343 if ((strlen(public_clients) +
345 < sizeof(public_clients)) {
346 strcat(public_clients, "|");
347 strcat(public_clients, addrbuf);
352 pc_timestamp = time(NULL);
353 end_critical_section(S_PUBLIC_CLIENTS);
356 lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
358 for (i=0; i<num_parms(public_clients); ++i) {
359 extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
360 if (!strcasecmp(CC->cs_addr, addrbuf)) {
361 lprintf(CTDL_DEBUG, "... yes it is.\n");
366 /* No hits. This is not a public client. */
367 lprintf(CTDL_DEBUG, "... no it isn't.\n");
373 * the client is identifying itself to the server
375 void cmd_iden(char *argbuf)
385 if (num_parms(argbuf)<4) {
386 cprintf("%d usage error\n", ERROR + ILLEGAL_VALUE);
390 dev_code = extract_int(argbuf,0);
391 cli_code = extract_int(argbuf,1);
392 rev_level = extract_int(argbuf,2);
393 extract_token(desc, argbuf, 3, '|', sizeof desc);
395 safestrncpy(from_host, config.c_fqdn, sizeof from_host);
396 from_host[sizeof from_host - 1] = 0;
397 if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host);
399 CC->cs_clientdev = dev_code;
400 CC->cs_clienttyp = cli_code;
401 CC->cs_clientver = rev_level;
402 safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
403 CC->cs_clientname[31] = 0;
405 if (strlen(from_host) > 0) {
406 if (CC->is_local_socket) do_lookup = 1;
407 else if (is_public_client()) do_lookup = 1;
411 lprintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
412 if ((addr.s_addr = inet_addr(from_host)) != -1) {
413 locate_host(CC->cs_host, sizeof CC->cs_host,
414 CC->cs_addr, sizeof CC->cs_addr,
418 safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
419 CC->cs_host[sizeof CC->cs_host - 1] = 0;
423 lprintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
430 cprintf("%d Ok\n",CIT_OK);
435 * display system messages or help
437 void cmd_mesg(char *mname)
447 extract_token(buf, mname, 0, '|', sizeof buf);
449 dirs[0] = strdup(ctdl_message_dir);
450 dirs[1] = strdup(ctdl_hlp_dir);
452 snprintf(buf2, sizeof buf2, "%s.%d.%d",
453 buf, CC->cs_clientdev, CC->cs_clienttyp);
455 /* If the client requested "?" then produce a listing */
456 if (!strcmp(buf, "?")) {
457 cprintf("%d %s\n", LISTING_FOLLOWS, buf);
458 dp = opendir(dirs[1]);
460 while (d = readdir(dp), d != NULL) {
461 if (d->d_name[0] != '.') {
462 cprintf(" %s\n", d->d_name);
473 /* Otherwise, look for the requested file by name. */
475 mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
476 if (strlen(targ) == 0) {
477 snprintf(buf2, sizeof buf2, "%s.%d",
478 buf, CC->cs_clientdev);
479 mesg_locate(targ, sizeof targ, buf2, 2,
480 (const char **)dirs);
481 if (strlen(targ) == 0) {
482 mesg_locate(targ, sizeof targ, buf, 2,
483 (const char **)dirs);
491 if (strlen(targ)==0) {
492 cprintf("%d '%s' not found. (Searching in %s and %s)\n",
493 ERROR + FILE_NOT_FOUND,
501 mfp = fopen(targ, "r");
503 cprintf("%d Cannot open '%s': %s\n",
504 ERROR + INTERNAL_ERROR, targ, strerror(errno));
507 cprintf("%d %s\n", LISTING_FOLLOWS,buf);
509 while (fgets(buf, (sizeof buf - 1), mfp) != NULL) {
510 buf[strlen(buf)-1] = 0;
521 * enter system messages or help
523 void cmd_emsg(char *mname)
533 if (CtdlAccessCheck(ac_aide)) return;
535 extract_token(buf, mname, 0, '|', sizeof buf);
536 for (a=0; a<strlen(buf); ++a) { /* security measure */
537 if (buf[a] == '/') buf[a] = '.';
540 dirs[0] = strdup(ctdl_message_dir);
541 dirs[1] = strdup(ctdl_hlp_dir);
543 mesg_locate(targ, sizeof targ, buf, 2, (const char**)dirs);
547 if (strlen(targ)==0) {
548 snprintf(targ, sizeof targ,
553 mfp = fopen(targ,"w");
555 cprintf("%d Cannot open '%s': %s\n",
556 ERROR + INTERNAL_ERROR, targ, strerror(errno));
559 cprintf("%d %s\n", SEND_LISTING, targ);
561 while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
562 fprintf(mfp, "%s\n", buf);
569 /* Don't show the names of private rooms unless the viewing
570 * user also knows the rooms.
572 void GenerateRoomDisplay(char *real_room,
573 struct CitContext *viewed,
574 struct CitContext *viewer) {
578 strcpy(real_room, viewed->room.QRname);
579 if (viewed->room.QRflags & QR_MAILBOX) {
580 strcpy(real_room, &real_room[11]);
582 if (viewed->room.QRflags & QR_PRIVATE) {
583 CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
584 if ( (ra & UA_KNOWN) == 0) {
585 strcpy(real_room, "<private room>");
589 if (viewed->cs_flags & CS_CHAT) {
590 while (strlen(real_room) < 14)
591 strcat(real_room, " ");
593 strcpy(&real_room[14], "<chat>");
599 * Convenience function.
601 int CtdlAccessCheck(int required_level) {
603 if (CC->internal_pgm) return(0);
604 if (required_level >= ac_internal) {
605 cprintf("%d This is not a user-level command.\n",
606 ERROR + HIGHER_ACCESS_REQUIRED);
610 if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
611 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
615 if (CC->user.axlevel >= 6) return(0);
616 if (required_level >= ac_aide) {
617 cprintf("%d This command requires Aide access.\n",
618 ERROR + HIGHER_ACCESS_REQUIRED);
622 if (is_room_aide()) return(0);
623 if (required_level >= ac_room_aide) {
624 cprintf("%d This command requires Aide or Room Aide access.\n",
625 ERROR + HIGHER_ACCESS_REQUIRED);
629 /* shhh ... succeed quietly */
636 * Terminate another running session
638 void cmd_term(char *cmdbuf)
641 struct CitContext *ccptr;
645 session_num = extract_int(cmdbuf, 0);
646 if (session_num == CC->cs_pid) {
647 cprintf("%d You can't kill your own session.\n", ERROR + ILLEGAL_VALUE);
651 lprintf(CTDL_DEBUG, "Locating session to kill\n");
652 begin_critical_section(S_SESSION_TABLE);
653 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
654 if (session_num == ccptr->cs_pid) {
656 if ((ccptr->user.usernum == CC->user.usernum)
657 || (CC->user.axlevel >= 6)) {
666 end_critical_section(S_SESSION_TABLE);
670 cprintf("%d Session terminated.\n", CIT_OK);
673 cprintf("%d You are not allowed to do that.\n",
674 ERROR + HIGHER_ACCESS_REQUIRED);
678 cprintf("%d No such session.\n", ERROR + ILLEGAL_VALUE);
687 * get the paginator prompt
689 void cmd_more(void) {
690 cprintf("%d %s\n", CIT_OK, config.c_moreprompt);
696 void cmd_echo(char *etext)
698 cprintf("%d %s\n", CIT_OK, etext);
704 * identify as internal program
706 void cmd_ipgm(char *argbuf)
710 secret = extract_int(argbuf, 0);
712 /* For security reasons, we do NOT allow this command to run
713 * over the network. Local sockets only.
715 if (!CC->is_local_socket) {
717 cprintf("%d Authentication failed.\n",
718 ERROR + PASSWORD_REQUIRED);
720 else if (secret == config.c_ipgm_secret) {
721 CC->internal_pgm = 1;
722 strcpy(CC->curr_user, "<internal program>");
723 CC->cs_flags = CC->cs_flags|CS_STEALTH;
724 cprintf("%d Authenticated as an internal program.\n", CIT_OK);
728 cprintf("%d Authentication failed.\n",
729 ERROR + PASSWORD_REQUIRED);
730 lprintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
734 /* Now change the ipgm secret for the next round.
735 * (Disabled because it breaks concurrent scripts. The fact that
736 * we no longer accept IPGM over the network should be sufficient
737 * to prevent brute-force attacks. If you don't agree, uncomment
740 config.c_ipgm_secret = rand();
747 * Shut down the server
749 void cmd_down(void) {
751 if (CtdlAccessCheck(ac_aide)) return;
753 cprintf("%d Shutting down server. Goodbye.\n", CIT_OK);
758 * Halt the server without exiting the server process.
760 void cmd_halt(void) {
762 if (CtdlAccessCheck(ac_aide)) return;
764 cprintf("%d Halting server. Goodbye.\n", CIT_OK);
766 shutdown_and_halt = 1;
770 * Schedule or cancel a server shutdown
772 void cmd_scdn(char *argbuf)
776 if (CtdlAccessCheck(ac_aide)) return;
778 new_state = extract_int(argbuf, 0);
779 if ((new_state == 0) || (new_state == 1)) {
780 ScheduledShutdown = new_state;
782 cprintf("%d %d\n", CIT_OK, ScheduledShutdown);
787 * Set or unset asynchronous protocol mode
789 void cmd_asyn(char *argbuf)
793 new_state = extract_int(argbuf, 0);
794 if ((new_state == 0) || (new_state == 1)) {
795 CC->is_async = new_state;
797 cprintf("%d %d\n", CIT_OK, CC->is_async);
802 * Generate a "nonce" for APOP-style authentication.
804 * RFC 1725 et al specify a PID to be placed in front of the nonce.
805 * Quoth BTX: That would be stupid.
807 void generate_nonce(struct CitContext *con) {
810 memset(con->cs_nonce, NONCE_SIZE, 0);
811 gettimeofday(&tv, NULL);
812 memset(con->cs_nonce, NONCE_SIZE, 0);
813 snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
814 rand(), (long)tv.tv_usec, config.c_fqdn);
821 * Back-end function for starting a session
823 void begin_session(struct CitContext *con)
826 struct sockaddr_in sin;
829 * Initialize some variables specific to our context.
832 con->internal_pgm = 0;
833 con->download_fp = NULL;
834 con->upload_fp = NULL;
835 con->FirstExpressMessage = NULL;
837 time(&con->lastidle);
838 strcpy(con->lastcmdname, " ");
839 strcpy(con->cs_clientname, "(unknown)");
840 strcpy(con->curr_user, NLI);
841 strcpy(con->net_node, "");
842 strcpy(con->fake_username, "");
843 strcpy(con->fake_hostname, "");
844 strcpy(con->fake_roomname, "");
846 safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
847 safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
848 con->cs_host[sizeof con->cs_host - 1] = 0;
850 if (!CC->is_local_socket) {
851 if (!getpeername(con->client_socket, (struct sockaddr *) &sin, &len)) {
852 locate_host(con->cs_host, sizeof con->cs_host,
853 con->cs_addr, sizeof con->cs_addr,
859 strcpy(con->cs_host, "");
862 con->upload_type = UPL_FILE;
866 if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) {
870 lprintf(CTDL_NOTICE, "Session started.\n");
872 /* Run any session startup routines registered by loadable modules */
873 PerformSessionHooks(EVT_START);
877 void citproto_begin_session() {
878 if (CC->nologin==1) {
879 cprintf("%d %s: Too many users are already online (maximum is %d)\n",
880 ERROR + MAX_SESSIONS_EXCEEDED,
881 config.c_nodename, config.c_maxsessions
886 cprintf("%d %s Citadel server ready.\n",
887 CIT_OK, config.c_nodename);
895 * This loop recognizes all server commands.
897 void do_command_loop(void) {
901 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
902 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
903 lprintf(CTDL_ERR, "Client disconnected: ending session.\n");
908 /* Log the server command, but don't show passwords... */
909 if ( (strncasecmp(cmdbuf, "PASS", 4))
910 && (strncasecmp(cmdbuf, "SETP", 4)) ) {
911 lprintf(CTDL_INFO, "%s\n", cmdbuf);
914 lprintf(CTDL_INFO, "<password command sent>\n");
920 * Let other clients see the last command we executed, and
921 * update the idle time, but not NOOP, QNOP, PEXP, GEXP, RWHO, or TIME.
923 if ( (strncasecmp(cmdbuf, "NOOP", 4))
924 && (strncasecmp(cmdbuf, "QNOP", 4))
925 && (strncasecmp(cmdbuf, "PEXP", 4))
926 && (strncasecmp(cmdbuf, "GEXP", 4))
927 && (strncasecmp(cmdbuf, "RWHO", 4))
928 && (strncasecmp(cmdbuf, "TIME", 4)) ) {
929 strcpy(CC->lastcmdname, " ");
930 safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname));
934 if ((strncasecmp(cmdbuf, "ENT0", 4))
935 && (strncasecmp(cmdbuf, "MESG", 4))
936 && (strncasecmp(cmdbuf, "MSGS", 4)))
938 CC->cs_flags &= ~CS_POSTING;
941 if (!strncasecmp(cmdbuf, "NOOP", 4)) {
942 cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
945 else if (!strncasecmp(cmdbuf, "QNOP", 4)) {
946 /* do nothing, this command returns no response */
949 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
950 cprintf("%d Goodbye.\n", CIT_OK);
954 else if (!strncasecmp(cmdbuf,"ASYN",4)) {
955 cmd_asyn(&cmdbuf[5]);
958 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
959 if (CC->logged_in) logout(CC);
960 cprintf("%d logged out.\n", CIT_OK);
963 else if (!strncasecmp(cmdbuf,"USER",4)) {
964 cmd_user(&cmdbuf[5]);
967 else if (!strncasecmp(cmdbuf,"PASS",4)) {
968 cmd_pass(&cmdbuf[5]);
971 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
972 cmd_newu(&cmdbuf[5]);
975 else if (!strncasecmp(cmdbuf,"CREU",4)) {
976 cmd_creu(&cmdbuf[5]);
979 else if (!strncasecmp(cmdbuf,"SETP",4)) {
980 cmd_setp(&cmdbuf[5]);
983 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
984 cmd_lrms(&cmdbuf[5]);
987 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
988 cmd_lkra(&cmdbuf[5]);
991 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
992 cmd_lkrn(&cmdbuf[5]);
995 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
996 cmd_lkro(&cmdbuf[5]);
999 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
1000 cmd_lzrm(&cmdbuf[5]);
1003 else if (!strncasecmp(cmdbuf,"LPRM",4)) {
1004 cmd_lprm(&cmdbuf[5]);
1007 else if (!strncasecmp(cmdbuf,"GETU",4)) {
1011 else if (!strncasecmp(cmdbuf,"SETU",4)) {
1012 cmd_setu(&cmdbuf[5]);
1015 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
1016 cmd_goto(&cmdbuf[5]);
1019 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
1020 cmd_msgs(&cmdbuf[5]);
1023 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
1027 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
1031 else if (!strncasecmp(cmdbuf,"EUID",4)) {
1032 cmd_euid(&cmdbuf[5]);
1035 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
1036 cmd_msg0(&cmdbuf[5]);
1039 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
1040 cmd_msg2(&cmdbuf[5]);
1043 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
1044 cmd_msg3(&cmdbuf[5]);
1047 else if (!strncasecmp(cmdbuf,"MSG4",4)) {
1048 cmd_msg4(&cmdbuf[5]);
1051 else if (!strncasecmp(cmdbuf,"MSGP",4)) {
1052 cmd_msgp(&cmdbuf[5]);
1055 else if (!strncasecmp(cmdbuf,"OPNA",4)) {
1056 cmd_opna(&cmdbuf[5]);
1059 else if (!strncasecmp(cmdbuf,"DLAT",4)) {
1060 cmd_dlat(&cmdbuf[5]);
1063 else if (!strncasecmp(cmdbuf,"INFO",4)) {
1067 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
1068 cmd_slrp(&cmdbuf[5]);
1071 else if (!strncasecmp(cmdbuf,"INVT",4)) {
1072 cmd_invt_kick(&cmdbuf[5],1);
1075 else if (!strncasecmp(cmdbuf,"KICK",4)) {
1076 cmd_invt_kick(&cmdbuf[5],0);
1079 else if (!strncasecmp(cmdbuf,"GETR",4)) {
1083 else if (!strncasecmp(cmdbuf,"SETR",4)) {
1084 cmd_setr(&cmdbuf[5]);
1087 else if (!strncasecmp(cmdbuf,"GETA",4)) {
1091 else if (!strncasecmp(cmdbuf,"SETA",4)) {
1092 cmd_seta(&cmdbuf[5]);
1095 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
1096 cmd_ent0(&cmdbuf[5]);
1099 else if (!strncasecmp(cmdbuf,"RINF",4)) {
1103 else if (!strncasecmp(cmdbuf,"DELE",4)) {
1104 cmd_dele(&cmdbuf[5]);
1107 else if (!strncasecmp(cmdbuf,"KILL",4)) {
1108 cmd_kill(&cmdbuf[5]);
1111 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
1112 cmd_cre8(&cmdbuf[5]);
1115 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
1116 cmd_move(&cmdbuf[5]);
1119 else if (!strncasecmp(cmdbuf,"FORG",4)) {
1123 else if (!strncasecmp(cmdbuf,"MESG",4)) {
1124 cmd_mesg(&cmdbuf[5]);
1127 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
1128 cmd_emsg(&cmdbuf[5]);
1131 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
1135 else if (!strncasecmp(cmdbuf,"VALI",4)) {
1136 cmd_vali(&cmdbuf[5]);
1139 else if (!strncasecmp(cmdbuf,"EINF",4)) {
1140 cmd_einf(&cmdbuf[5]);
1143 else if (!strncasecmp(cmdbuf,"LIST",4)) {
1144 cmd_list(&cmdbuf[5]);
1147 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
1151 else if (!strncasecmp(cmdbuf,"DELF",4)) {
1152 cmd_delf(&cmdbuf[5]);
1155 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
1156 cmd_movf(&cmdbuf[5]);
1159 else if (!strncasecmp(cmdbuf,"NETF",4)) {
1160 cmd_netf(&cmdbuf[5]);
1163 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
1164 cmd_open(&cmdbuf[5]);
1167 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
1171 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
1172 cmd_uopn(&cmdbuf[5]);
1175 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
1176 cmd_ucls(&cmdbuf[5]);
1179 else if (!strncasecmp(cmdbuf,"READ",4)) {
1180 cmd_read(&cmdbuf[5]);
1183 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
1184 cmd_writ(&cmdbuf[5]);
1187 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
1188 cmd_qusr(&cmdbuf[5]);
1191 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
1192 cmd_echo(&cmdbuf[5]);
1195 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
1196 cmd_oimg(&cmdbuf[5]);
1199 else if (!strncasecmp(cmdbuf,"MORE",4)) {
1203 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
1204 cmd_ndop(&cmdbuf[5]);
1207 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
1208 cmd_nuop(&cmdbuf[5]);
1211 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
1215 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
1216 cmd_cflr(&cmdbuf[5]);
1219 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
1220 cmd_kflr(&cmdbuf[5]);
1223 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
1224 cmd_eflr(&cmdbuf[5]);
1227 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
1228 cmd_iden(&cmdbuf[5]);
1231 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1232 cmd_ipgm(&cmdbuf[5]);
1235 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1236 cmd_term(&cmdbuf[5]);
1239 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1243 else if (!strncasecmp(cmdbuf,"HALT",4)) {
1247 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1248 cmd_scdn(&cmdbuf[5]);
1251 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1252 cmd_uimg(&cmdbuf[5]);
1255 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1259 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1260 cmd_agup(&cmdbuf[5]);
1263 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1264 cmd_asup(&cmdbuf[5]);
1267 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1268 cmd_gpex(&cmdbuf[5]);
1271 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1272 cmd_spex(&cmdbuf[5]);
1275 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1276 cmd_conf(&cmdbuf[5]);
1279 else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
1280 cmd_seen(&cmdbuf[5]);
1283 else if (!strncasecmp(cmdbuf, "GTSN", 4)) {
1284 cmd_gtsn(&cmdbuf[5]);
1287 else if (!strncasecmp(cmdbuf, "VIEW", 4)) {
1288 cmd_view(&cmdbuf[5]);
1291 else if (!strncasecmp(cmdbuf, "ISME", 4)) {
1292 cmd_isme(&cmdbuf[5]);
1295 else if (!DLoader_Exec_Cmd(cmdbuf)) {
1296 cprintf("%d Unrecognized or unsupported command.\n",
1297 ERROR + CMD_NOT_SUPPORTED);
1302 /* Run any after-each-command routines registered by modules */
1303 PerformSessionHooks(EVT_CMD);
1308 * This loop performs all asynchronous functions.
1310 void do_async_loop(void) {
1311 PerformSessionHooks(EVT_ASYNC);