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 "client_chat.h"
46 #include "client_passwords.h"
47 #include "citadel_decls.h"
50 #include "client_crypto.h"
60 char march_name[ROOMNAMELEN];
65 #define IFEXPERT if (userflags&US_EXPERT)
66 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
67 #define IFAIDE if (axlevel>=6)
68 #define IFNAIDE if (axlevel<6)
70 struct march *march = NULL;
72 /* globals associated with the client program */
73 char temp[PATH_MAX]; /* Name of general temp file */
74 char temp2[PATH_MAX]; /* Name of general temp file */
75 char tempdir[PATH_MAX]; /* Name of general temp dir */
76 char editor_path[SIZ]; /* path to external editor */
77 char printcmd[SIZ]; /* print command */
78 int editor_pid = (-1);
81 struct CtdlServInfo serv_info; /* Info on the server connected */
85 char room_name[ROOMNAMELEN];
86 char *uglist[UGLISTLEN]; /* size of the ungoto list */
87 long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
89 char is_mail = 0; /* nonzero when we're in a mail room */
90 char axlevel = 0; /* access level */
91 char is_room_aide = 0; /* boolean flag, 1 if room aide */
95 long usernum = 0L; /* user number */
96 time_t lastcall = 0L; /* Date/time of previous login */
98 long highest_msg_read; /* used for <A>bandon room cmd */
99 long maxmsgnum; /* used for <G>oto */
101 char have_xterm = 0; /* are we running on an xterm? */
102 char rc_username[32];
103 char rc_password[32];
108 char curr_floor = 0; /* number of current floor */
109 char floorlist[128][SIZ]; /* names of floors */
110 char express_msgs = 0; /* express messages waiting! */
111 int termn8 = 0; /* Set to nonzero to cause a logoff */
112 int secure; /* Set to nonzero when wire is encrypted */
114 extern int rc_ansi_color; /* ansi color value from citadel.rc */
117 * here is our 'clean up gracefully and exit' routine
119 void logoff(int code)
122 if (editor_pid > 0) { /* kill the editor if it's running */
123 kill(editor_pid, SIGHUP);
126 /* Free the ungoto list */
127 for (lp = 0; lp < uglistsize; lp++)
130 /* shut down the server... but not if the logoff code is 3, because
131 * that means we're exiting because we already lost the server
137 * now clean up various things
146 /* Violently kill off any child processes if Citadel is
149 if (getppid() == 1) {
150 kill(0 - getpgrp(), SIGTERM);
152 kill(0 - getpgrp(), SIGKILL);
154 sttybbs(SB_RESTORE); /* return the old terminal settings */
155 exit(code); /* exit with the proper exit code */
161 * signal catching function for hangups...
163 void dropcarr(int signum)
171 * catch SIGCONT to reset terminal modes when were are put back into the
174 void catch_sigcont(int signum)
177 signal(SIGCONT, catch_sigcont);
182 /* general purpose routines */
184 void formout(char *name)
185 { /* display a file */
187 snprintf(cmd, sizeof cmd, "MESG %s", name);
191 scr_printf("%s\n", &cmd[4]);
194 fmout(screenwidth, NULL, NULL,
195 ((userflags & US_PAGINATOR) ? 1 : 0),
200 void userlist(char *patn)
210 pprintf("%s\n", &buf[4]);
213 pprintf(" User Name Num L LastCall Calls Posts\n");
214 pprintf("------------------------- ----- - ---------- ----- -----\n");
215 while (serv_gets(buf), strcmp(buf, "000")) {
216 if (sigcaught == 0) {
218 if (pattern(fl, patn) >= 0) {
219 pprintf("%-25s ", fl);
220 pprintf("%5ld %d ", extract_long(buf, 2),
221 extract_int(buf, 1));
222 lc = extract_long(buf, 3);
223 tmbuf = (struct tm *) localtime(&lc);
224 pprintf("%02d/%02d/%04d ",
227 (tmbuf->tm_year + 1900));
228 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
238 * grab assorted info about the user...
240 void load_user_info(char *params)
242 extract(fullname, params, 0);
243 axlevel = extract_int(params, 1);
244 timescalled = extract_int(params, 2);
245 posted = extract_int(params, 3);
246 userflags = extract_int(params, 4);
247 usernum = extract_long(params, 5);
248 lastcall = extract_long(params, 6);
253 * Remove a room from the march list. 'floornum' is ignored unless
254 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
255 * floor will be removed from the march list.
257 void remove_march(char *roomname, int floornum)
259 struct march *mptr, *mptr2;
264 if ((!strcasecmp(march->march_name, roomname))
265 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
272 for (mptr = march; mptr != NULL; mptr = mptr->next) {
274 if ((!strcasecmp(mptr->march_name, roomname))
275 || ((!strcasecmp(roomname, "_FLOOR_"))
276 && (mptr->march_floor == floornum))) {
278 mptr2->next = mptr->next;
289 * Locate the room on the march list which we most want to go to. Each room
290 * is measured given a "weight" of preference based on various factors.
292 char *pop_march(int desired_floor)
294 static char TheRoom[ROOMNAMELEN];
296 int TheOrder = 32767;
299 struct march *mptr = NULL;
301 strcpy(TheRoom, "_BASEROOM_");
305 for (mptr = march; mptr != NULL; mptr = mptr->next) {
307 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
308 weight = weight + 10000;
309 if (mptr->march_floor == desired_floor)
310 weight = weight + 5000;
312 weight = weight + ((128 - (mptr->march_floor)) * 128);
313 weight = weight + (128 - (mptr->march_order));
315 if (weight > TheWeight) {
317 strcpy(TheRoom, mptr->march_name);
318 TheFloor = mptr->march_floor;
319 TheOrder = mptr->march_order;
327 * jump directly to a room
329 void dotgoto(char *towhere, int display_name, int fromungoto)
331 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
333 int newmailcount = 0;
334 static int oldmailcount = (-1);
335 int partial_match, best_match;
337 int ugpos = uglistsize;
339 /* store ungoto information */
342 if (uglistsize >= (UGLISTLEN-1))
343 { /* sloppy slide them all down, hey it's the client, who cares. :-) */
346 for (lp = 0; lp < (UGLISTLEN-1); lp++)
348 uglist[lp] = uglist[lp+1];
349 uglistlsn[lp] = uglistlsn[lp+1];
356 uglist[ugpos] = malloc(strlen(room_name)+1);
357 strcpy(uglist[ugpos], room_name);
358 uglistlsn[ugpos] = ls;
361 /* first try an exact match */
362 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
367 if (!strncmp(aaa, "54", 2)) {
368 newprompt("Enter room password: ", bbb, 9);
369 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
375 if (!strncmp(aaa, "54", 2)) {
376 scr_printf("Wrong password.\n");
380 * If a match is not found, try a partial match.
381 * Partial matches anywhere in the string carry a weight of 1,
382 * left-aligned matches carry a weight of 2. Pick the room that
383 * has the highest-weighted match.
391 while (serv_gets(aaa), strcmp(aaa, "000")) {
392 extract(psearch, aaa, 0);
394 if (pattern(psearch, towhere) >= 0) {
397 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
400 if (partial_match > best_match) {
401 strcpy(bbb, psearch);
402 best_match = partial_match;
405 if (strlen(bbb) == 0) {
406 scr_printf("No room '%s'.\n", towhere);
409 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
416 scr_printf("%s\n", aaa);
419 extract(room_name, &aaa[4], 0);
420 room_flags = extract_int(&aaa[4], 4);
421 from_floor = curr_floor;
422 curr_floor = extract_int(&aaa[4], 10);
424 remove_march(room_name, 0);
425 if (!strcasecmp(towhere, "_BASEROOM_"))
426 remove_march(towhere, 0);
427 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
428 if (floorlist[(int) curr_floor][0] == 0)
430 scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
432 if (display_name == 1) {
434 scr_printf("%s ", room_name);
438 if (display_name != 2) {
439 color(BRIGHT_YELLOW);
440 scr_printf("%d ", extract_int(&aaa[4], 1));
442 scr_printf("new of ");
443 color(BRIGHT_YELLOW);
444 scr_printf("%d ", extract_int(&aaa[4], 2));
446 scr_printf("messages.\n");
448 highest_msg_read = extract_int(&aaa[4], 6);
449 maxmsgnum = extract_int(&aaa[4], 5);
450 is_mail = (char) extract_int(&aaa[4], 7);
451 is_room_aide = (char) extract_int(&aaa[4], 8);
452 ls = extract_long(&aaa[4], 6);
454 /* read info file if necessary */
455 if (extract_int(&aaa[4], 3) > 0)
458 /* check for newly arrived mail if we can */
459 if (num_parms(&aaa[4]) >= 10) {
460 newmailcount = extract_int(&aaa[4], 9);
461 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
463 scr_printf("*** You have new mail\n");
466 oldmailcount = newmailcount;
467 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
468 room_name, secure, newmailcount);
470 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
471 room_name, secure, -1);
475 /* Goto next room having unread messages.
476 * We want to skip over rooms that the user has already been to, and take the
477 * user back to the lobby when done. The room we end up in is placed in
478 * newroom - which is set to 0 (the lobby) initially.
483 struct march *mptr, *mptr2;
484 char next_room[ROOMNAMELEN];
486 /* Check to see if the march-mode list is already allocated.
487 * If it is, pop the first room off the list and go there.
493 while (serv_gets(buf), strcmp(buf, "000")) {
494 mptr = (struct march *) malloc(sizeof(struct march));
496 extract(mptr->march_name, buf, 0);
497 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
498 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
503 while (mptr2->next != NULL)
508 /* add _BASEROOM_ to the end of the march list, so the user will end up
509 * in the system base room (usually the Lobby>) at the end of the loop
511 mptr = (struct march *) malloc(sizeof(struct march));
513 strcpy(mptr->march_name, "_BASEROOM_");
518 while (mptr2->next != NULL)
523 * ...and remove the room we're currently in, so a <G>oto doesn't make us
524 * walk around in circles
526 remove_march(room_name, 0);
529 strcpy(next_room, pop_march(curr_floor));
531 strcpy(next_room, "_BASEROOM_");
533 remove_march(next_room, 0);
534 dotgoto(next_room, 1, 0);
538 * forget all rooms on a given floor
540 void forget_all_rooms_on(int ffloor)
543 struct march *flist, *fptr;
545 scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
547 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
551 scr_printf("%-72s\n", &buf[4]);
555 while (serv_gets(buf), strcmp(buf, "000")) {
556 fptr = (struct march *) malloc(sizeof(struct march));
559 extract(fptr->march_name, buf, 0);
561 while (flist != NULL) {
562 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
573 scr_printf("%-72s\r", "");
578 * routine called by gotofloor() to move to a new room on a new floor
580 void gf_toroom(char *towhere, int mode)
582 int floor_being_left;
584 floor_being_left = curr_floor;
586 if (mode == GF_GOTO) { /* <;G>oto mode */
588 dotgoto(towhere, 1, 0);
590 if (mode == GF_SKIP) { /* <;S>kip mode */
591 dotgoto(towhere, 1, 0);
592 remove_march("_FLOOR_", floor_being_left);
594 if (mode == GF_ZAP) { /* <;Z>ap mode */
595 dotgoto(towhere, 1, 0);
596 remove_march("_FLOOR_", floor_being_left);
597 forget_all_rooms_on(floor_being_left);
605 void gotofloor(char *towhere, int mode)
609 char buf[SIZ], targ[SIZ];
611 if (floorlist[0][0] == 0)
614 for (a = 0; a < 128; ++a)
615 if (!strcasecmp(&floorlist[a][0], towhere))
619 for (a = 0; a < 128; ++a) {
620 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
626 for (a = 0; a < 128; ++a)
627 if (pattern(towhere, &floorlist[a][0]) > 0)
631 scr_printf("No floor '%s'.\n", towhere);
634 for (mptr = march; mptr != NULL; mptr = mptr->next) {
635 if ((mptr->march_floor) == tofloor)
636 gf_toroom(mptr->march_name, mode);
641 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
645 while (serv_gets(buf), strcmp(buf, "000")) {
646 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
647 extract(targ, buf, 0);
649 if (strlen(targ) > 0) {
650 gf_toroom(targ, mode);
652 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
658 * forget all rooms on current floor
660 void forget_this_floor(void)
663 if (curr_floor == 0) {
664 scr_printf("Can't forget this floor.\n");
667 if (floorlist[0][0] == 0)
669 scr_printf("Are you sure you want to forget all rooms on %s? ",
670 &floorlist[(int) curr_floor][0]);
674 gf_toroom("_BASEROOM_", GF_ZAP);
679 * Figure out the physical screen dimensions, if we can
680 * WARNING: this is now called from a signal handler!
682 void check_screen_dims(void)
686 unsigned short height; /* rows */
687 unsigned short width; /* columns */
688 unsigned short xpixels;
689 unsigned short ypixels; /* pixels */
692 if (have_xterm) { /* dynamically size screen if on an xterm */
693 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
695 screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
697 screenwidth = (int) xwinsz.width;
705 * set floor mode depending on client, server, and user settings
707 void set_floor_mode(void)
709 if (serv_info.serv_ok_floors == 0) {
710 floor_mode = 0; /* Don't use floors if the server */
712 /* doesn't support them! */
714 if (rc_floor_mode == RC_NO) { /* never use floors */
717 if (rc_floor_mode == RC_YES) { /* always use floors */
720 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
721 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
727 * Set or change the user's password
729 int set_password(void)
735 if (strlen(rc_password) > 0) {
736 strcpy(pass1, rc_password);
737 strcpy(pass2, rc_password);
739 IFNEXPERT formout("changepw");
740 newprompt("Enter a new password: ", pass1, -19);
741 newprompt("Enter it again to confirm: ", pass2, -19);
745 if (!strcasecmp(pass1, pass2)) {
746 snprintf(buf, sizeof buf, "SETP %s", pass1);
749 scr_printf("%s\n", &buf[4]);
750 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
753 scr_printf("*** They don't match... try again.\n");
761 * get info about the server we've connected to
763 void get_serv_info(char *supplied_hostname)
767 CtdlInternalGetServInfo(&serv_info);
769 /* be nice and identify ourself to the server */
770 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
771 SERVER_TYPE, 0, REV_LEVEL,
772 (server_is_local ? "local" : CITADEL));
774 /* Append a hostname */
775 if (supplied_hostname != NULL) {
776 strcat(buf, supplied_hostname);
779 locate_host(&buf[strlen(buf)]); /* append to the end */
783 serv_gets(buf); /* we don't care about the result code */
791 * Display list of users currently logged on to the server
793 void who_is_online(int longlist)
795 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
797 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
798 char tbuf[SIZ], clientsoft[SIZ];
800 time_t idletime, idlehours, idlemins, idlesecs;
801 int last_session = (-1);
812 if (tbuf[0] == '2') {
813 timenow = extract_long(&tbuf[4], 0);
821 pprintf("FLG ### User Name Room From host\n");
823 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
828 while (serv_gets(buf), strcmp(buf, "000")) {
830 extract(username, buf, 1);
831 extract(roomname, buf, 2);
832 extract(fromhost, buf, 3);
833 extract(clientsoft, buf, 4);
834 extract(flags, buf, 7);
836 idletime = timenow - extract_long(buf, 5);
837 idlehours = idletime / 3600;
838 idlemins = (idletime - (idlehours * 3600)) / 60;
839 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
841 if (idletime > 900) {
842 while (strlen(roomname) < 20) {
843 strcat(roomname, " ");
845 strcpy(&roomname[14], "[idle]");
852 extract(actual_user, buf, 8);
853 extract(actual_room, buf, 9);
854 extract(actual_host, buf, 10);
856 pprintf(" Flags: %s\n", flags);
857 pprintf("Session: %d\n", extract_int(buf, 0));
858 pprintf(" Name: %s\n", username);
859 pprintf("In room: %s\n", roomname);
860 pprintf(" Host: %s\n", fromhost);
861 pprintf(" Client: %s\n", clientsoft);
862 pprintf(" Idle: %ld:%02ld:%02ld\n",
867 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
869 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
870 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
871 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
878 if (extract_int(buf, 0) == last_session) {
881 color(BRIGHT_MAGENTA);
882 pprintf("%-3s ", flags);
884 pprintf("%-3d ", extract_int(buf, 0));
886 last_session = extract_int(buf, 0);
888 pprintf("%-25s ", username);
889 color(BRIGHT_MAGENTA);
891 pprintf("%-20s ", roomname);
894 pprintf("%-24s\n", fromhost);
902 void enternew(char *desc, char *buf, int maxlen)
905 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
906 newprompt(bbb, buf, maxlen);
911 int shift(int argc, char **argv, int start, int count) {
914 for (i=start; i<(argc-count); ++i) {
915 argv[i] = argv[i+count];
924 int main(int argc, char **argv)
927 char aaa[100], bbb[100];/* general purpose variables */
928 char argbuf[32]; /* command line buf */
929 char nonce[NONCE_SIZE];
930 char *telnet_client_host = NULL;
931 char *sptr, *sptr2; /* USed to extract the nonce */
932 char hexstring[MD5_HEXSTRING_SIZE];
933 int stored_password = 0;
936 /* Permissions sanity check - don't run citadel setuid/setgid */
937 if (getuid() != geteuid()) {
938 err_printf("Please do not run citadel setuid!\n");
940 } else if (getgid() != getegid()) {
941 err_printf("Please do not run citadel setgid!\n");
945 sttybbs(SB_SAVE); /* Store the old terminal parameters */
946 load_command_set(); /* parse the citadel.rc file */
947 sttybbs(SB_NO_INTR); /* Install the new ones */
948 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
949 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
950 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
952 signal(SIGWINCH, scr_winch); /* Window resize signal */
956 arg_encrypt = RC_DEFAULT;
959 arg_screen = RC_DEFAULT;
963 * Handle command line options as if we were called like /bin/login
964 * (i.e. from in.telnetd)
966 for (a=0; a<argc; ++a) {
967 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
968 telnet_client_host = argv[a+1];
969 argc = shift(argc, argv, a, 2);
971 if (!strcmp(argv[a], "-x")) {
975 argc = shift(argc, argv, a, 1);
977 if (!strcmp(argv[a], "-X")) {
979 arg_encrypt = RC_YES;
980 argc = shift(argc, argv, a, 1);
982 fprintf(stderr, "Not compiled with encryption support");
986 if (!strcmp(argv[a], "-s")) {
990 argc = shift(argc, argv, a, 1);
992 if (!strcmp(argv[a], "-S")) {
996 argc = shift(argc, argv, a, 1);
998 if (!strcmp(argv[a], "-p")) {
1001 if (chdir(BBSDIR) < 0) {
1002 perror("can't change to " BBSDIR);
1007 * Drop privileges if necessary. We stat
1008 * citadel.config to get the uid/gid since it's
1009 * guaranteed to have the uid/gid we want.
1011 if (!getuid() || !getgid()) {
1012 if (stat(BBSDIR "/citadel.config", &st) < 0) {
1013 perror("couldn't stat citadel.config");
1016 if (!getgid() && (setgid(st.st_gid) < 0)) {
1017 perror("couldn't change gid");
1020 if (!getuid() && (setuid(st.st_uid) < 0)) {
1021 perror("couldn't change uid");
1025 scr_printf("Privileges changed to uid %d gid %d\n",
1026 getuid(), getgid());
1029 argc = shift(argc, argv, a, 1);
1035 sln_printf("Attaching to server... \r");
1037 attach_to_server(argc, argv, hostbuf, portbuf);
1040 if (aaa[0] != '2') {
1041 scr_printf("%s\n", &aaa[4]);
1045 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
1049 if ((sptr = strchr(aaa, '<')) == NULL)
1055 if ((sptr2 = strchr(sptr, '>')) == NULL)
1063 strncpy(nonce, sptr, NONCE_SIZE);
1067 get_serv_info(telnet_client_host);
1069 scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1070 serv_info.serv_bbs_city);
1073 secure = starttls();
1074 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city, NULL,
1077 screenwidth = 80; /* default screen dimensions */
1080 scr_printf(" pause next stop\n");
1081 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1082 formout("hello"); /* print the opening greeting */
1085 GSTA: /* See if we have a username and password on disk */
1086 if (rc_remember_passwords) {
1087 get_stored_password(hostbuf, portbuf, fullname, password);
1088 if (strlen(fullname) > 0) {
1089 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1094 snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
1096 else /* Else no APOP */
1098 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1103 if (aaa[0] == '2') {
1104 load_user_info(&aaa[4]);
1105 stored_password = 1;
1109 set_stored_password(hostbuf, portbuf, "", "");
1117 if (strlen(rc_username) > 0) {
1118 strcpy(fullname, rc_username);
1120 newprompt("Enter your name: ", fullname, 29);
1123 if (!strcasecmp(fullname, "new")) { /* just in case */
1124 scr_printf("Please enter the name you wish to log in with.\n");
1127 (!strcasecmp(fullname, "bbs"))
1128 || (!strcasecmp(fullname, "new"))
1129 || (strlen(fullname) == 0));
1131 if (!strcasecmp(fullname, "off")) {
1135 /* sign on to the server */
1136 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1142 /* password authentication */
1143 if (strlen(rc_password) > 0) {
1144 strcpy(password, rc_password);
1146 newprompt("\rPlease enter your password: ", password, -19);
1152 snprintf(aaa, sizeof aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring, sizeof hexstring));
1154 else /* Else no APOP */
1156 snprintf(aaa, sizeof aaa, "PASS %s", password);
1161 if (aaa[0] == '2') {
1162 load_user_info(&aaa[4]);
1163 offer_to_remember_password(hostbuf, portbuf,
1164 fullname, password);
1167 scr_printf("<< wrong password >>\n");
1168 if (strlen(rc_password) > 0)
1172 NEWUSR: if (strlen(rc_password) == 0) {
1173 scr_printf("No record. Enter as new user? ");
1177 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1180 if (aaa[0] != '2') {
1181 scr_printf("%s\n", aaa);
1184 load_user_info(&aaa[4]);
1186 while (set_password() != 0);;
1192 /* Switch color support on or off if we're in user mode */
1193 if (rc_ansi_color == 3) {
1194 if (userflags & US_COLOR)
1200 scr_printf("%s\nAccess level: %d (%s)\n"
1201 "User #%ld / Login #%d",
1202 fullname, axlevel, axdefs[(int) axlevel],
1203 usernum, timescalled);
1204 if (lastcall > 0L) {
1205 scr_printf(" / Last login: %s\n",
1206 asctime(localtime(&lastcall)) );
1212 if (aaa[0] == '2') {
1213 b = extract_int(&aaa[4], 0);
1217 scr_printf("*** You have a new private message in Mail>\n");
1219 scr_printf("*** You have %d new private messages in Mail>\n", b);
1222 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1223 scr_printf("*** Users need validation\n");
1225 if (extract_int(&aaa[4], 1) > 0) {
1226 scr_printf("*** Please register.\n");
1227 formout("register");
1231 /* Make up some temporary filenames for use in various parts of the
1232 * program. Don't mess with these once they've been set, because we
1233 * will be unlinking them later on in the program and we don't
1234 * want to delete something that we didn't create. */
1235 snprintf(temp, sizeof temp, tmpnam(NULL));
1236 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1237 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1239 /* Get screen dimensions. First we go to a default of 80x24. Then
1240 * we try to get the user's actual screen dimensions off the server.
1241 * However, if we're running on an xterm, all this stuff is
1242 * irrelevant because we're going to dynamically size the screen
1243 * during the session.
1249 if (aaa[0] == '2') {
1250 screenwidth = extract_int(&aaa[4], 0);
1251 screenheight = extract_int(&aaa[4], 1);
1253 if (getenv("TERM") != NULL)
1254 if (!strcmp(getenv("TERM"), "xterm")) {
1258 check_screen_dims();
1264 /* Enter the lobby */
1265 dotgoto("_BASEROOM_", 1, 0);
1267 /* Main loop for the system... user is logged in. */
1275 /* MAIN COMMAND LOOP */
1277 mcmd = getcmd(argbuf); /* Get keyboard command */
1280 check_screen_dims(); /* if xterm, get screen size */
1298 newprompt("What do you want your username to be? ", aaa, 32);
1299 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1302 if (strncmp("200", aaa, 3))
1303 scr_printf("\n%s\n", aaa);
1312 if (!rc_alt_semantics)
1317 if (!rc_alt_semantics)
1319 dotgoto(argbuf, 0, 0);
1323 dotgoto("_MAIL_", 1, 0);
1327 dotgoto(argbuf, 0, 0);
1330 if (rc_alt_semantics)
1332 dotgoto(argbuf, 0, 0);
1344 readmsgs(0, (-1), 0);
1347 readmsgs(2, (-1), 0);
1350 readmsgs(3, 1, atoi(argbuf));
1423 if (!rc_alt_semantics)
1428 if (!rc_alt_semantics)
1439 cli_image_upload("_userpic_");
1442 cli_image_upload("_roompic_");
1446 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1447 cli_image_upload(aaa);
1451 enternew("roomname", aaa, 20);
1452 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1455 if (strncmp("200", aaa, 3))
1456 scr_printf("\n%s\n", aaa);
1459 enternew("hostname", aaa, 25);
1460 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1463 if (strncmp("200", aaa, 3))
1464 scr_printf("\n%s\n", aaa);
1467 enternew("username", aaa, 32);
1468 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1471 if (strncmp("200", aaa, 3))
1472 scr_printf("\n%s\n", aaa);
1482 display_help(argbuf);
1486 formout("register");
1491 scr_printf("Are you sure (y/n)? ");
1500 scr_printf("All users will be disconnected! "
1501 "Really terminate the server? ");
1505 scr_printf("%s\n", &aaa[4]);
1515 scr_printf("Do you really want to schedule a "
1516 "server shutdown? ");
1518 serv_puts("SCDN 1");
1521 if (atoi(&aaa[4])) {
1523 "The Citadel server will terminate when all users are logged off.\n"
1528 "The Citadel server will not terminate.\n"
1536 network_config_management("listrecp",
1537 "Mailing list recipients");
1541 network_config_management("ignet_push_share",
1542 "Nodes with which we share this room");
1546 do_ignet_configuration();
1550 do_filterlist_configuration();
1554 if (rc_alt_semantics)
1564 if (server_is_local) {
1566 sttybbs(SB_RESTORE);
1567 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1568 "exec ./subsystem %ld %d %d", fullname,
1569 usernum, screenwidth, axlevel);
1571 sttybbs(SB_NO_INTR);
1574 scr_printf("*** Can't run doors when server is not local.\n");
1591 do_system_configuration();
1595 do_internet_configuration();
1599 check_message_base();
1621 gotofloor(argbuf, GF_GOTO);
1625 gotofloor(argbuf, GF_SKIP);
1629 forget_this_floor();
1657 knrooms(floor_mode);
1667 misc_server_cmd(argbuf);
1671 edit_system_message(argbuf);
1696 } while (termn8 == 0);
1698 TERMN8: scr_printf("%s logged out.\n", fullname);
1699 while (march != NULL) {
1700 remove_march(march->march_name, 0);
1703 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
1705 snprintf(aaa, sizeof aaa, "LOUT");
1709 sttybbs(SB_RESTORE);
1710 if ((mcmd == 29) || (mcmd == 15)) {