X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Flistsub%2Fserv_listsub.c;h=ae41d1746f8b3a639b5564ac1a51dc53273f7d47;hb=924b8cd997f56b68e16fa1dfc1be55722596f5d8;hp=a9fd95bfb8761a8706c2fc1af3f644fa55e5f761;hpb=6f0f2b51a2ccb6873d3b2c8ecb075535d2516729;p=citadel.git diff --git a/citadel/modules/listsub/serv_listsub.c b/citadel/modules/listsub/serv_listsub.c index a9fd95bfb..ae41d1746 100644 --- a/citadel/modules/listsub/serv_listsub.c +++ b/citadel/modules/listsub/serv_listsub.c @@ -1,15 +1,15 @@ /* * This module handles self-service subscription/unsubscription to mail lists. * - * Copyright (c) 2002-2012 by the citadel.org team + * Copyright (c) 2002-2016 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include "sysdep.h" @@ -48,7 +48,6 @@ #include "msgbase.h" #include "internet_addressing.h" #include "clientsocket.h" -#include "file_ops.h" #include "ctdl_module.h" /* @@ -58,17 +57,21 @@ void listsub_generate_token(char *buf) { char sourcebuf[SIZ]; static int seq = 0; + size_t len; /* Theo, please sit down and shut up. This key doesn't have to be * tinfoil-hat secure, it just needs to be reasonably unguessable * and unique. */ - sprintf(sourcebuf, "%lx", + len = sprintf(sourcebuf, "%lx", (long) (++seq + getpid() + time(NULL)) ); /* Convert it to base64 so it looks cool */ - CtdlEncodeBase64(buf, sourcebuf, strlen(sourcebuf), 0); + len = CtdlEncodeBase64(buf, sourcebuf, len, 0); + if (buf[len - 1] == '\n') { + buf[len - 1] = '\0'; + } } const RoomNetCfg ActiveSubscribers[] = {listrecp, digestrecp}; @@ -131,7 +134,7 @@ void do_subscribe(StrBuf **room, StrBuf **email, StrBuf **subtype, StrBuf **webp RoomMailAddress = qrbuf.QRname; OneRNCfg = CtdlGetNetCfgForRoom(qrbuf.QRnumber); - if (OneRNCfg!=NULL) { + if (OneRNCfg != NULL) { found_sub = CountThisSubscriber(OneRNCfg, *email); if (StrLength(OneRNCfg->Sender) > 0) { EmailSender = RoomMailAddress = ChrPtr(OneRNCfg->Sender); @@ -144,6 +147,7 @@ void do_subscribe(StrBuf **room, StrBuf **email, StrBuf **subtype, StrBuf **webp ChrPtr(*email), RoomMailAddress); + FreeRoomNetworkStruct(&OneRNCfg); end_critical_section(S_NETCONFIGS); return; } @@ -267,6 +271,8 @@ void do_subscribe(StrBuf **room, StrBuf **email, StrBuf **subtype, StrBuf **webp "\n" "--__ctdlmultipart__--\n"), 0); + SaveRoomNetConfigFile(OneRNCfg, qrbuf.QRnumber); + FreeRoomNetworkStruct(&OneRNCfg); end_critical_section(S_NETCONFIGS); pcf_req = SmashStrBuf(&cf_req); @@ -330,11 +336,8 @@ void do_unsubscribe(StrBuf **room, StrBuf **email, StrBuf **webpage) { } if (found_sub == 0) { - cprintf("%d '%s' is not subscribed to '%s'.\n", - ERROR + NO_SUCH_USER, - ChrPtr(*email), - qrbuf.QRname); - + cprintf("%d '%s' is not subscribed to '%s'.\n", ERROR + NO_SUCH_USER, ChrPtr(*email), qrbuf.QRname); + FreeRoomNetworkStruct(&OneRNCfg); end_critical_section(S_NETCONFIGS); return; } @@ -458,6 +461,8 @@ void do_unsubscribe(StrBuf **room, StrBuf **email, StrBuf **webpage) { "\n" "--__ctdlmultipart__--\n"), 0); + SaveRoomNetConfigFile(OneRNCfg, qrbuf.QRnumber); + FreeRoomNetworkStruct(&OneRNCfg); end_critical_section(S_NETCONFIGS); pcf_req = SmashStrBuf(&cf_req); @@ -589,8 +594,6 @@ void do_confirm(StrBuf **room, StrBuf **token) { else { /* whipe duplicate subscribe entry... */ - OneRNCfg->changed = 1; - SaveChangedConfigs(); errmsg = "already subscribed"; } } @@ -633,10 +636,10 @@ void do_confirm(StrBuf **room, StrBuf **token) { errmsg = "no subscriber found for this unsubscription request"; } DeleteGenericCfgLine(NULL/*TODO*/, &ConfirmLine); - OneRNCfg->changed = 1; - SaveChangedConfigs(); } + SaveRoomNetConfigFile(OneRNCfg, qrbuf.QRnumber); + FreeRoomNetworkStruct(&OneRNCfg); end_critical_section(S_NETCONFIGS); /*