]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Add .filename.lock file to lock against. Only allow addresses with a @ in them. 1.2.3
authormmj <none@none>
Mon, 7 Feb 2005 19:37:40 +0000 (06:37 +1100)
committermmj <none@none>
Mon, 7 Feb 2005 19:37:40 +0000 (06:37 +1100)
ChangeLog
README
VERSION
src/mlmmj-sub.c
src/mlmmj-unsub.c

index e525c2226f6ed3518020c27cf294d90d3e4f5f47..4717c557ccf79fcc7b1c7896bd15b439fad1ca31 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
- o In case of listname+bounces-INDEX use the DSN (RFC1891) to extract
+1.2.3
+ o Only allow subscription of addresses with '@' in them
+ o Add extra lock layer (.filename.lock) when accessing subscribers files
+ o In case of listname+bounces-INDEX use the DSN (RFC1891) report to extract
    the bouncing address
  o Fix usage of a zero sized control/verp string
  o Make the Date: header RFC2822 conformant
diff --git a/README b/README
index 7c8a08393c9ff46ca0e36e0430cd643b0b42fd7c..6aeb42b63e3abc125c15dbaa1dd995ae0c4d7c5c 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README mlmmj-1.2.2                                     February 1st 2005
+README mlmmj-1.2.3                                     February 7th 2005
 
 This is an attempt at implementing a mailing list manager with the same
 functionality as the brilliant ezmlm, but with a decent license and mail server
@@ -19,6 +19,7 @@ The functionality:
  · Digests
  · No mail delivery subscription
  · VERP support
+ · Delivery Status Notification (RFC1891) support
 
 To use mlmmj, do the following:
 
