// This file contains functions which handle the mapping of Internet addresses
// to users on the Citadel system.
//
-// Copyright (c) 1987-2021 by the citadel.org team
+// Copyright (c) 1987-2022 by the citadel.org team
//
// This program is open source software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 3.
// If the last item in a list of recipients was truncated to a partial address,
// remove it completely in order to avoid choking library functions.
-void sanitize_truncated_recipient(char *str)
-{
+void sanitize_truncated_recipient(char *str) {
if (!str) return;
if (num_tokens(str, ',') < 2) return;
}
-/*
- * Configure Internet email addresses for a user account, updating the Directory Index in the process
- */
-void CtdlSetEmailAddressesForUser(char *requested_user, char *new_emailaddrs)
-{
+// Configure Internet email addresses for a user account, updating the Directory Index in the process
+void CtdlSetEmailAddressesForUser(char *requested_user, char *new_emailaddrs) {
struct ctdluser usbuf;
int i;
char buf[SIZ];
- if (CtdlGetUserLock(&usbuf, requested_user) != 0) { // We are relying on the fact that the DirectoryIndex functions don't lock.
- return; // Silently fail here if we can't acquire a lock on the user record.
+ if (CtdlGetUserLock(&usbuf, requested_user) != 0) { // We can lock because the DirectoryIndex functions don't lock.
+ return; // Silently fail here if the specified user does not exist.
}
syslog(LOG_DEBUG, "internet_addressing: setting email addresses for <%s> to <%s>", usbuf.fullname, new_emailaddrs);
- /* Delete all of the existing directory index records for the user (easier this way) */
+ // Delete all of the existing directory index records for the user (easier this way)
for (i=0; i<num_tokens(usbuf.emailaddrs, '|'); ++i) {
extract_token(buf, usbuf.emailaddrs, i, '|', sizeof buf);
CtdlDirectoryDelUser(buf, requested_user);
strcpy(usbuf.emailaddrs, new_emailaddrs); // make it official.
- /* Index all of the new email addresses (they've already been sanitized) */
+ // Index all of the new email addresses (they've already been sanitized)
for (i=0; i<num_tokens(usbuf.emailaddrs, '|'); ++i) {
extract_token(buf, usbuf.emailaddrs, i, '|', sizeof buf);
CtdlDirectoryAddUser(buf, requested_user);
if (CtdlGetRoom(&room, room_name)) {
return(0); // room not found, so definitely not subscribed
}
+
+ // If this room has the QR2_SMTP_PUBLIC flag set, anyone may email a post to this room, even non-subscribers.
+ if (room.QRflags2 & QR2_SMTP_PUBLIC) {
+ return(1);
+ }
+
roomnum = room.QRnumber;
roomnetconfig = LoadRoomNetConfigFile(roomnum);
if (roomnetconfig == NULL) {