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");
144 lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
145 create_room(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
146 create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
147 create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
148 create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
150 /* The "Local System Configuration" room doesn't need to be visible */
151 if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
152 qrbuf.QRflags2 |= QR2_SYSTEM;
156 lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
157 urandom = fopen("/dev/urandom", "r");
158 if (urandom != NULL) {
159 fread(&seed, sizeof seed, 1, urandom);
163 gettimeofday(&tv, NULL);
168 lprintf(CTDL_INFO, "Initializing ipgm secret\n");
170 config.c_ipgm_secret = rand();
173 lprintf(CTDL_DEBUG, "master_startup() finished\n");
178 * Cleanup routine to be called when the server is shutting down.
180 void master_cleanup(int exitcode) {
181 struct CleanupFunctionHook *fcn;
182 static int already_cleaning_up = 0;
184 if (already_cleaning_up) while(1) sleep(1);
185 already_cleaning_up = 1;
187 /* Run any cleanup routines registered by loadable modules */
188 for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
189 (*fcn->h_function_pointer)();
192 /* Close the AdjRefCount queue file */
195 /* Close databases */
196 lprintf(CTDL_INFO, "Closing databases\n");
199 /* Do system-dependent stuff */
200 sysdep_master_cleanup();
202 #ifdef DEBUG_MEMORY_LEAKS
206 /* If the operator requested a halt but not an exit, halt here. */
207 if (shutdown_and_halt) {
208 lprintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
209 fflush(stdout); fflush(stderr);
218 lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
219 fflush(stdout); fflush(stderr);
221 if (restart_server != 0)
229 * Terminate a session.
231 void RemoveContext (struct CitContext *con)
235 "WARNING: RemoveContext() called with NULL!\n");
238 lprintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
240 /* Run any cleanup routines registered by loadable modules.
241 * Note: We have to "become_session()" because the cleanup functions
242 * might make references to "CC" assuming it's the right one.
245 PerformSessionHooks(EVT_STOP);
246 become_session(NULL);
248 /* Now handle all of the administrivia. */
249 lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
252 lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
254 /* If the client is still connected, blow 'em away. */
255 lprintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
256 close(con->client_socket);
258 lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
266 * cmd_info() - tell the client about this server
268 void cmd_info(void) {
269 cprintf("%d Server info:\n", LISTING_FOLLOWS);
270 cprintf("%d\n", CC->cs_pid);
271 cprintf("%s\n", config.c_nodename);
272 cprintf("%s\n", config.c_humannode);
273 cprintf("%s\n", config.c_fqdn);
274 cprintf("%s\n", CITADEL);
275 cprintf("%d\n", REV_LEVEL);
276 cprintf("%s\n", config.c_site_location);
277 cprintf("%s\n", config.c_sysadm);
278 cprintf("%d\n", SERVER_TYPE);
279 cprintf("%s\n", config.c_moreprompt);
280 cprintf("1\n"); /* 1 = yes, this system supports floors */
281 cprintf("1\n"); /* 1 = we support the extended paging options */
282 cprintf("%s\n", CC->cs_nonce);
283 cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */
286 cprintf("1\n"); /* 1 = yes, this server is LDAP-enabled */
288 cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */
291 if (config.c_auth_mode == 1) {
292 cprintf("1\n"); /* "create new user" never works with host auth */
295 cprintf("%d\n", config.c_disable_newu); /* otherwise, site defined */
298 cprintf("%s\n", config.c_default_cal_zone);
305 * returns an asterisk if there are any instant messages waiting,
308 char CtdlCheckExpress(void) {
309 if (CC->FirstExpressMessage == NULL) {
323 localtime_r(&tv, &tmp);
325 /* timezone and daylight global variables are not portable. */
326 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
327 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
329 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
335 * Check originating host against the public_clients file. This determines
336 * whether the client is allowed to change the hostname for this session
337 * (for example, to show the location of the user rather than the location
340 int is_public_client(void)
347 static time_t pc_timestamp = 0;
348 static char public_clients[SIZ];
349 static char public_clients_file[SIZ];
351 snprintf(public_clients_file,
352 sizeof public_clients_file,
357 * Check the time stamp on the public_clients file. If it's been
358 * updated since the last time we were here (or if this is the first
359 * time we've been through the loop), read its contents and learn
360 * the IP addresses of the listed hosts.
362 if (stat(public_clients_file, &statbuf) != 0) {
363 /* No public_clients file exists, so bail out */
364 lprintf(CTDL_WARNING, "Warning: '%s' does not exist\n",
365 public_clients_file);
369 if (statbuf.st_mtime > pc_timestamp) {
370 begin_critical_section(S_PUBLIC_CLIENTS);
371 lprintf(CTDL_INFO, "Loading %s\n", public_clients_file);
373 safestrncpy(public_clients, "127.0.0.1", sizeof public_clients);
374 if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
375 strcat(public_clients, "|");
376 strcat(public_clients, addrbuf);
379 fp = fopen(public_clients_file, "r");
380 if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
383 while (!IsEmptyStr(ptr)) {
391 while (ptr>buf && isspace(*ptr)) {
394 if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
395 if ((strlen(public_clients) +
397 < sizeof(public_clients)) {
398 strcat(public_clients, "|");
399 strcat(public_clients, addrbuf);
404 pc_timestamp = time(NULL);
405 end_critical_section(S_PUBLIC_CLIENTS);
408 lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
410 for (i=0; i<num_parms(public_clients); ++i) {
411 extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
412 if (!strcasecmp(CC->cs_addr, addrbuf)) {
413 lprintf(CTDL_DEBUG, "... yes it is.\n");
418 /* No hits. This is not a public client. */
419 lprintf(CTDL_DEBUG, "... no it isn't.\n");
425 * the client is identifying itself to the server
427 void cmd_iden(char *argbuf)
437 if (num_parms(argbuf)<4) {
438 cprintf("%d usage error\n", ERROR + ILLEGAL_VALUE);
442 dev_code = extract_int(argbuf,0);
443 cli_code = extract_int(argbuf,1);
444 rev_level = extract_int(argbuf,2);
445 extract_token(desc, argbuf, 3, '|', sizeof desc);
447 safestrncpy(from_host, config.c_fqdn, sizeof from_host);
448 from_host[sizeof from_host - 1] = 0;
449 if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host);
451 CC->cs_clientdev = dev_code;
452 CC->cs_clienttyp = cli_code;
453 CC->cs_clientver = rev_level;
454 safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
455 CC->cs_clientname[31] = 0;
457 if (!IsEmptyStr(from_host)) {
458 if (CC->is_local_socket) do_lookup = 1;
459 else if (is_public_client()) do_lookup = 1;
463 lprintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
464 if ((addr.s_addr = inet_addr(from_host)) != -1) {
465 locate_host(CC->cs_host, sizeof CC->cs_host,
466 CC->cs_addr, sizeof CC->cs_addr,
470 safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
471 CC->cs_host[sizeof CC->cs_host - 1] = 0;
475 lprintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
482 cprintf("%d Ok\n",CIT_OK);
487 * display system messages or help
489 void cmd_mesg(char *mname)
499 extract_token(buf, mname, 0, '|', sizeof buf);
501 dirs[0] = strdup(ctdl_message_dir);
502 dirs[1] = strdup(ctdl_hlp_dir);
504 snprintf(buf2, sizeof buf2, "%s.%d.%d",
505 buf, CC->cs_clientdev, CC->cs_clienttyp);
507 /* If the client requested "?" then produce a listing */
508 if (!strcmp(buf, "?")) {
509 cprintf("%d %s\n", LISTING_FOLLOWS, buf);
510 dp = opendir(dirs[1]);
512 while (d = readdir(dp), d != NULL) {
513 if (d->d_name[0] != '.') {
514 cprintf(" %s\n", d->d_name);
525 /* Otherwise, look for the requested file by name. */
527 mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs);
528 if (IsEmptyStr(targ)) {
529 snprintf(buf2, sizeof buf2, "%s.%d",
530 buf, CC->cs_clientdev);
531 mesg_locate(targ, sizeof targ, buf2, 2,
532 (const char **)dirs);
533 if (IsEmptyStr(targ)) {
534 mesg_locate(targ, sizeof targ, buf, 2,
535 (const char **)dirs);
543 if (IsEmptyStr(targ)) {
544 cprintf("%d '%s' not found. (Searching in %s and %s)\n",
545 ERROR + FILE_NOT_FOUND,
553 mfp = fopen(targ, "r");
555 cprintf("%d Cannot open '%s': %s\n",
556 ERROR + INTERNAL_ERROR, targ, strerror(errno));
559 cprintf("%d %s\n", LISTING_FOLLOWS,buf);
561 while (fgets(buf, (sizeof buf - 1), mfp) != NULL) {
562 buf[strlen(buf)-1] = 0;
573 * enter system messages or help
575 void cmd_emsg(char *mname)
585 if (CtdlAccessCheck(ac_aide)) return;
587 extract_token(buf, mname, 0, '|', sizeof buf);
588 for (a=0; !IsEmptyStr(&buf[a]); ++a) { /* security measure */
589 if (buf[a] == '/') buf[a] = '.';
592 dirs[0] = strdup(ctdl_message_dir);
593 dirs[1] = strdup(ctdl_hlp_dir);
595 mesg_locate(targ, sizeof targ, buf, 2, (const char**)dirs);
599 if (IsEmptyStr(targ)) {
600 snprintf(targ, sizeof targ,
605 mfp = fopen(targ,"w");
607 cprintf("%d Cannot open '%s': %s\n",
608 ERROR + INTERNAL_ERROR, targ, strerror(errno));
611 cprintf("%d %s\n", SEND_LISTING, targ);
613 while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
614 fprintf(mfp, "%s\n", buf);
621 /* Don't show the names of private rooms unless the viewing
622 * user also knows the rooms.
624 void GenerateRoomDisplay(char *real_room,
625 struct CitContext *viewed,
626 struct CitContext *viewer) {
630 strcpy(real_room, viewed->room.QRname);
631 if (viewed->room.QRflags & QR_MAILBOX) {
632 strcpy(real_room, &real_room[11]);
634 if (viewed->room.QRflags & QR_PRIVATE) {
635 CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
636 if ( (ra & UA_KNOWN) == 0) {
637 strcpy(real_room, "<private room>");
641 if (viewed->cs_flags & CS_CHAT) {
642 while (strlen(real_room) < 14)
643 strcat(real_room, " ");
645 strcpy(&real_room[14], "<chat>");
651 * Convenience function.
653 int CtdlAccessCheck(int required_level) {
655 if (CC->internal_pgm) return(0);
656 if (required_level >= ac_internal) {
657 cprintf("%d This is not a user-level command.\n",
658 ERROR + HIGHER_ACCESS_REQUIRED);
662 if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
663 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
667 if (CC->user.axlevel >= 6) return(0);
668 if (required_level >= ac_aide) {
669 cprintf("%d This command requires Aide access.\n",
670 ERROR + HIGHER_ACCESS_REQUIRED);
674 if (is_room_aide()) return(0);
675 if (required_level >= ac_room_aide) {
676 cprintf("%d This command requires Aide or Room Aide access.\n",
677 ERROR + HIGHER_ACCESS_REQUIRED);
681 /* shhh ... succeed quietly */
688 * Terminate another running session
690 void cmd_term(char *cmdbuf)
693 struct CitContext *ccptr;
697 session_num = extract_int(cmdbuf, 0);
698 if (session_num == CC->cs_pid) {
699 cprintf("%d You can't kill your own session.\n", ERROR + ILLEGAL_VALUE);
703 lprintf(CTDL_DEBUG, "Locating session to kill\n");
704 begin_critical_section(S_SESSION_TABLE);
705 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
706 if (session_num == ccptr->cs_pid) {
708 if ((ccptr->user.usernum == CC->user.usernum)
709 || (CC->user.axlevel >= 6)) {
718 end_critical_section(S_SESSION_TABLE);
722 cprintf("%d Session terminated.\n", CIT_OK);
725 cprintf("%d You are not allowed to do that.\n",
726 ERROR + HIGHER_ACCESS_REQUIRED);
730 cprintf("%d No such session.\n", ERROR + ILLEGAL_VALUE);
739 * get the paginator prompt
741 void cmd_more(void) {
742 cprintf("%d %s\n", CIT_OK, config.c_moreprompt);
748 void cmd_echo(char *etext)
750 cprintf("%d %s\n", CIT_OK, etext);
756 * identify as internal program
758 void cmd_ipgm(char *argbuf)
762 secret = extract_int(argbuf, 0);
764 /* For security reasons, we do NOT allow this command to run
765 * over the network. Local sockets only.
767 if (!CC->is_local_socket) {
769 cprintf("%d Authentication failed.\n",
770 ERROR + PASSWORD_REQUIRED);
772 else if (secret == config.c_ipgm_secret) {
773 CC->internal_pgm = 1;
774 strcpy(CC->curr_user, "<internal program>");
775 CC->cs_flags = CC->cs_flags|CS_STEALTH;
776 cprintf("%d Authenticated as an internal program.\n", CIT_OK);
780 cprintf("%d Authentication failed.\n",
781 ERROR + PASSWORD_REQUIRED);
782 lprintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
786 /* Now change the ipgm secret for the next round.
787 * (Disabled because it breaks concurrent scripts. The fact that
788 * we no longer accept IPGM over the network should be sufficient
789 * to prevent brute-force attacks. If you don't agree, uncomment
792 config.c_ipgm_secret = rand();
799 * Shut down the server
801 void cmd_down(char *argbuf) {
802 char *Reply ="%d Shutting down server. Goodbye.\n";
804 if (CtdlAccessCheck(ac_aide)) return;
806 if (!IsEmptyStr(argbuf))
809 restart_server = extract_int(argbuf, 0);
811 if (restart_server > 0)
812 Reply = "%d Restarting server. See you soon.\n";
813 if ((restart_server > 0) && !running_as_daemon)
815 lprintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
816 Reply = "%d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
819 cprintf(Reply, state);
823 cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN);
829 * Halt the server without exiting the server process.
831 void cmd_halt(void) {
833 if (CtdlAccessCheck(ac_aide)) return;
835 cprintf("%d Halting server. Goodbye.\n", CIT_OK);
837 shutdown_and_halt = 1;
841 * Schedule or cancel a server shutdown
843 void cmd_scdn(char *argbuf)
847 char *Reply = "%d %d\n";
849 if (CtdlAccessCheck(ac_aide)) return;
851 new_state = extract_int(argbuf, 0);
852 if ((new_state == 2) || (new_state == 3))
855 if (!running_as_daemon)
857 lprintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
858 Reply = "%d %d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
862 restart_server = extract_int(argbuf, 0);
865 if ((new_state == 0) || (new_state == 1)) {
866 ScheduledShutdown = new_state;
868 cprintf(Reply, state, ScheduledShutdown);
873 * Set or unset asynchronous protocol mode
875 void cmd_asyn(char *argbuf)
879 new_state = extract_int(argbuf, 0);
880 if ((new_state == 0) || (new_state == 1)) {
881 CC->is_async = new_state;
883 cprintf("%d %d\n", CIT_OK, CC->is_async);
888 * Generate a "nonce" for APOP-style authentication.
890 * RFC 1725 et al specify a PID to be placed in front of the nonce.
891 * Quoth BTX: That would be stupid.
893 void generate_nonce(struct CitContext *con) {
896 memset(con->cs_nonce, NONCE_SIZE, 0);
897 gettimeofday(&tv, NULL);
898 memset(con->cs_nonce, NONCE_SIZE, 0);
899 snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
900 rand(), (long)tv.tv_usec, config.c_fqdn);
907 * Back-end function for starting a session
909 void begin_session(struct CitContext *con)
912 struct sockaddr_in sin;
915 * Initialize some variables specific to our context.
918 con->internal_pgm = 0;
919 con->download_fp = NULL;
920 con->upload_fp = NULL;
921 con->FirstExpressMessage = NULL;
923 time(&con->lastidle);
924 strcpy(con->lastcmdname, " ");
925 strcpy(con->cs_clientname, "(unknown)");
926 strcpy(con->curr_user, NLI);
927 *con->net_node = '\0';
928 *con->fake_username = '\0';
929 *con->fake_hostname = '\0';
930 *con->fake_roomname = '\0';
932 safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
933 safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
934 con->cs_host[sizeof con->cs_host - 1] = 0;
936 if (!CC->is_local_socket) {
937 if (!getpeername(con->client_socket, (struct sockaddr *) &sin, &len)) {
938 locate_host(con->cs_host, sizeof con->cs_host,
939 con->cs_addr, sizeof con->cs_addr,
945 strcpy(con->cs_host, "");
948 con->upload_type = UPL_FILE;
952 if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions)) {
956 lprintf(CTDL_NOTICE, "Session started.\n");
958 /* Run any session startup routines registered by loadable modules */
959 PerformSessionHooks(EVT_START);
963 void citproto_begin_session() {
964 if (CC->nologin==1) {
965 cprintf("%d %s: Too many users are already online (maximum is %d)\n",
966 ERROR + MAX_SESSIONS_EXCEEDED,
967 config.c_nodename, config.c_maxsessions
972 cprintf("%d %s Citadel server ready.\n",
973 CIT_OK, config.c_nodename);
981 * This loop recognizes all server commands.
983 void do_command_loop(void) {
987 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
988 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
989 lprintf(CTDL_ERR, "Client disconnected: ending session.\n");
994 /* Log the server command, but don't show passwords... */
995 if ( (strncasecmp(cmdbuf, "PASS", 4))
996 && (strncasecmp(cmdbuf, "SETP", 4)) ) {
997 lprintf(CTDL_INFO, "%s\n", cmdbuf);
1000 lprintf(CTDL_INFO, "<password command sent>\n");
1006 * Let other clients see the last command we executed, and
1007 * update the idle time, but not NOOP, QNOP, PEXP, GEXP, RWHO, or TIME.
1009 if ( (strncasecmp(cmdbuf, "NOOP", 4))
1010 && (strncasecmp(cmdbuf, "QNOP", 4))
1011 && (strncasecmp(cmdbuf, "PEXP", 4))
1012 && (strncasecmp(cmdbuf, "GEXP", 4))
1013 && (strncasecmp(cmdbuf, "RWHO", 4))
1014 && (strncasecmp(cmdbuf, "TIME", 4)) ) {
1015 strcpy(CC->lastcmdname, " ");
1016 safestrncpy(CC->lastcmdname, cmdbuf, sizeof(CC->lastcmdname));
1017 time(&CC->lastidle);
1020 if ((strncasecmp(cmdbuf, "ENT0", 4))
1021 && (strncasecmp(cmdbuf, "MESG", 4))
1022 && (strncasecmp(cmdbuf, "MSGS", 4)))
1024 CC->cs_flags &= ~CS_POSTING;
1027 if (!strncasecmp(cmdbuf, "NOOP", 4)) {
1028 cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
1031 else if (!strncasecmp(cmdbuf, "QNOP", 4)) {
1032 /* do nothing, this command returns no response */
1035 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
1036 cprintf("%d Goodbye.\n", CIT_OK);
1040 else if (!strncasecmp(cmdbuf,"ASYN",4)) {
1041 cmd_asyn(&cmdbuf[5]);
1044 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
1045 if (CC->logged_in) logout(CC);
1046 cprintf("%d logged out.\n", CIT_OK);
1049 else if (!strncasecmp(cmdbuf,"USER",4)) {
1050 cmd_user(&cmdbuf[5]);
1053 else if (!strncasecmp(cmdbuf,"PASS",4)) {
1054 cmd_pass(&cmdbuf[5]);
1057 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
1058 cmd_newu(&cmdbuf[5]);
1061 else if (!strncasecmp(cmdbuf,"CREU",4)) {
1062 cmd_creu(&cmdbuf[5]);
1065 else if (!strncasecmp(cmdbuf,"SETP",4)) {
1066 cmd_setp(&cmdbuf[5]);
1069 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
1070 cmd_lrms(&cmdbuf[5]);
1073 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
1074 cmd_lkra(&cmdbuf[5]);
1077 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
1078 cmd_lkrn(&cmdbuf[5]);
1081 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
1082 cmd_lkro(&cmdbuf[5]);
1085 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
1086 cmd_lzrm(&cmdbuf[5]);
1089 else if (!strncasecmp(cmdbuf,"LPRM",4)) {
1090 cmd_lprm(&cmdbuf[5]);
1093 else if (!strncasecmp(cmdbuf,"GETU",4)) {
1097 else if (!strncasecmp(cmdbuf,"SETU",4)) {
1098 cmd_setu(&cmdbuf[5]);
1101 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
1102 cmd_goto(&cmdbuf[5]);
1105 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
1106 cmd_msgs(&cmdbuf[5]);
1109 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
1113 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
1117 else if (!strncasecmp(cmdbuf,"EUID",4)) {
1118 cmd_euid(&cmdbuf[5]);
1121 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
1122 cmd_msg0(&cmdbuf[5]);
1125 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
1126 cmd_msg2(&cmdbuf[5]);
1129 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
1130 cmd_msg3(&cmdbuf[5]);
1133 else if (!strncasecmp(cmdbuf,"MSG4",4)) {
1134 cmd_msg4(&cmdbuf[5]);
1137 else if (!strncasecmp(cmdbuf,"MSGP",4)) {
1138 cmd_msgp(&cmdbuf[5]);
1141 else if (!strncasecmp(cmdbuf,"OPNA",4)) {
1142 cmd_opna(&cmdbuf[5]);
1145 else if (!strncasecmp(cmdbuf,"DLAT",4)) {
1146 cmd_dlat(&cmdbuf[5]);
1149 else if (!strncasecmp(cmdbuf,"INFO",4)) {
1153 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
1154 cmd_slrp(&cmdbuf[5]);
1157 else if (!strncasecmp(cmdbuf,"INVT",4)) {
1158 cmd_invt_kick(&cmdbuf[5],1);
1161 else if (!strncasecmp(cmdbuf,"KICK",4)) {
1162 cmd_invt_kick(&cmdbuf[5],0);
1165 else if (!strncasecmp(cmdbuf,"GETR",4)) {
1169 else if (!strncasecmp(cmdbuf,"SETR",4)) {
1170 cmd_setr(&cmdbuf[5]);
1173 else if (!strncasecmp(cmdbuf,"GETA",4)) {
1177 else if (!strncasecmp(cmdbuf,"SETA",4)) {
1178 cmd_seta(&cmdbuf[5]);
1181 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
1182 cmd_ent0(&cmdbuf[5]);
1185 else if (!strncasecmp(cmdbuf,"RINF",4)) {
1189 else if (!strncasecmp(cmdbuf,"DELE",4)) {
1190 cmd_dele(&cmdbuf[5]);
1193 else if (!strncasecmp(cmdbuf,"KILL",4)) {
1194 cmd_kill(&cmdbuf[5]);
1197 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
1198 cmd_cre8(&cmdbuf[5]);
1201 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
1202 cmd_move(&cmdbuf[5]);
1205 else if (!strncasecmp(cmdbuf,"FORG",4)) {
1209 else if (!strncasecmp(cmdbuf,"MESG",4)) {
1210 cmd_mesg(&cmdbuf[5]);
1213 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
1214 cmd_emsg(&cmdbuf[5]);
1217 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
1221 else if (!strncasecmp(cmdbuf,"VALI",4)) {
1222 cmd_vali(&cmdbuf[5]);
1225 else if (!strncasecmp(cmdbuf,"EINF",4)) {
1226 cmd_einf(&cmdbuf[5]);
1229 else if (!strncasecmp(cmdbuf,"LIST",4)) {
1230 cmd_list(&cmdbuf[5]);
1233 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
1237 else if (!strncasecmp(cmdbuf,"DELF",4)) {
1238 cmd_delf(&cmdbuf[5]);
1241 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
1242 cmd_movf(&cmdbuf[5]);
1245 else if (!strncasecmp(cmdbuf,"NETF",4)) {
1246 cmd_netf(&cmdbuf[5]);
1249 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
1250 cmd_open(&cmdbuf[5]);
1253 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
1257 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
1258 cmd_uopn(&cmdbuf[5]);
1261 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
1262 cmd_ucls(&cmdbuf[5]);
1265 else if (!strncasecmp(cmdbuf,"READ",4)) {
1266 cmd_read(&cmdbuf[5]);
1269 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
1270 cmd_writ(&cmdbuf[5]);
1273 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
1274 cmd_qusr(&cmdbuf[5]);
1277 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
1278 cmd_echo(&cmdbuf[5]);
1281 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
1282 cmd_oimg(&cmdbuf[5]);
1285 else if (!strncasecmp(cmdbuf,"MORE",4)) {
1289 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
1290 cmd_ndop(&cmdbuf[5]);
1293 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
1294 cmd_nuop(&cmdbuf[5]);
1297 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
1301 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
1302 cmd_cflr(&cmdbuf[5]);
1305 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
1306 cmd_kflr(&cmdbuf[5]);
1309 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
1310 cmd_eflr(&cmdbuf[5]);
1313 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
1314 cmd_iden(&cmdbuf[5]);
1317 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1318 cmd_ipgm(&cmdbuf[5]);
1321 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1322 cmd_term(&cmdbuf[5]);
1325 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1326 cmd_down(&cmdbuf[5]);
1329 else if (!strncasecmp(cmdbuf,"HALT",4)) {
1333 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1334 cmd_scdn(&cmdbuf[5]);
1337 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1338 cmd_uimg(&cmdbuf[5]);
1341 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1345 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1346 cmd_agup(&cmdbuf[5]);
1349 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1350 cmd_asup(&cmdbuf[5]);
1353 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1354 cmd_gpex(&cmdbuf[5]);
1357 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1358 cmd_spex(&cmdbuf[5]);
1361 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1362 cmd_conf(&cmdbuf[5]);
1365 else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
1366 cmd_seen(&cmdbuf[5]);
1369 else if (!strncasecmp(cmdbuf, "GTSN", 4)) {
1370 cmd_gtsn(&cmdbuf[5]);
1373 else if (!strncasecmp(cmdbuf, "VIEW", 4)) {
1374 cmd_view(&cmdbuf[5]);
1377 else if (!strncasecmp(cmdbuf, "ISME", 4)) {
1378 cmd_isme(&cmdbuf[5]);
1381 else if (!DLoader_Exec_Cmd(cmdbuf)) {
1382 cprintf("%d Unrecognized or unsupported command.\n",
1383 ERROR + CMD_NOT_SUPPORTED);
1388 /* Run any after-each-command routines registered by modules */
1389 PerformSessionHooks(EVT_CMD);
1394 * This loop performs all asynchronous functions.
1396 void do_async_loop(void) {
1397 PerformSessionHooks(EVT_ASYNC);