OSSP CVS Repository

ossp - Check-in [286]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 286
Date: 2001-Jan-16 12:33:36 (local)
2001-Jan-16 11:33:36 (UTC)
User:simons
Branch:
Comment: Implemented the acked-once feature.
Tickets:
Inspections:
Files:
ossp-pkg/petidomo/Makefile.in      1.23 -> 1.24     1 inserted, 1 deleted
ossp-pkg/petidomo/address-db.c      added-> 1.1
ossp-pkg/petidomo/hermes.c      1.10 -> 1.11     55 inserted, 1 deleted
ossp-pkg/petidomo/petidomo.h      1.14 -> 1.15     6 inserted, 1 deleted

ossp-pkg/petidomo/Makefile.in 1.23 -> 1.24

--- Makefile.in  2001/01/15 18:48:49     1.23
+++ Makefile.in  2001/01/16 11:33:36     1.24
@@ -27,7 +27,7 @@
                   filter.o handleacl.o help.o hermes.o index.o io.o listserv.o \
                   mailer.o members.o parsearray.o password.o rfcparse.o \
                   subscribe.o tool.o unsubscribe.o main.o queue_command.o \
-                  queue_posting.o approve.o
+                  queue_posting.o approve.o address-db.o
 LIBS            = librfc822/librfc822.a libmpools/libmpools.a liblists/liblists.a libargv/libargv.a \
                   libconfigfile/libconfigfile.a libtext/libtext.a
 


ossp-pkg/petidomo/address-db.c -> 1.1

*** /dev/null    Sat Nov 23 01:10:18 2024
--- -    Sat Nov 23 01:10:29 2024
***************
*** 0 ****
--- 1,78 ----
+ /*
+    $Source: /v/ossp/cvs/ossp-pkg/petidomo/address-db.c,v $
+    $Revision: 1.1 $
+ 
+    Copyright (C) 2000 by Peter Simons <simons@computer.org>
+ 
+    This file is part of OpenPetidomo.
+ 
+    OpenPetidomo is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2, or (at your option)
+    any later version.
+ 
+    OpenPetidomo 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 <string.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include "libtext/text.h"
+ #include "petidomo.h"
+ 
+ /*
+  * rc ==  0: Address is not on list.
+  * rc == -1: Error occured while reading the file.
+  * rc ==  1: Address is on list.
+  */
+ int is_address_on_list(const char* file, const char* address)
+     {
+     char *         list;
+     char *         p;
+     unsigned int   len;
+     int            rc;
+ 
+     list = loadfile(file);
+     if (list == NULL)
+        {
+        if (errno == ENOENT)
+            return 0;
+        else
+            return -1;
+        }
+ 
+     for (len = strlen(address), p = list; *p != '\0'; p = text_find_next_line(p))
+        {
+        if (strncasecmp(p, address, len) == 0 &&
+            (p == list || p[-1] == '\n') &&
+            (isspace((int)p[len]) || p[len] == '\0'))
+            {
+            break;
+            }
+        }
+ 
+     rc = ((*p != '\0') ? 1 : 0);
+     free(list);
+     return rc;
+     }
+ 
+ int add_address(const char* file, const char* address)
+     {
+     FILE* fh;
+     int rc = is_address_on_list(file, address);
+     if (rc != 0)
+        return rc;
+ 
+     fh = fopen(file, "a");
+     if (fh == NULL)
+        {
+        syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %m", file);
+        return -1;
+        }
+     fprintf(fh, "%s\n", address);
+     fclose(fh);
+     return 0;
+     }


ossp-pkg/petidomo/hermes.c 1.10 -> 1.11

--- hermes.c     2001/01/16 10:45:21     1.10
+++ hermes.c     2001/01/16 11:33:36     1.11
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/hermes.c,v $
-   $Revision: 1.10 $
+   $Revision: 1.11 $
 
    Copyright (C) 2000 by CyberSolutions GmbH, Germany.
 
@@ -199,6 +199,60 @@
                 }
             return 0;
             }
+
+        else if (ListConfig->listtype == LIST_ACKED_ONCE)
+            {
+            /* First posting needs an acknowledgement. */
+
+            if (g_is_approved)
+                {
+                int rc = add_address(ListConfig->ack_file, MailStruct->From);
+                if (rc < 0)
+                    {
+                    syslog(LOG_ERR, "Can't add address to ack file.");
+                    return -1;
+                    }
+                }
+            else
+                {
+                int rc = is_address_on_list(ListConfig->ack_file, MailStruct->From);
+                if (rc == 0)
+                    rc = is_address_on_list(ListConfig->ack_file, MailStruct->Envelope);
+                if (rc < 0)
+                    {
+                    syslog(LOG_ERR, "Can't verify whether address \"%s\" needs to be acknowledged or not.", MailStruct->From);
+                    return -1;
+                    }
+                else if (rc == 0)
+                    {
+                    char* cookie = queue_posting(MailStruct, listname);
+                    fh = vOpenMailer(owner, MailStruct->Envelope, NULL);
+                    if (fh != NULL)
+                        {
+                        fprintf(fh, "From: petidomo-approve@%s (Petidomo Mailing List Server)\n", ListConfig->fqdn);
+                        fprintf(fh, "To: %s\n", MailStruct->Envelope);
+                        fprintf(fh, "Subject: Petidomo: CONFIRM %s@%s: Your posting to list \"%s\"\n",
+                                listname, ListConfig->fqdn, listname);
+                        fprintf(fh, "Precedence: junk\n");
+                        fprintf(fh, "Sender: %s\n", owner);
+                        fprintf(fh, "\n");
+                        fprintf(fh, "Your posting needs to be confirmed. Do this by replying\n");
+                        fprintf(fh, "to this mail and citing the string\n");
+                        fprintf(fh, "\n");
+                        fprintf(fh, "    %s\n", cookie);
+                        fprintf(fh, "\n");
+                        fprintf(fh, "in your reply. You won't have to do that again.\n");
+                        CloseMailer(fh);
+                        }
+                    else
+                        {
+                        syslog(LOG_ERR, "Failed to send email to \"%s\" concerning this request.", owner);
+                        return -1;
+                        }
+                    return 0;
+                    }
+                }
+            }
         }
 
     /* Copy the desired headers from the original mail to our own


ossp-pkg/petidomo/petidomo.h 1.14 -> 1.15

--- petidomo.h   2001/01/16 10:49:08     1.14
+++ petidomo.h   2001/01/16 11:33:36     1.15
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v $
-   $Revision: 1.14 $
+   $Revision: 1.15 $
 
    Copyright (C) 2000 by CyberSolutions GmbH, Germany.
 
@@ -251,4 +251,9 @@
 
 char* queue_command(const struct Mail* mail, const char* command);
 
+/********** address_db.c **********/
+
+int is_address_on_list(const char* file, const char* address);
+int add_address(const char* file, const char* address);
+
 #endif /* !defined(__PETIDOMO_H__) */

CVSTrac 2.0.1