From 9590fb796e361392256ff255d6ba2ffff10751a3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 22 Feb 2007 21:38:00 +0000 Subject: [PATCH] Final changes to server to allow message display names to be either the account's display name or the vCard's friendly name. --- citadel/citadel.c | 21 +++++---------------- citadel/citserver.c | 1 - citadel/messages.c | 14 ++++++++++---- citadel/messages.h | 2 +- citadel/msgbase.c | 45 +++++++++++++++------------------------------ citadel/server.h | 9 ++++----- citadel/user_ops.c | 1 - 7 files changed, 35 insertions(+), 58 deletions(-) diff --git a/citadel/citadel.c b/citadel/citadel.c index 1894907d3..0c5ccc835 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -1747,27 +1747,16 @@ NEWUSR: if (strlen(rc_password) == 0) { formout(ipc, "help"); break; case 4: - entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0)); + entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 0); break; case 36: - entmsg(ipc, 0, 1); + entmsg(ipc, 0, 1, 0); break; case 46: - entmsg(ipc, 0, 2); + entmsg(ipc, 0, 2, 0); break; case 78: - { - /* Only m.author is used */ - struct ctdlipcmessage m; - newprompt("What do you want your username to be? ", - m.author, USERNAME_SIZE - 1); - m.text = ""; - r = CtdlIPCPostMessage(ipc, 2, &m, aaa); - if (r / 100 != 2) - scr_printf("%s\n", aaa); - else - entmsg(ipc, 0, 0); - } + entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 1); break; case 5: /* oto */ updatels(ipc); @@ -2247,7 +2236,7 @@ NEWUSR: if (strlen(rc_password) == 0) { if (mcmd >= 100 && mcmd < (100+MAX_EDITORS)) { /* entmsg mode >=2 select editor */ - entmsg(ipc, 0, mcmd - 100 + 2); + entmsg(ipc, 0, mcmd - 100 + 2, 0); break; } } /* end switch */ diff --git a/citadel/citserver.c b/citadel/citserver.c index 2a034e5f6..8c2c4cde4 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -841,7 +841,6 @@ void begin_session(struct CitContext *con) strcpy(con->curr_user, NLI); strcpy(con->net_node, ""); strcpy(con->fake_username, ""); - strcpy(con->fake_postname, ""); strcpy(con->fake_hostname, ""); strcpy(con->fake_roomname, ""); generate_nonce(con); diff --git a/citadel/messages.c b/citadel/messages.c index 7788bc822..e726f2e1a 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -1098,8 +1098,9 @@ void break_big_lines(char *msg) { */ int entmsg(CtdlIPC *ipc, int is_reply, /* nonzero if this was a eply command */ - int c) /* mode */ -{ + int c, /* mode */ + int masquerade /* prompt for a non-default display name? */ +) { char buf[SIZ]; int a, b; int need_recp = 0; @@ -1125,9 +1126,14 @@ int entmsg(CtdlIPC *ipc, strcpy(message.recipient, ""); strcpy(message.author, ""); strcpy(message.subject, ""); - message.text = message.author; /* point to "", changes later */ + message.text = ""; /* point to "", changes later */ message.anonymous = 0; message.type = mode; + + if (masquerade) { + newprompt("Display name for this message: ", message.author, 40); + } + r = CtdlIPCPostMessage(ipc, 0, &message, buf); if (r / 100 != 2 && r / 10 != 57) { @@ -1824,7 +1830,7 @@ RMSGREAD: scr_flush(); goto RMSGREAD; case 'r': savedpos = num_msgs; - entmsg(ipc, 1, ((userflags & US_EXTEDIT) ? 2 : 0)); + entmsg(ipc, 1, ((userflags & US_EXTEDIT) ? 2 : 0), 0); num_msgs = savedpos; goto RMSGREAD; case 'u': diff --git a/citadel/messages.h b/citadel/messages.h index 4453190b4..ce5c4a64c 100644 --- a/citadel/messages.h +++ b/citadel/messages.h @@ -5,7 +5,7 @@ extern int num_urls; extern char urls[MAXURLS][SIZ]; int ka_system(char *shc); -int entmsg(CtdlIPC *ipc, int is_reply, int c); +int entmsg(CtdlIPC *ipc, int is_reply, int c, int masquerade); void readmsgs(CtdlIPC *ipc, enum MessageList c, enum MessageDirection rdir, int q); void edit_system_message(CtdlIPC *ipc, char *which_message); pid_t ka_wait(int *kstatus); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 74a2f898f..f8a9791b5 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2906,8 +2906,8 @@ struct CtdlMessage *CtdlMakeMessage( char *supplied_euid, /* ...or NULL if this is irrelevant */ char *preformatted_text /* ...or NULL to read text from client */ ) { - char dest_node[SIZ]; - char buf[SIZ]; + char dest_node[256]; + char buf[1024]; struct CtdlMessage *msg; msg = malloc(sizeof(struct CtdlMessage)); @@ -2987,8 +2987,7 @@ struct CtdlMessage *CtdlMakeMessage( msg->cm_fields['M'] = preformatted_text; } else { - msg->cm_fields['M'] = CtdlReadMessageBody("000", - config.c_maxmsglen, NULL, 0); + msg->cm_fields['M'] = CtdlReadMessageBody("000", config.c_maxmsglen, NULL, 0); } return(msg); @@ -3255,10 +3254,9 @@ void cmd_ent0(char *entargs) char cc[SIZ]; char bcc[SIZ]; char supplied_euid[128]; - char masquerade_as[SIZ]; int anon_flag = 0; int format_type = 0; - char newusername[SIZ]; + char newusername[256]; struct CtdlMessage *msg; int anonymous = 0; char errmsg[SIZ]; @@ -3278,6 +3276,7 @@ void cmd_ent0(char *entargs) anon_flag = extract_int(entargs, 2); format_type = extract_int(entargs, 3); extract_token(subject, entargs, 4, '|', sizeof subject); + extract_token(newusername, entargs, 5, '|', sizeof newusername); do_confirm = extract_int(entargs, 6); extract_token(cc, entargs, 7, '|', sizeof cc); extract_token(bcc, entargs, 8, '|', sizeof bcc); @@ -3301,19 +3300,17 @@ void cmd_ent0(char *entargs) /* Check some other permission type things. */ - if (post == 2) { - if (CC->user.axlevel < 6) { - cprintf("%d You don't have permission to masquerade.\n", - ERROR + HIGHER_ACCESS_REQUIRED); - return; - } - extract_token(newusername, entargs, 5, '|', sizeof newusername); - memset(CC->fake_postname, 0, sizeof(CC->fake_postname) ); - safestrncpy(CC->fake_postname, newusername, - sizeof(CC->fake_postname) ); - cprintf("%d ok\n", CIT_OK); + if ( (CC->user.axlevel < 6) + && (strcasecmp(newusername, CC->user.fullname)) + && (strcasecmp(newusername, CC->cs_inet_fn)) + ) { + cprintf("%d You don't have permission to author messages as '%s'.\n", + ERROR + HIGHER_ACCESS_REQUIRED, + newusername + ); return; } + CC->cs_flags |= CS_POSTING; /* In the Mail> room we have to behave a little differently -- @@ -3430,17 +3427,6 @@ void cmd_ent0(char *entargs) free(valid_cc); free(valid_bcc); - /* Handle author masquerading */ - if (CC->fake_postname[0]) { - strcpy(masquerade_as, CC->fake_postname); - } - else if (CC->fake_username[0]) { - strcpy(masquerade_as, CC->fake_username); - } - else { - strcpy(masquerade_as, ""); - } - /* Read in the message from the client. */ if (do_confirm) { cprintf("%d send message\n", START_CHAT_MODE); @@ -3450,7 +3436,7 @@ void cmd_ent0(char *entargs) msg = CtdlMakeMessage(&CC->user, recp, cc, CC->room.QRname, anonymous, format_type, - masquerade_as, subject, + newusername, subject, ((strlen(supplied_euid) > 0) ? supplied_euid : NULL), NULL); @@ -3500,7 +3486,6 @@ void cmd_ent0(char *entargs) CtdlFreeMessage(msg); } - CC->fake_postname[0] = '\0'; if (valid != NULL) { free(valid); } diff --git a/citadel/server.h b/citadel/server.h index db01ba68f..bdb7a7ebe 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -129,11 +129,10 @@ struct CitContext { int disable_exp; /* Set to 1 to disable incoming pages */ int newmail; /* Other sessions increment this */ - /* Masquerade... */ - char fake_username[USERNAME_SIZE]; /* Fake username */ - char fake_postname[USERNAME_SIZE]; /* Fake postname */ - char fake_hostname[64]; /* Fake hostname */ - char fake_roomname[ROOMNAMELEN]; /* Fake roomname */ + /* Masqueraded values in the 'who is online' list */ + char fake_username[USERNAME_SIZE]; + char fake_hostname[64]; + char fake_roomname[ROOMNAMELEN]; char preferred_formats[256]; /* Preferred MIME formats */ diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 4b23c646f..296a57677 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -541,7 +541,6 @@ void logout(struct CitContext *who) * make that assumption. */ strcpy(who->fake_username, ""); - strcpy(who->fake_postname, ""); strcpy(who->fake_hostname, ""); strcpy(who->fake_roomname, ""); who->logged_in = 0; -- 2.39.2