void RTPApplication::findCNAME() { // build string username@host_fqn std::string username; findusername(username); // First create an InetHostAddress object, otherwise the // object will be destructed and the hostname corrupted. InetHostAddress iha; const char *p = iha.getHostname(); // Returned hostname can be NULL std::string hname; if (p) hname = p; setSDESItem(SDESItemTypeCNAME, username + "@" + hname); }
static char *get_headers(void) { char *ofs; int fd; struct DayDream_Message msg; char fname[PATH_MAX + 1]; snprintf(fname, PATH_MAX + 1, "%s/messages/base%3.3d/msgbase.dat", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER); if ((fd = open(fname, O_RDONLY)) == -1) return NULL; ofs = (char *) calloc(1 + highest - lowest, 1); for (;;) { if (read(fd, &msg, sizeof(struct DayDream_Message)) != sizeof(struct DayDream_Message)) break; if (msg.MSG_NUMBER < lowest || msg.MSG_NUMBER > highest) continue; /* no deleted messages */ if (msg.MSG_FLAGS & (1L << 1)) continue; /* keep privacy */ if (msg.MSG_FLAGS & (1L << 0) && !read_all && findusername(msg.MSG_RECEIVER) != user.user_account_id) continue; ofs[msg.MSG_NUMBER - lowest] = 1; } close(fd); return ofs; }
int entermsg(struct DayDream_Message *msg, int reply, char *params) { char ebuf[1024]; int hola; int msgfd; char *s; struct DayDream_Message header; char *lineedmem; int recoff; if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E' && ((access1 & (1L << SECB_FIDOMESSAGE)) == 0)) { DDPut(sd[emnofidomsgstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N' && ((access2 & (1L << SECB_SENDNETMAIL)) == 0)) { DDPut(sd[emnonetmsgstr]); return 0; } changenodestatus("Entering a message"); if (msg) { memcpy(&header, msg, sizeof(struct DayDream_Message)); } else { s = (char *) &header; memset(&header, 0, sizeof(struct DayDream_Message)); if (params) strncpy(header.MSG_RECEIVER, params, 25); } if (current_msgbase->MSGBASE_FLAGS & (1L << 0) && current_msgbase->MSGBASE_FLAGS & (1L << 1)) { DDPut(sd[emnomsgsstr]); return 0; } DDPut(sd[emhead1str]); DDPut(current_msgbase->MSGBASE_NAME); ebuf[0] = 0; strlcat(ebuf, sd[emhead2str], sizeof ebuf); hola = 61 - strlen(current_msgbase->MSGBASE_NAME); while (hola) { strlcat(ebuf, "-", sizeof ebuf); hola--; } DDPut(ebuf); ddprintf(sd[emhead3str], highest); DDPut(sd[emhead4str]); if ((current_msgbase->MSGBASE_FLAGS & (1L << 0)) || (header.MSG_FLAGS & (1L << 0))) { DDPut(sd[emprvstr]); header.MSG_FLAGS |= (1L << 0); } else { DDPut(sd[empubstr]); } header.MSG_CREATION = time(0); DDPut(sd[emhead5str]); DDPut(ctime(&header.MSG_CREATION)); DDPut(sd[emhead6str]); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_AUTHOR, user.user_handle, sizeof header.MSG_AUTHOR); } else { strlcpy(header.MSG_AUTHOR, user.user_realname, sizeof header.MSG_AUTHOR); } DDPut(header.MSG_AUTHOR); for (;;) { askrec: DDPut(sd[emhead7str]); if (!(Prompt(header.MSG_RECEIVER, 25, 0))) return 0; if (header.MSG_RECEIVER[0] == 0 || (!strcasecmp(header.MSG_RECEIVER, "all")) || (!strcasecmp(header.MSG_RECEIVER, "all users"))) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else { DDPut(sd[emhead9str]); header.MSG_RECEIVER[0] = 0; break; } } else if (!strcasecmp(header.MSG_RECEIVER, "eall")) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else if (access1 & (1L << SECB_EALLMESSAGE)) { header.MSG_RECEIVER[0] = -1; DDPut(sd[emhead10str]); break; } else { DDPut(sd[emnopoststr]); HotKey(0); header.MSG_RECEIVER[0] = 0; } } else { if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'L') { struct userbase user; if (!strcasecmp(header.MSG_RECEIVER, "sysop")) { recoff = 0; } else { recoff = findusername(header.MSG_RECEIVER); } if (recoff == -1 || getubentbyid(recoff, &user) == -1) { DDPut(sd[emnouserstr]); HotKey(0); goto askrec; } if (!checkconfaccess(conference()->conf.CONF_NUMBER, &user)) { DDPut(sd[emnoaccessstr]); HotKey(0); } DDPut("[5;12H [5;12H"); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_RECEIVER, user.user_handle, sizeof header.MSG_RECEIVER); } else { strlcpy(header.MSG_RECEIVER, user.user_realname, sizeof header.MSG_RECEIVER); } DDPut(header.MSG_RECEIVER); break; } else break; } } DDPut(sd[emsubjectstr]); if (!(Prompt(header.MSG_SUBJECT, 67, 0))) return 0; if (header.MSG_SUBJECT[0] == 0) { DDPut(sd[emabortedstr]); return 0; } DDPut("[11;1H [11;1H"); if (header.MSG_RECEIVER[0] == 0 || header.MSG_RECEIVER[0] == -1 || header.MSG_FLAGS & (1L << 0) || current_msgbase->MSGBASE_FLAGS & (1L << 1)) { } else { DDPut(sd[emisprivatestr]); hola = HotKey(HOT_NOYES); if (hola == 0) return 0; if (hola == 1) header.MSG_FLAGS |= MSG_FLAGS_PRIVATE; } if ((header.MSG_FLAGS & (1L << 0)) == 0 && (access1 & (1L << SECB_PUBLICMESSAGE)) == 0) { DDPut(sd[emnopubstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { if (header.MSG_FN_DEST_NET) { snprintf(ebuf, sizeof ebuf, "%d:%d/%d.%d", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_DEST_POINT); } else { *ebuf = 0; } DDPut(sd[emnetaddstr]); if (!(Prompt(ebuf, 30, 0))) return 0; if (!str2addr(ebuf, &header.MSG_FN_DEST_ZONE, &header.MSG_FN_DEST_NET, &header.MSG_FN_DEST_NODE, &header.MSG_FN_DEST_POINT)) return 0; if(access2 & (1L << SECB_CRASH)) { DDPut(sd[emnetcrashstr]); if(HotKey(HOT_NOYES) == 1) { header.MSG_FLAGS |= MSG_FLAGS_CRASH; } } DDPut(sd[emnetkillstr]); if(HotKey(HOT_YESNO) == 1) { header.MSG_FLAGS |= MSG_FLAGS_KILL_SENT; } } *header.MSG_ATTACH = 0; if (current_msgbase->MSGBASE_FLAGS & (1L << 5)) { if ((header.MSG_FLAGS & (1L << 0)) && (access2 & (1L << SECB_PVTATTACH))) { *header.MSG_ATTACH = 1; } else if (((header.MSG_FLAGS & (1L << 0)) == 0) && (access2 & (1L << SECB_PUBATTACH))) { *header.MSG_ATTACH = 1; } } if (reply) { if (!askqlines()) { snprintf(ebuf, sizeof ebuf, "%s/daydream%d.msg", DDTMP, node); unlink(ebuf); } DDPut("\n\n"); } /* XXX: size should be replaced by a constant! */ lineedmem = (char *) xmalloc(80 * 500); hola = edfile(lineedmem, 80 * 500, reply, &header); if (hola == 0) { char fabuf[1024]; DDPut(sd[emaborted2str]); free(lineedmem); if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); return 0; } DDPut(sd[emsavingstr]); getmsgptrs(); highest++; header.MSG_NUMBER = highest; if (setmsgptrs() == 0) { free(lineedmem); return 0; } if (*header.MSG_ATTACH) { char fabuf[1024]; FILE *fd; snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); if ((fd = fopen(fabuf, "r"))) { char hoobab[1024]; snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/fa%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); mkdir(hoobab, 0777); setperm(hoobab, 0777); while (fgetsnolf(hoobab, 1024, fd)) { char sr[1024]; char de[1024]; snprintf(sr, sizeof sr, "%s/%s", currnode->MULTI_TEMPORARY, hoobab); snprintf(de, sizeof de, "%s/messages/base%3.3d/fa%5.5d/%s", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, hoobab); newrename(sr, de); } fclose(fd); snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/msf%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); newrename(fabuf, hoobab); } else { *header.MSG_ATTACH = 0; } } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { header.MSG_FN_ORIG_ZONE = current_msgbase->MSGBASE_FN_ZONE; header.MSG_FN_ORIG_NET = current_msgbase->MSGBASE_FN_NET; header.MSG_FN_ORIG_NODE = current_msgbase->MSGBASE_FN_NODE; header.MSG_FN_ORIG_POINT = current_msgbase->MSGBASE_FN_POINT; header.MSG_FLAGS |= (1L << 2); } if ((msgfd = ddmsg_open_base(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, O_RDWR | O_CREAT, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); lseek(msgfd, 0, SEEK_END); safe_write(msgfd, &header, sizeof(struct DayDream_Message)); ddmsg_close_base(msgfd); if ((msgfd = ddmsg_open_msg(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { char ub[128]; int uq; strlcpy(ub, current_msgbase->MSGBASE_FN_TAG, sizeof ub); strupr(ub); snprintf(ebuf, sizeof ebuf, "AREA:%s\n", ub); safe_write(msgfd, ebuf, strlen(ebuf)); if ((uq = getfidounique())) { snprintf(ebuf, sizeof ebuf, "\001MSGID: %d:%d/%d.%d %8.8x\n", current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_POINT, uq); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_ORIGINAL) { if (getreplyid(header.MSG_ORIGINAL, ebuf, sizeof ebuf)) safe_write(msgfd, ebuf, strlen(ebuf)); } } } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { snprintf(ebuf, sizeof ebuf, "\001INTL %d:%d/%d %d:%d/%d\n", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_ORIG_ZONE, header.MSG_FN_ORIG_NET, header.MSG_FN_ORIG_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_FN_DEST_POINT) { snprintf(ebuf, sizeof ebuf, "\001TOPT %d\n", header.MSG_FN_DEST_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } if (header.MSG_FN_ORIG_POINT) { snprintf(ebuf, sizeof ebuf, "\001FMPT %d\n", header.MSG_FN_ORIG_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } } s = lineedmem; while (hola) { snprintf(ebuf, sizeof ebuf, "%s\n", s); safe_write(msgfd, ebuf, strlen(ebuf)); hola--; s = &s[80]; } // place holder, user auto-sig goes here // snprintf(ebuf, sizeof ebuf, "signature here"); // safe_write(msgfd, ebuf, strlen(ebuf)); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n * Origin: %s (%d:%d/%d)\nSEEN-BY: %d/%d\n", versionstring, current_msgbase->MSGBASE_FN_ORIGIN, current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n", versionstring); safe_write(msgfd, ebuf, strlen(ebuf)); } ddmsg_close_msg(msgfd); DDPut(sd[emdonestr]); free(lineedmem); if (header.MSG_FLAGS & (1L << 0)) { user.user_pvtmessages++; clog.cl_pvtmessages++; } else { user.user_pubmessages++; clog.cl_pubmessages++; } return 1; }
/* FIXME! buffer overflows? */ static int handle_choice(const char *askbuf) { char lesbabuf[30]; struct userbase muser = user; int leps; if (!(strcasecmp(askbuf, "1"))) { for (;;) { if (!isaccess(SECB_REALNAME, access2)) break; DDPut(sd[eu1str]); strlcpy(lesbabuf, user.user_realname, sizeof lesbabuf); if (!(Prompt(lesbabuf, 25, 0))) return 1; removespaces(lesbabuf); if (strcasecmp(lesbabuf, user.user_realname)) { leps = findusername(lesbabuf); if (leps == user.user_account_id || leps == -1) { if (lesbabuf[0]) strlcpy(user.user_realname, lesbabuf, sizeof user.user_realname); } else { DDPut(sd[newalreadystr]); continue; } } break; } } else if (!(strcasecmp(askbuf, "2"))) { for (;;) { if (!isaccess(SECB_HANDLE, access2)) break; DDPut(sd[eu2str]); strlcpy(lesbabuf, user.user_handle, sizeof lesbabuf); if (!(Prompt(lesbabuf, 25, 0))) return 1; removespaces(lesbabuf); if (strcasecmp(lesbabuf, user.user_handle)) { leps = findusername(lesbabuf); if (leps == user.user_account_id || leps == -1) { if (lesbabuf[0]) strlcpy(user.user_handle, lesbabuf, sizeof user.user_handle); } else { DDPut(sd[newalreadystr]); continue; } } break; } } else if (!(strcasecmp(askbuf, "3"))) { DDPut(sd[eu3str]); if (!(Prompt(user.user_organization, 25, 0))) return 1; } else if (!(strcasecmp(askbuf, "4"))) { DDPut(sd[eu4str]); if (!(Prompt(user.user_zipcity, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "5"))) { DDPut(sd[eu5str]); if (!(Prompt(user.user_voicephone, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "6"))) { MD_CTX context; char verifypw[32]; DDPut(sd[eu6str]); lesbabuf[0] = 0; if (!(Prompt(lesbabuf, 15, PROMPT_SECRET))) return 1; if (lesbabuf[0] == 0) return 0; *verifypw = 0; DDPut(sd[euverifypwstr]); if (!(Prompt(verifypw, 15, PROMPT_SECRET))) return 1; if (strcasecmp(lesbabuf, verifypw)) { DDPut(sd[eunomatchstr]); return 0; } strupr(lesbabuf); MDInit(&context); MDUpdate(&context, (unsigned char *) lesbabuf, strlen(lesbabuf)); MDFinal(user.user_password, &context); } else if (!strcasecmp(askbuf, "7")) { for (;;) { int fallos; DDPut(sd[eu7str]); lesbabuf[0] = 0; if (!(Prompt(lesbabuf, 3, 0))) return 1; if (lesbabuf[0] == 't' || lesbabuf[0] == 'T') { testscreenl(); continue; } fallos = atoi(lesbabuf); if (fallos < 10) { DDPut(sd[newminslstr]); continue; } user.user_screenlength = fallos; break; } } else if (!(strcasecmp(askbuf, "8"))) { struct DayDream_Protocol *tp; TypeFile("protocols", TYPE_MAKE | TYPE_WARN); DDPut(sd[eu8str]); *lesbabuf = 0; if (user.user_protocol) { *lesbabuf = user.user_protocol; lesbabuf[1] = 0; } if (!(Prompt(lesbabuf, 3, 0))) return 1; *lesbabuf = toupper(*lesbabuf); if (!*lesbabuf) return 0; tp = protocols; for (;;) { if (tp->PROTOCOL_ID == 0) return 0; if (tp->PROTOCOL_ID == *lesbabuf) { protocol = tp; user.user_protocol = *lesbabuf; return 0; } tp++; } } else if (!(strcasecmp(askbuf, "9"))) { DDPut(sd[eu9str]); if (!(Prompt(user.user_signature, 44, 0))) return 1; } else if (!(strcasecmp(askbuf, "10"))) { DDPut(sd[eu10str]); if (!(Prompt(user.user_computermodel, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "11"))) { DDPut(sd[eu11str]); snprintf(lesbabuf, sizeof lesbabuf, "%d", user.user_flines); if (!(Prompt(lesbabuf, 3, 0))) return 1; user.user_flines = atoi(lesbabuf); } else if (!(strcasecmp(askbuf, "12"))) { rundoor("doors/autosig %N", 0); return 1; } else if (!(strcasecmp(askbuf, "a"))) { DDPut(sd[euabortedstr]); user = muser; return 1; } else if (!(strcasecmp(askbuf, "v"))) { TypeFile("edituser", TYPE_MAKE | TYPE_WARN); } else if (!(strcasecmp(askbuf, "s"))) { switches(); } else if ((!(strcasecmp(askbuf, "c")) || (askbuf[0] == 0))) { DDPut(sd[eusavedstr]); saveuserbase(&user); return 1; } return 0; }