diff --git a/VERSION b/VERSION
index 23aa8390630cc1ae7f102ddd472e4ba48b689844..0495c4a88caed0f036ffab0948c17d4b5fdc96c1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.2
+1.2.3
index 648dffac95b4ec1befc992a4df045cb23edef53b..4a53472e14e3455c317e19dcadf798250b27739d 100644 (file)
@@ -244,9 +244,10 @@ int main(int argc, char **argv)
 {
        char *listaddr, *listdir = NULL, *address = NULL, *subfilename = NULL;
        char *mlmmjsend, *bindir, chstr[2], *subdir, *subddirname = NULL;
+       char *sublockname;
        int subconfirm = 0, confirmsub = 0, opt, subfilefd, lock, notifysub;
        int changeuid = 1, status, digest = 0, nomail = 0;
-       int groupwritable = 0;
+       int groupwritable = 0, sublock, sublockfd;
        size_t len;
        off_t suboff;
        struct stat st;
@@ -300,6 +301,12 @@ int main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
+       if(strchr(address, '@') == NULL) {
+               log_error(LOG_ARGS, "No '@' sign in '%s', not subscribing",
+                               address);
+               exit(EXIT_SUCCESS);
+       }
+
        if(digest && nomail) {
                fprintf(stderr, "Specify either -d or -n, not both\n");
                fprintf(stderr, "%s -h for help\n", argv[0]);
@@ -365,6 +372,24 @@ int main(int argc, char **argv)
        subfilename = concatstr(3, listdir, subdir, chstr);
        myfree(subdir);
 
+       sublockname = concatstr(5, listdir, subdir, ".", chstr, ".lock");
+       sublockfd = open(sublockname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+       if(sublockfd < 0) {
+               log_error(LOG_ARGS, "Error opening lock file %s",
+                               sublockname);
+               myfree(sublockname);
+               exit(EXIT_FAILURE);
+       }
+
+       sublock = myexcllock(sublockfd);
+       if(sublock < 0) {
+               log_error(LOG_ARGS, "Error locking '%s' file",
+                               sublockname);
+               myfree(sublockname);
+               close(sublockfd);
+               exit(EXIT_FAILURE);
+       }
+
        subfilefd = open(subfilename, O_RDWR|O_CREAT,
                                S_IRUSR|S_IWUSR|groupwritable);
        if(subfilefd == -1) {
index cc57f8bab78b76125967286b776c92aeccb66cec..fc9deda05e9f8f1f063e78350e17542248d1bda8 100644 (file)
@@ -231,29 +231,34 @@ ssize_t unsubscribe(int subreadfd, int subwritefd, const char *address)
        struct stat st;
        char *inmap;
        size_t len = strlen(address) + 1; /* + 1 for the '\n' */
-       ssize_t writeres, written = 0;
+       ssize_t writeres = 0, written = 0;
        
        if(suboff == -1)
-               return 1; /* Did not find subscriber */
+               return -1; /* Did not find subscriber */
 
        if(fstat(subreadfd, &st) < 0) {
-               log_error(LOG_ARGS, "Could not stat fd");
-               return 1;
+               log_error(LOG_ARGS, "Could not stat subreadfd");
+               return -1;
        }
 
        if((inmap = mmap(0, st.st_size, PROT_READ, MAP_SHARED,
                       subreadfd, 0)) == MAP_FAILED) {
-               log_error(LOG_ARGS, "Could not mmap fd");
-               return 1;
+               log_error(LOG_ARGS, "Could not mmap subreadfd");
+               return -1;
        }
 
-       if((writeres = writen(subwritefd, inmap, suboff)) < 0)
-               return -1;
+       if(suboff > 0) {
+               writeres = writen(subwritefd, inmap, suboff);
+               if(writeres < 0)
+                       return -1;
+       }
        written += writeres;
        
-       if((writeres = writen(subwritefd, inmap + suboff + len,
-                                       st.st_size - len - suboff) < 0))
+       writeres = writen(subwritefd, inmap + len + suboff,
+                               st.st_size - len - suboff);
+       if(writeres < 0)
                return -1;
+
        written += writeres;
 
        munmap(inmap, st.st_size);
@@ -283,10 +288,10 @@ int main(int argc, char **argv)
 {
        int subread, subwrite, rlock, wlock, opt, unsubres, status, nomail = 0;
        int confirmunsub = 0, unsubconfirm = 0, notifysub = 0, digest = 0;
-       int changeuid = 1, groupwritable = 0;
+       int changeuid = 1, groupwritable = 0, sublock, sublockfd;
        char *listaddr, *listdir = NULL, *address = NULL, *subreadname = NULL;
        char *subwritename, *mlmmjsend, *bindir, *subdir;
-       char *subddirname;
+       char *subddirname, *sublockname;
        off_t suboff;
        DIR *subddir;
        struct dirent *dp;
@@ -439,25 +444,50 @@ int main(int argc, char **argv)
                        continue;
                }
 
+               /* create a .name.lock file and aquire the lock */
+               sublockname = concatstr(5, listdir, subdir, ".", dp->d_name,
+                                       ".lock");
+               sublockfd = open(sublockname, O_RDWR | O_CREAT,
+                                               S_IRUSR | S_IWUSR);
+               if(sublockfd < 0) {
+                       log_error(LOG_ARGS, "Error opening lock file %s",
+                                       sublockname);
+                       myfree(sublockname);
+                       continue;
+               }
+
+               sublock = myexcllock(sublockfd);
+               if(sublock < 0) {
+                       log_error(LOG_ARGS, "Error locking '%s' file",
+                                       sublockname);
+                       myfree(sublockname);
+                       close(sublockfd);
+                       continue;
+               }
+               
                rlock = myexcllock(subread);
                if(rlock < 0) {
                        log_error(LOG_ARGS, "Error locking '%s' file",
                                        subreadname);
                        close(subread);
+                       close(sublockfd);
                        myfree(subreadname);
+                       myfree(sublockname);
                        continue;
                }
 
                subwritename = concatstr(2, subreadname, ".new");
 
-               subwrite = open(subwritename, O_RDWR | O_CREAT | O_EXCL,
+               subwrite = open(subwritename, O_RDWR | O_CREAT | O_TRUNC,
                                S_IRUSR | S_IWUSR | groupwritable);
                if(subwrite == -1){
                        log_error(LOG_ARGS, "Could not open '%s'",
                                        subwritename);
                        close(subread);
+                       close(sublockfd);
                        myfree(subreadname);
                        myfree(subwritename);
+                       myfree(sublockname);
                        continue;
                }
 
@@ -467,8 +497,10 @@ int main(int argc, char **argv)
                                        subwritename);
                        close(subread);
                        close(subwrite);
+                       close(sublockfd);
                        myfree(subreadname);
                        myfree(subwritename);
+                       myfree(sublockname);
                        continue;
                }
 
@@ -476,14 +508,14 @@ int main(int argc, char **argv)
                if(unsubres < 0) {
                        close(subread);
                        close(subwrite);
+                       close(sublockfd);
                        unlink(subwritename);
                        myfree(subreadname);
                        myfree(subwritename);
+                       myfree(sublockname);
                        continue;
                }
 
-               unlink(subreadname);
-
                if(unsubres > 0) {
                        if(rename(subwritename, subreadname) < 0) {
                                log_error(LOG_ARGS,
@@ -495,13 +527,18 @@ int main(int argc, char **argv)
                                myfree(subwritename);
                                continue;
                        }
-               } else /* unsubres == 0, no subscribers left */
+               } else /* unsubres == 0, no subscribers left */
                        unlink(subwritename);
+                       unlink(subreadname);
+               }
 
                close(subread);
                close(subwrite);
+               close(sublockfd);
                myfree(subreadname);
                myfree(subwritename);
+               unlink(sublockname);
+               myfree(sublockname);
 
                if(confirmunsub) {
                        childpid = fork();