* give the flag to the CtdlDoIHavePermissionToPostInThisRoom in through the parameter...
authorWilfried Göesgens <willi@citadel.org>
Sun, 9 Dec 2007 23:26:41 +0000 (23:26 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 9 Dec 2007 23:26:41 +0000 (23:26 +0000)
dict_tcp flags it CHECK_EXISTANCE;
serv_smtp flags it POST_EXTERNAL / POST_LOGGED_IN depending on user state. (logged in users may post to public rooms if they have write permission)

citadel/journaling.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/imap/imap_acl.c
citadel/modules/network/serv_network.c
citadel/modules/sieve/serv_sieve.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/vcard/serv_vcard.c
citadel/msgbase.c
citadel/msgbase.h
citadel/user_ops.c

index a0ebeb21d0c747bcf47f3c1f413225d6d01412eb..c78292b6bc7cb43b48cd5ef673506ed641c1d622 100644 (file)
@@ -133,7 +133,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
        static int seq = 0;
        int i;
 
-       journal_recps = validate_recipients(config.c_journal_dest);
+       journal_recps = validate_recipients(config.c_journal_dest, 0);
        if (journal_recps != NULL) {
 
                if (  (journal_recps->num_local > 0)
index 345aaa5a80bb16b4fcabe626e8ffc73c0b085086..526d737c50b124e2141e4dd21418e6dac48e44f6 100644 (file)
@@ -264,7 +264,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                                if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
                                        strcpy(attendee_string, &attendee_string[7]);
                                        striplt(attendee_string);
-                                       recp = validate_recipients(attendee_string);
+                                       recp = validate_recipients(attendee_string, 0);
                                        if (recp != NULL) {
                                                if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
                                                        if (me_attend) icalproperty_free(me_attend);
@@ -350,7 +350,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                        reply_message_text);
        
                if (msg != NULL) {
-                       valid = validate_recipients(organizer_string);
+                       valid = validate_recipients(organizer_string, 0);
                        CtdlSubmitMsg(msg, valid, "");
                        CtdlFreeMessage(msg);
                        free_recipients(valid);
@@ -1214,7 +1214,7 @@ void ical_freebusy(char *who) {
        /* If not found, try it as an unqualified email address. */
        if (found_user != 0) {
                strcpy(buf, who);
-               recp = validate_recipients(buf);
+               recp = validate_recipients(buf, 0);
                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
@@ -1230,7 +1230,7 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
-               recp = validate_recipients(buf);
+               recp = validate_recipients(buf, 0);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
                                found_user = getuser(&usbuf, recp->recp_local);
@@ -1253,7 +1253,7 @@ void ical_freebusy(char *who) {
                           || (!strcasecmp(type, "directory")) ) {
                                snprintf(buf, sizeof buf, "%s@%s", who, host);
                                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
-                               recp = validate_recipients(buf);
+                               recp = validate_recipients(buf, 0);
                                if (recp != NULL) {
                                        if (recp->num_local == 1) {
                                                found_user = getuser(&usbuf, recp->recp_local);
@@ -1794,7 +1794,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
                        request_message_text);
        
                if (msg != NULL) {
-                       valid = validate_recipients(attendees_string);
+                       valid = validate_recipients(attendees_string, 0);
                        CtdlSubmitMsg(msg, valid, "");
                        CtdlFreeMessage(msg);
                        free_recipients(valid);
index 55a010982ec870d2851a8c753800fed8badf6f68..3b5d44c88a8d3568153ee6c29e89994a76f5589a 100644 (file)
@@ -230,7 +230,7 @@ void imap_listrights(int num_parms, char *parms[]) {
         * Search for the specified user
         */
        ret = (-1);
-       valid = validate_recipients(parms[3]);
+       valid = validate_recipients(parms[3], 0);
        if (valid != NULL) {
                if (valid->num_local == 1) {
                        ret = getuser(&temp, valid->recp_local);
index c685ec4d1aa69d192ebba481e6d3daad1afa4aeb..13d4a73e1c73c8096c5b6f3de1597efe800c8472 100644 (file)
@@ -518,7 +518,7 @@ void network_deliver_digest(SpoolControl *sc) {
        }
 
        /* Now submit the message */
-       valid = validate_recipients(recps);
+       valid = validate_recipients(recps, 0);
        free(recps);
        CtdlSubmitMsg(msg, valid, NULL);
        CtdlFreeMessage(msg);
@@ -565,7 +565,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
        }
 
        /* Now submit the message */
-       valid = validate_recipients(recps);
+       valid = validate_recipients(recps, 0);
        free(recps);
        CtdlSubmitMsg(msg, valid, NULL);
        free_recipients(valid);
@@ -734,7 +734,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                        }
                                        msg->cm_fields['R'] = strdup(nptr->name);
        
-                                       valid = validate_recipients(nptr->name);
+                                       valid = validate_recipients(nptr->name, 0);
                                        CtdlSubmitMsg(msg, valid, "");
                                        free_recipients(valid);
                                }
@@ -1403,7 +1403,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        free(oldpath);
 
        /* Now submit the message */
-       valid = validate_recipients(recipient);
+       valid = validate_recipients(recipient, 0);
        if (valid != NULL) if (valid->num_error != 0) {
                free_recipients(valid);
                valid = NULL;
@@ -1561,7 +1561,7 @@ void network_process_buffer(char *buffer, long size) {
 
        /* Otherwise, does it have a recipient?  If so, validate it... */
        else if (msg->cm_fields['R'] != NULL) {
-               recp = validate_recipients(msg->cm_fields['R']);
+               recp = validate_recipients(msg->cm_fields['R'], 0);
                if (recp != NULL) if (recp->num_error != 0) {
                        network_bounce(msg,
                                "A message you sent could not be delivered due to an invalid address.\n"
index e6cf9aebf9ab6d05476a134c7196e2d9687f1c3c..39827f36588c3ae3f3cdbb5b507a69fd33170b28 100644 (file)
@@ -104,7 +104,7 @@ int ctdl_redirect(sieve2_context_t *s, void *my)
 
        lprintf(CTDL_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
 
-       valid = validate_recipients(recp);
+       valid = validate_recipients(recp, 0);
        if (valid == NULL) {
                lprintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                return SIEVE2_ERROR_BADARGS;
index 0376c1e47d2077f162d53e550e9182f4a84c1de9..d2c7b1e95f6ca4896187885c199dca25e28485ae 100644 (file)
@@ -598,7 +598,8 @@ void smtp_rcpt(char *argbuf) {
                }
        }
 
-       valid = validate_recipients(recp);
+       valid = validate_recipients(recp, 
+                                   (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL);
        if (valid->num_error != 0) {
                cprintf("599 5.1.1 Error: %s\r\n", valid->errormsg);
                free_recipients(valid);
@@ -721,7 +722,8 @@ void smtp_data(void) {
        msg->cm_fields['V'] = strdup(SMTP->recipients);
 
        /* Submit the message into the Citadel system. */
-       valid = validate_recipients(SMTP->recipients);
+       valid = validate_recipients(SMTP->recipients, 
+                                   (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL);
 
        /* If there are modules that want to scan this message before final
         * submission (such as virus checkers or spam filters), call them now
@@ -1437,7 +1439,7 @@ void smtp_do_bounce(char *instr) {
                }
 
                /* Can we deliver the bounce to the original sender? */
-               valid = validate_recipients(bounceto);
+               valid = validate_recipients(bounceto, 0);
                if (valid != NULL) {
                        if (valid->num_error == 0) {
                                CtdlSubmitMsg(bmsg, valid, "");
index 7580c0d2a864a8cffe70a0d4187f23d6ff6f4ec2..fc610c79cd20404d96cc28e1e7f6fcc37e72b969 100644 (file)
@@ -1271,7 +1271,7 @@ void check_get(void) {
                char *argbuf = &cmdbuf[4];
                
                extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
-               rcpt = validate_recipients(internet_addr);
+               rcpt = validate_recipients(internet_addr, CHECK_EXISTANCE);
                if ((rcpt != NULL)&&
                        (
                         (*rcpt->recp_local != '\0')||
index 15957eb24d18de53dd865a253b4a9a440b900b88..a34c418ce6dfbb63c03dff852702ad5e33393100 100644 (file)
@@ -2841,7 +2841,7 @@ void quickie_message(char *from, char *fromaddr, char *to, char *room, char *tex
        msg->cm_fields['N'] = strdup(NODENAME);
        if (to != NULL) {
                msg->cm_fields['R'] = strdup(to);
-               recp = validate_recipients(to);
+               recp = validate_recipients(to, 0);
        }
        if (subject != NULL) {
                msg->cm_fields['U'] = strdup(subject);
@@ -3166,7 +3166,7 @@ int CtdlCheckInternetMailPermission(struct ctdluser *who) {
  *
  * Caller needs to free the result using free_recipients()
  */
-struct recptypes *validate_recipients(char *supplied_recipients) {
+struct recptypes *validate_recipients(char *supplied_recipients, int Flags) {
        struct recptypes *ret;
        char *recipients = NULL;
        char this_recp[256];
@@ -3295,8 +3295,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) {
                                        CC->room = tempQR;
                                        
                                        /* Check permissions to send mail to this room */
-                                       err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, POST_EXTERNAL);
-                                       //// TODO: CHECK_EXISTANCE for dict_tcp
+                                       err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, Flags);
                                        if (err)
                                        {
                                                cprintf("%d %s\n", err, errmsg);
@@ -3542,14 +3541,14 @@ void cmd_ent0(char *entargs)
                        strcpy(bcc, "");
                }
 
-               valid_to = validate_recipients(recp);
+               valid_to = validate_recipients(recp, 0);
                if (valid_to->num_error > 0) {
                        cprintf("%d Invalid recipient (To)\n", ERROR + NO_SUCH_USER);
                        free_recipients(valid_to);
                        return;
                }
 
-               valid_cc = validate_recipients(cc);
+               valid_cc = validate_recipients(cc, 0);
                if (valid_cc->num_error > 0) {
                        cprintf("%d Invalid recipient (CC)\n", ERROR + NO_SUCH_USER);
                        free_recipients(valid_to);
@@ -3557,7 +3556,7 @@ void cmd_ent0(char *entargs)
                        return;
                }
 
-               valid_bcc = validate_recipients(bcc);
+               valid_bcc = validate_recipients(bcc, 0);
                if (valid_bcc->num_error > 0) {
                        cprintf("%d Invalid recipient (BCC)\n", ERROR + NO_SUCH_USER);
                        free_recipients(valid_to);
@@ -3684,7 +3683,7 @@ void cmd_ent0(char *entargs)
                strcat(all_recps, bcc);
        }
        if (!IsEmptyStr(all_recps)) {
-               valid = validate_recipients(all_recps);
+               valid = validate_recipients(all_recps, 0);
        }
        else {
                valid = NULL;
@@ -4402,7 +4401,7 @@ int CtdlIsMe(char *addr, int addr_buf_len)
        struct recptypes *recp;
        int i;
 
-       recp = validate_recipients(addr);
+       recp = validate_recipients(addr, 0);
        if (recp == NULL) return(0);
 
        if (recp->num_local == 0) {
index 61800c76f9cabcdc9ad986a5105f2322a9865335..e4f3854cc45414375d61631eb92de78edb7a6539 100644 (file)
@@ -167,7 +167,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                struct ctdluser *which_user, struct ctdlroom *which_room);
 void CtdlGetSeen(char *buf, int which_set);
 
-struct recptypes *validate_recipients(char *recipients);
+struct recptypes *validate_recipients(char *recipients, int Flags);
 void free_recipients(struct recptypes *);
 
 struct CtdlMessage *CtdlMakeMessage(
index 866e508a1a7b640baa5c64efcfc872c4e89e2fa3..2c1228b87888d38de33d0ac366688eb586841347 100644 (file)
@@ -422,7 +422,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
                * is an e-mail address
                */
                if (found_user != 0) {
-                       valid = validate_recipients(username);
+                       valid = validate_recipients(username, 0);
                        if (valid != NULL) {
                                if (valid->num_local == 1) {
                                        found_user = getuser(&CC->user, valid->recp_local);