4 * Main source module for the client program.
15 #if TIME_WITH_SYS_TIME
16 # include <sys/time.h>
20 # include <sys/time.h>
27 #include <sys/types.h>
30 #include <sys/ioctl.h>
38 #include "serv_info.h"
40 #include "routines2.h"
45 #include "citadel_ipc.h"
46 #include "client_chat.h"
47 #include "client_passwords.h"
48 #include "citadel_decls.h"
51 #include "client_crypto.h"
59 #define IFEXPERT if (userflags&US_EXPERT)
60 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
61 #define IFAIDE if (axlevel>=6)
62 #define IFNAIDE if (axlevel<6)
64 struct march *march = NULL;
66 /* globals associated with the client program */
67 char temp[PATH_MAX]; /* Name of general temp file */
68 char temp2[PATH_MAX]; /* Name of general temp file */
69 char tempdir[PATH_MAX]; /* Name of general temp dir */
70 char editor_path[SIZ]; /* path to external editor */
71 char printcmd[SIZ]; /* print command */
72 int editor_pid = (-1);
75 struct CtdlServInfo serv_info; /* Info on the server connected */
79 char room_name[ROOMNAMELEN];
80 char *uglist[UGLISTLEN]; /* size of the ungoto list */
81 long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
83 char is_mail = 0; /* nonzero when we're in a mail room */
84 char axlevel = 0; /* access level */
85 char is_room_aide = 0; /* boolean flag, 1 if room aide */
89 long usernum = 0L; /* user number */
90 time_t lastcall = 0L; /* Date/time of previous login */
92 long highest_msg_read; /* used for <A>bandon room cmd */
93 long maxmsgnum; /* used for <G>oto */
95 char have_xterm = 0; /* are we running on an xterm? */
102 char curr_floor = 0; /* number of current floor */
103 char floorlist[128][SIZ]; /* names of floors */
104 char express_msgs = 0; /* express messages waiting! */
105 int termn8 = 0; /* Set to nonzero to cause a logoff */
106 int secure; /* Set to nonzero when wire is encrypted */
108 extern int rc_ansi_color; /* ansi color value from citadel.rc */
109 extern int next_lazy_cmd;
112 * here is our 'clean up gracefully and exit' routine
114 void logoff(int code)
117 if (editor_pid > 0) { /* kill the editor if it's running */
118 kill(editor_pid, SIGHUP);
121 /* Free the ungoto list */
122 for (lp = 0; lp < uglistsize; lp++)
125 /* shut down the server... but not if the logoff code is 3, because
126 * that means we're exiting because we already lost the server
132 * now clean up various things
141 /* Violently kill off any child processes if Citadel is
144 if (getppid() == 1) {
145 kill(0 - getpgrp(), SIGTERM);
147 kill(0 - getpgrp(), SIGKILL);
149 sttybbs(SB_RESTORE); /* return the old terminal settings */
150 exit(code); /* exit with the proper exit code */
156 * signal catching function for hangups...
158 void dropcarr(int signum)
166 * catch SIGCONT to reset terminal modes when were are put back into the
169 void catch_sigcont(int signum)
172 signal(SIGCONT, catch_sigcont);
177 /* general purpose routines */
179 void formout(char *name)
181 int r; /* IPC return code */
185 r = CtdlIPCSystemMessage(name, &text, buf);
187 scr_printf("%s\n", buf);
191 fmout(screenwidth, NULL, text, NULL,
192 ((userflags & US_PAGINATOR) ? 1 : 0),
199 void userlist(char *patn)
209 pprintf("%s\n", &buf[4]);
212 pprintf(" User Name Num L LastCall Calls Posts\n");
213 pprintf("------------------------- ----- - ---------- ----- -----\n");
214 while (serv_gets(buf), strcmp(buf, "000")) {
215 if (sigcaught == 0) {
217 if (pattern(fl, patn) >= 0) {
218 pprintf("%-25s ", fl);
219 pprintf("%5ld %d ", extract_long(buf, 2),
220 extract_int(buf, 1));
221 lc = extract_long(buf, 3);
222 tmbuf = (struct tm *) localtime(&lc);
223 pprintf("%02d/%02d/%04d ",
226 (tmbuf->tm_year + 1900));
227 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
237 * grab assorted info about the user...
239 void load_user_info(char *params)
241 extract(fullname, params, 0);
242 axlevel = extract_int(params, 1);
243 timescalled = extract_int(params, 2);
244 posted = extract_int(params, 3);
245 userflags = extract_int(params, 4);
246 usernum = extract_long(params, 5);
247 lastcall = extract_long(params, 6);
252 * Remove a room from the march list. 'floornum' is ignored unless
253 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
254 * floor will be removed from the march list.
256 void remove_march(char *roomname, int floornum)
258 struct march *mptr, *mptr2;
263 if ((!strcasecmp(march->march_name, roomname))
264 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
271 for (mptr = march; mptr != NULL; mptr = mptr->next) {
273 if ((!strcasecmp(mptr->march_name, roomname))
274 || ((!strcasecmp(roomname, "_FLOOR_"))
275 && (mptr->march_floor == floornum))) {
277 mptr2->next = mptr->next;
288 * Locate the room on the march list which we most want to go to. Each room
289 * is measured given a "weight" of preference based on various factors.
291 char *pop_march(int desired_floor)
293 static char TheRoom[ROOMNAMELEN];
295 int TheOrder = 32767;
298 struct march *mptr = NULL;
300 strcpy(TheRoom, "_BASEROOM_");
304 for (mptr = march; mptr != NULL; mptr = mptr->next) {
306 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
307 weight = weight + 10000;
308 if (mptr->march_floor == desired_floor)
309 weight = weight + 5000;
311 weight = weight + ((128 - (mptr->march_floor)) * 128);
312 weight = weight + (128 - (mptr->march_order));
314 if (weight > TheWeight) {
316 strcpy(TheRoom, mptr->march_name);
317 TheFloor = mptr->march_floor;
318 TheOrder = mptr->march_order;
326 * jump directly to a room
328 void dotgoto(char *towhere, int display_name, int fromungoto)
330 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
332 int newmailcount = 0;
333 static int oldmailcount = (-1);
334 int partial_match, best_match;
336 int ugpos = uglistsize;
337 int r; /* IPC result code */
338 struct ctdlipcroom *roomrec = NULL;
340 /* store ungoto information */
341 if (fromungoto == 0) {
342 /* sloppy slide them all down, hey it's the client, who cares. :-) */
343 if (uglistsize >= (UGLISTLEN-1)) {
346 for (lp = 0; lp < (UGLISTLEN-1); lp++) {
347 uglist[lp] = uglist[lp+1];
348 uglistlsn[lp] = uglistlsn[lp+1];
354 uglist[ugpos] = malloc(strlen(room_name)+1);
355 strcpy(uglist[ugpos], room_name);
356 uglistlsn[ugpos] = ls;
359 /* first try an exact match */
360 r = CtdlIPCGotoRoom(towhere, "", &roomrec, aaa);
362 newprompt("Enter room password: ", bbb, 9);
363 r = CtdlIPCGotoRoom(towhere, bbb, &roomrec, aaa);
365 scr_printf("Wrong password.\n");
370 * If a match is not found, try a partial match.
371 * Partial matches anywhere in the string carry a weight of 1,
372 * left-aligned matches carry a weight of 2. Pick the room that
373 * has the highest-weighted match.
381 while (serv_gets(aaa), strcmp(aaa, "000")) {
382 extract(psearch, aaa, 0);
384 if (pattern(psearch, towhere) >= 0) {
387 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
390 if (partial_match > best_match) {
391 strcpy(bbb, psearch);
392 best_match = partial_match;
395 if (strlen(bbb) == 0) {
396 scr_printf("No room '%s'.\n", towhere);
399 r = CtdlIPCGotoRoom(bbb, "", &roomrec, aaa);
402 scr_printf("%s\n", aaa);
405 safestrncpy(room_name, roomrec->RRname, ROOMNAMELEN);
406 room_flags = roomrec->RRflags;
407 from_floor = curr_floor;
408 curr_floor = roomrec->RRfloor;
410 remove_march(room_name, 0);
411 if (!strcasecmp(towhere, "_BASEROOM_"))
412 remove_march(towhere, 0);
413 if (!roomrec->RRunread)
414 next_lazy_cmd = 5; /* Don't read new if no new msgs */
415 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
416 if (floorlist[(int) curr_floor][0] == 0)
418 scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
420 if (display_name == 1) {
422 scr_printf("%s ", room_name);
426 if (display_name != 2) {
427 color(BRIGHT_YELLOW);
428 scr_printf("%d ", roomrec->RRunread);
430 scr_printf("new of ");
431 color(BRIGHT_YELLOW);
432 scr_printf("%d ", roomrec->RRtotal);
434 scr_printf("messages.\n");
436 highest_msg_read = roomrec->RRlastread;
437 maxmsgnum = roomrec->RRhighest;
438 is_mail = roomrec->RRismailbox;
439 is_room_aide = roomrec->RRaide;
440 ls = roomrec->RRlastread;
442 /* read info file if necessary */
443 if (roomrec->RRinfoupdated > 0)
446 /* check for newly arrived mail if we can */
447 newmailcount = roomrec->RRnewmail;
448 if (newmailcount > 0) {
450 scr_printf("*** You have %d new mail message%s\n",
451 newmailcount - oldmailcount,
452 (newmailcount - oldmailcount == 1) ?
456 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
457 room_name, secure, newmailcount);
460 /* Goto next room having unread messages.
461 * We want to skip over rooms that the user has already been to, and take the
462 * user back to the lobby when done. The room we end up in is placed in
463 * newroom - which is set to 0 (the lobby) initially.
468 struct march *mptr, *mptr2;
469 char next_room[ROOMNAMELEN];
470 int r; /* IPC response code */
472 /* Check to see if the march-mode list is already allocated.
473 * If it is, pop the first room off the list and go there.
476 r = CtdlIPCKnownRooms(1, -1, &march, buf);
477 /* add _BASEROOM_ to the end of the march list, so the user will end up
478 * in the system base room (usually the Lobby>) at the end of the loop
480 mptr = (struct march *) malloc(sizeof(struct march));
482 strcpy(mptr->march_name, "_BASEROOM_");
487 while (mptr2->next != NULL)
492 * ...and remove the room we're currently in, so a <G>oto doesn't make us
493 * walk around in circles
495 remove_march(room_name, 0);
498 strcpy(next_room, pop_march(curr_floor));
500 strcpy(next_room, "_BASEROOM_");
502 remove_march(next_room, 0);
503 dotgoto(next_room, 1, 0);
507 * forget all rooms on a given floor
509 void forget_all_rooms_on(int ffloor)
512 struct march *flist, *fptr;
514 scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
516 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
520 scr_printf("%-72s\n", &buf[4]);
524 while (serv_gets(buf), strcmp(buf, "000")) {
525 fptr = (struct march *) malloc(sizeof(struct march));
528 extract(fptr->march_name, buf, 0);
530 while (flist != NULL) {
531 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
542 scr_printf("%-72s\r", "");
547 * routine called by gotofloor() to move to a new room on a new floor
549 void gf_toroom(char *towhere, int mode)
551 int floor_being_left;
553 floor_being_left = curr_floor;
555 if (mode == GF_GOTO) { /* <;G>oto mode */
557 dotgoto(towhere, 1, 0);
559 if (mode == GF_SKIP) { /* <;S>kip mode */
560 dotgoto(towhere, 1, 0);
561 remove_march("_FLOOR_", floor_being_left);
563 if (mode == GF_ZAP) { /* <;Z>ap mode */
564 dotgoto(towhere, 1, 0);
565 remove_march("_FLOOR_", floor_being_left);
566 forget_all_rooms_on(floor_being_left);
574 void gotofloor(char *towhere, int mode)
578 char buf[SIZ], targ[SIZ];
580 if (floorlist[0][0] == 0)
583 for (a = 0; a < 128; ++a)
584 if (!strcasecmp(&floorlist[a][0], towhere))
588 for (a = 0; a < 128; ++a) {
589 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
595 for (a = 0; a < 128; ++a)
596 if (pattern(towhere, &floorlist[a][0]) > 0)
600 scr_printf("No floor '%s'.\n", towhere);
603 for (mptr = march; mptr != NULL; mptr = mptr->next) {
604 if ((mptr->march_floor) == tofloor)
605 gf_toroom(mptr->march_name, mode);
610 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
614 while (serv_gets(buf), strcmp(buf, "000")) {
615 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
616 extract(targ, buf, 0);
618 if (strlen(targ) > 0) {
619 gf_toroom(targ, mode);
621 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
627 * forget all rooms on current floor
629 void forget_this_floor(void)
632 if (curr_floor == 0) {
633 scr_printf("Can't forget this floor.\n");
636 if (floorlist[0][0] == 0)
638 scr_printf("Are you sure you want to forget all rooms on %s? ",
639 &floorlist[(int) curr_floor][0]);
643 gf_toroom("_BASEROOM_", GF_ZAP);
648 * Figure out the physical screen dimensions, if we can
649 * WARNING: this is now called from a signal handler!
651 void check_screen_dims(void)
655 unsigned short height; /* rows */
656 unsigned short width; /* columns */
657 unsigned short xpixels;
658 unsigned short ypixels; /* pixels */
661 if (have_xterm) { /* dynamically size screen if on an xterm */
662 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
664 screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
666 screenwidth = (int) xwinsz.width;
674 * set floor mode depending on client, server, and user settings
676 void set_floor_mode(void)
678 if (serv_info.serv_ok_floors == 0) {
679 floor_mode = 0; /* Don't use floors if the server */
681 /* doesn't support them! */
683 if (rc_floor_mode == RC_NO) { /* never use floors */
686 if (rc_floor_mode == RC_YES) { /* always use floors */
689 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
690 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
696 * Set or change the user's password
698 int set_password(void)
704 if (strlen(rc_password) > 0) {
705 strcpy(pass1, rc_password);
706 strcpy(pass2, rc_password);
708 IFNEXPERT formout("changepw");
709 newprompt("Enter a new password: ", pass1, -19);
710 newprompt("Enter it again to confirm: ", pass2, -19);
714 if (!strcasecmp(pass1, pass2)) {
715 CtdlIPCChangePassword(pass1, buf);
716 scr_printf("%s\n", buf);
717 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
720 scr_printf("*** They don't match... try again.\n");
728 * get info about the server we've connected to
730 void get_serv_info(char *supplied_hostname)
734 CtdlInternalGetServInfo(&serv_info);
736 /* be nice and identify ourself to the server */
737 CtdlIPCIdentifySoftware(SERVER_TYPE, 0, REV_LEVEL,
738 (server_is_local ? "local" : CITADEL),
739 (supplied_hostname) ? supplied_hostname : "", buf);
740 /* (locate_host(buf), buf)); */
748 * Display list of users currently logged on to the server
750 void who_is_online(int longlist)
752 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
754 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
755 char tbuf[SIZ], clientsoft[SIZ];
757 time_t idletime, idlehours, idlemins, idlesecs;
758 int last_session = (-1);
766 if (!(timenow = CtdlIPCServerTime(tbuf))) {
772 pprintf("FLG ### User Name Room From host\n");
774 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
779 while (serv_gets(buf), strcmp(buf, "000")) {
781 extract(username, buf, 1);
782 extract(roomname, buf, 2);
783 extract(fromhost, buf, 3);
784 extract(clientsoft, buf, 4);
785 extract(flags, buf, 7);
787 idletime = timenow - extract_long(buf, 5);
788 idlehours = idletime / 3600;
789 idlemins = (idletime - (idlehours * 3600)) / 60;
790 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
792 if (idletime > rc_idle_threshold) {
793 while (strlen(roomname) < 20) {
794 strcat(roomname, " ");
796 strcpy(&roomname[14], "[idle]");
803 extract(actual_user, buf, 8);
804 extract(actual_room, buf, 9);
805 extract(actual_host, buf, 10);
807 pprintf(" Flags: %s\n", flags);
808 pprintf("Session: %d\n", extract_int(buf, 0));
809 pprintf(" Name: %s\n", username);
810 pprintf("In room: %s\n", roomname);
811 pprintf(" Host: %s\n", fromhost);
812 pprintf(" Client: %s\n", clientsoft);
813 pprintf(" Idle: %ld:%02ld:%02ld\n",
818 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
820 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
821 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
822 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
829 if (extract_int(buf, 0) == last_session) {
832 color(BRIGHT_MAGENTA);
833 pprintf("%-3s ", flags);
835 pprintf("%-3d ", extract_int(buf, 0));
837 last_session = extract_int(buf, 0);
839 pprintf("%-25s ", username);
840 color(BRIGHT_MAGENTA);
842 pprintf("%-20s ", roomname);
845 pprintf("%-24s\n", fromhost);
853 void enternew(char *desc, char *buf, int maxlen)
856 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
857 newprompt(bbb, buf, maxlen);
862 int shift(int argc, char **argv, int start, int count) {
865 for (i=start; i<(argc-count); ++i) {
866 argv[i] = argv[i+count];
872 static void statusHook(char *s) {
880 int main(int argc, char **argv)
883 char aaa[100], bbb[100];/* general purpose variables */
884 char argbuf[32]; /* command line buf */
885 char nonce[NONCE_SIZE];
886 char *telnet_client_host = NULL;
887 char *sptr, *sptr2; /* USed to extract the nonce */
888 char hexstring[MD5_HEXSTRING_SIZE];
889 int stored_password = 0;
891 struct ctdlipcmisc chek;
892 struct usersupp *myself = NULL;
893 int r; /* IPC result code */
895 setIPCDeathHook(screen_delete);
896 setIPCErrorPrintf(err_printf);
897 setCryptoStatusHook(statusHook);
899 /* Permissions sanity check - don't run citadel setuid/setgid */
900 if (getuid() != geteuid()) {
901 err_printf("Please do not run citadel setuid!\n");
903 } else if (getgid() != getegid()) {
904 err_printf("Please do not run citadel setgid!\n");
908 sttybbs(SB_SAVE); /* Store the old terminal parameters */
909 load_command_set(); /* parse the citadel.rc file */
910 sttybbs(SB_NO_INTR); /* Install the new ones */
911 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
912 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
913 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
915 signal(SIGWINCH, scr_winch); /* Window resize signal */
919 arg_encrypt = RC_DEFAULT;
922 arg_screen = RC_DEFAULT;
926 * Handle command line options as if we were called like /bin/login
927 * (i.e. from in.telnetd)
929 for (a=0; a<argc; ++a) {
930 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
931 telnet_client_host = argv[a+1];
932 argc = shift(argc, argv, a, 2);
934 if (!strcmp(argv[a], "-x")) {
938 argc = shift(argc, argv, a, 1);
940 if (!strcmp(argv[a], "-X")) {
942 arg_encrypt = RC_YES;
943 argc = shift(argc, argv, a, 1);
945 fprintf(stderr, "Not compiled with encryption support");
949 if (!strcmp(argv[a], "-s")) {
953 argc = shift(argc, argv, a, 1);
955 if (!strcmp(argv[a], "-S")) {
959 argc = shift(argc, argv, a, 1);
961 if (!strcmp(argv[a], "-p")) {
964 if (chdir(BBSDIR) < 0) {
965 perror("can't change to " BBSDIR);
970 * Drop privileges if necessary. We stat
971 * citadel.config to get the uid/gid since it's
972 * guaranteed to have the uid/gid we want.
974 if (!getuid() || !getgid()) {
975 if (stat(BBSDIR "/citadel.config", &st) < 0) {
976 perror("couldn't stat citadel.config");
979 if (!getgid() && (setgid(st.st_gid) < 0)) {
980 perror("couldn't change gid");
983 if (!getuid() && (setuid(st.st_uid) < 0)) {
984 perror("couldn't change uid");
988 scr_printf("Privileges changed to uid %d gid %d\n",
992 argc = shift(argc, argv, a, 1);
998 sln_printf("Attaching to server... \r");
1000 attach_to_server(argc, argv, hostbuf, portbuf);
1003 if (aaa[0] != '2') {
1004 scr_printf("%s\n", &aaa[4]);
1008 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
1012 if ((sptr = strchr(aaa, '<')) == NULL)
1018 if ((sptr2 = strchr(sptr, '>')) == NULL)
1026 strncpy(nonce, sptr, NONCE_SIZE);
1030 get_serv_info(telnet_client_host);
1032 scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1033 serv_info.serv_bbs_city);
1036 secure = starttls();
1037 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city, NULL,
1040 screenwidth = 80; /* default screen dimensions */
1043 scr_printf(" pause next stop\n");
1044 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1045 formout("hello"); /* print the opening greeting */
1048 GSTA: /* See if we have a username and password on disk */
1049 if (rc_remember_passwords) {
1050 get_stored_password(hostbuf, portbuf, fullname, password);
1051 if (strlen(fullname) > 0) {
1052 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1057 snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
1059 else /* Else no APOP */
1061 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1066 if (aaa[0] == '2') {
1067 load_user_info(&aaa[4]);
1068 stored_password = 1;
1072 set_stored_password(hostbuf, portbuf, "", "");
1080 if (strlen(rc_username) > 0) {
1081 strcpy(fullname, rc_username);
1083 newprompt("Enter your name: ", fullname, 29);
1086 if (!strcasecmp(fullname, "new")) { /* just in case */
1087 scr_printf("Please enter the name you wish to log in with.\n");
1090 (!strcasecmp(fullname, "bbs"))
1091 || (!strcasecmp(fullname, "new"))
1092 || (strlen(fullname) == 0));
1094 if (!strcasecmp(fullname, "off")) {
1098 /* sign on to the server */
1099 r = CtdlIPCTryLogin(fullname, aaa);
1103 /* password authentication */
1104 if (strlen(rc_password) > 0) {
1105 strcpy(password, rc_password);
1107 newprompt("\rPlease enter your password: ", password, -19);
1113 snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
1115 else /* Else no APOP */
1117 snprintf(aaa, sizeof aaa, "PASS %s", password);
1122 if (aaa[0] == '2') {
1123 load_user_info(&aaa[4]);
1124 offer_to_remember_password(hostbuf, portbuf,
1125 fullname, password);
1128 scr_printf("<< wrong password >>\n");
1129 if (strlen(rc_password) > 0)
1133 NEWUSR: if (strlen(rc_password) == 0) {
1134 scr_printf("No record. Enter as new user? ");
1138 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1141 if (aaa[0] != '2') {
1142 scr_printf("%s\n", aaa);
1145 load_user_info(&aaa[4]);
1147 while (set_password() != 0);;
1153 /* Switch color support on or off if we're in user mode */
1154 if (rc_ansi_color == 3) {
1155 if (userflags & US_COLOR)
1161 scr_printf("%s\nAccess level: %d (%s)\n"
1162 "User #%ld / Login #%d",
1163 fullname, axlevel, axdefs[(int) axlevel],
1164 usernum, timescalled);
1165 if (lastcall > 0L) {
1166 scr_printf(" / Last login: %s\n",
1167 asctime(localtime(&lastcall)) );
1171 r = CtdlIPCMiscCheck(&chek, aaa);
1177 scr_printf("*** You have a new private message in Mail>\n");
1179 scr_printf("*** You have %d new private messages in Mail>\n", b);
1182 if ((axlevel >= 6) && (chek.needvalid > 0)) {
1183 scr_printf("*** Users need validation\n");
1185 if (chek.needregis > 0) {
1186 scr_printf("*** Please register.\n");
1187 formout("register");
1191 /* Make up some temporary filenames for use in various parts of the
1192 * program. Don't mess with these once they've been set, because we
1193 * will be unlinking them later on in the program and we don't
1194 * want to delete something that we didn't create. */
1195 snprintf(temp, sizeof temp, tmpnam(NULL));
1196 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1197 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1199 /* Get screen dimensions. First we go to a default of 80x24. Then
1200 * we try to get the user's actual screen dimensions off the server.
1201 * However, if we're running on an xterm, all this stuff is
1202 * irrelevant because we're going to dynamically size the screen
1203 * during the session.
1207 r = CtdlIPCGetConfig(&myself, aaa);
1209 screenwidth = myself->USscreenwidth;
1210 screenheight = myself->USscreenheight;
1212 if (getenv("TERM") != NULL)
1213 if (!strcmp(getenv("TERM"), "xterm")) {
1217 check_screen_dims();
1223 /* Enter the lobby */
1224 dotgoto("_BASEROOM_", 1, 0);
1226 /* Main loop for the system... user is logged in. */
1234 /* MAIN COMMAND LOOP */
1236 mcmd = getcmd(argbuf); /* Get keyboard command */
1239 check_screen_dims(); /* if xterm, get screen size */
1257 newprompt("What do you want your username to be? ", aaa, 32);
1258 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1261 if (strncmp("200", aaa, 3))
1262 scr_printf("\n%s\n", aaa);
1271 if (!rc_alt_semantics)
1276 if (!rc_alt_semantics)
1278 dotgoto(argbuf, 0, 0);
1282 dotgoto("_MAIL_", 1, 0);
1286 dotgoto(argbuf, 0, 0);
1289 if (rc_alt_semantics)
1291 dotgoto(argbuf, 0, 0);
1303 readmsgs(0, (-1), 0);
1306 readmsgs(2, (-1), 0);
1309 readmsgs(3, 1, atoi(argbuf));
1382 if (!rc_alt_semantics)
1387 if (!rc_alt_semantics)
1398 cli_image_upload("_userpic_");
1401 cli_image_upload("_roompic_");
1405 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1406 cli_image_upload(aaa);
1410 enternew("roomname", aaa, 20);
1411 r = CtdlIPCChangeRoomname(aaa, bbb);
1413 scr_printf("\n%s\n", aaa);
1416 enternew("hostname", aaa, 25);
1417 r = CtdlIPCChangeHostname(aaa, bbb);
1419 scr_printf("\n%s\n", aaa);
1422 enternew("username", aaa, 32);
1423 r = CtdlIPCChangeUsername(aaa, bbb);
1425 scr_printf("\n%s\n", aaa);
1435 display_help(argbuf);
1439 formout("register");
1444 scr_printf("Are you sure (y/n)? ");
1453 scr_printf("All users will be disconnected! "
1454 "Really terminate the server? ");
1456 r = CtdlIPCTerminateServerNow(aaa);
1457 scr_printf("%s\n", aaa);
1467 scr_printf("Do you really want to schedule a "
1468 "server shutdown? ");
1470 r = CtdlIPCTerminateServerScheduled(1, aaa);
1474 "The Citadel server will terminate when all users are logged off.\n"
1478 "The Citadel server will not terminate.\n"
1486 network_config_management("listrecp",
1487 "Mailing list recipients");
1491 network_config_management("ignet_push_share",
1492 "Nodes with which we share this room");
1496 do_ignet_configuration();
1500 do_filterlist_configuration();
1504 if (rc_alt_semantics)
1514 if (server_is_local) {
1516 sttybbs(SB_RESTORE);
1517 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1518 "exec ./subsystem %ld %d %d", fullname,
1519 usernum, screenwidth, axlevel);
1521 sttybbs(SB_NO_INTR);
1524 scr_printf("*** Can't run doors when server is not local.\n");
1541 do_system_configuration();
1545 do_internet_configuration();
1549 check_message_base();
1575 gotofloor(argbuf, GF_GOTO);
1579 gotofloor(argbuf, GF_SKIP);
1583 forget_this_floor();
1611 knrooms(floor_mode);
1621 misc_server_cmd(argbuf);
1625 edit_system_message(argbuf);
1650 } while (termn8 == 0);
1652 TERMN8: scr_printf("%s logged out.\n", fullname);
1653 while (march != NULL) {
1654 remove_march(march->march_name, 0);
1657 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
1661 sttybbs(SB_RESTORE);
1662 if ((mcmd == 29) || (mcmd == 15)) {