From: mmj Date: Fri, 9 Sep 2005 10:11:58 +0000 (+1000) Subject: Fix mlmmj-sub to not be able to subscribe twice X-Git-Tag: RELEASE_1_2_12_RC1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cc2aa5fc51210db8f0a4a2bd8aadf28c82c96f2;p=thirdparty%2Fmlmmj.git Fix mlmmj-sub to not be able to subscribe twice --- diff --git a/ChangeLog b/ChangeLog index 1ea81cf4..427fcf2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + o Use is_subbed_in instead of find_subscriber when subscribing people + (Christian Laursen) o Make it possible to confirm subscription even though it's a closedlist. It makes sense to be able to confirm a request submitted by the sysadmin on the commandline diff --git a/src/mlmmj-sub.c b/src/mlmmj-sub.c index d2656445..5b1baf85 100644 --- a/src/mlmmj-sub.c +++ b/src/mlmmj-sub.c @@ -277,9 +277,8 @@ int main(int argc, char **argv) char *sublockname; int subconfirm = 0, confirmsub = 0, opt, subfilefd, lock, notifysub; int changeuid = 1, status, digest = 0, nomail = 0; - int groupwritable = 0, sublock, sublockfd, nogensubscribed = 0; + int groupwritable = 0, sublock, sublockfd, nogensubscribed = 0, subbed; size_t len; - off_t suboff; struct stat st; pid_t pid, childpid; uid_t uid; @@ -364,7 +363,20 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); /* XXX is this success? */ } - subddirname = concatstr(2, listdir, "/subscribers.d"); + switch(typesub) { + default: + case SUB_NORMAL: + subdir = "/subscribers.d/"; + break; + case SUB_DIGEST: + subdir = "/digesters.d/"; + break; + case SUB_NOMAIL: + subdir = "/nomailsubs.d/"; + break; + } + + subddirname = concatstr(2, listdir, subdir); if (stat(subddirname, &st) == 0) { if(st.st_mode & S_IWGRP) { groupwritable = S_IRGRP|S_IWGRP; @@ -389,19 +401,6 @@ int main(int argc, char **argv) chstr[0] = address[0]; chstr[1] = '\0'; - switch(typesub) { - default: - case SUB_NORMAL: - subdir = "/subscribers.d/"; - break; - case SUB_DIGEST: - subdir = "/digesters.d/"; - break; - case SUB_NOMAIL: - subdir = "/nomailsubs.d/"; - break; - } - subfilename = concatstr(3, listdir, subdir, chstr); sublockname = concatstr(5, listdir, subdir, ".", chstr, ".lock"); @@ -438,8 +437,8 @@ int main(int argc, char **argv) myfree(sublockname); exit(EXIT_FAILURE); } - suboff = find_subscriber(subfilefd, address); - if(suboff == -1) { + subbed = is_subbed_in(subddirname, address); + if(subbed) { if(subconfirm) { close(subfilefd); close(sublockfd);