OSSP CVS Repository

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

Check-in Number: 312
Date: 2001-Jan-19 13:49:44 (local)
2001-Jan-19 12:49:44 (UTC)
User:simons
Branch:
Comment: Petidomo needs to know the path to the executable in order to write the ack-spool file, which starts Petidomo again to process the acknowledged command or posting. I used BINDIR for that, but realized that this sucks when somebody manually moves the binary. Hence, I am using the contents of argv[0] now, normalized to an absolute path. This value is stored in the global variable who_am_i, which the queue_*() routines now use.
Tickets:
Inspections:
Files:
ossp-pkg/petidomo/main.c      1.9 -> 1.10     22 inserted, 1 deleted
ossp-pkg/petidomo/petidomo.h      1.16 -> 1.17     2 inserted, 1 deleted
ossp-pkg/petidomo/queue_command.c      1.3 -> 1.4     2 inserted, 2 deleted
ossp-pkg/petidomo/queue_posting.c      1.3 -> 1.4     2 inserted, 2 deleted

ossp-pkg/petidomo/main.c 1.9 -> 1.10

--- main.c       2001/01/18 20:30:50     1.9
+++ main.c       2001/01/19 12:49:44     1.10
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/main.c,v $
-   $Revision: 1.9 $
+   $Revision: 1.10 $
 
    Copyright (C) 2000 by CyberSolutions GmbH, Germany.
 
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include "libargv/argv.h"
+#include "libtext/text.h"
 #include "petidomo.h"
 
 #ifndef LOG_PERROR
@@ -34,6 +35,7 @@
 static char*  mode = NULL;
 static char*  masterconfig_path = SYSCONFDIR "/petidomo.conf";
 char          g_is_approved = ARGV_FALSE;
+const char* who_am_i;
 
 int
 main(int argc, char * argv[])
@@ -54,6 +56,25 @@
 
     openlog("petidomo", LOG_CONS | LOG_PID | LOG_PERROR, LOG_MAIL);
 
+    /* Store our full path and program name in who_am_I, so that
+       queue_posting() and queue_command() know where to find the
+       Petidomo binary. */
+
+    if (argv[0][0] == '/')
+        {
+        who_am_i = argv[0];
+        }
+    else
+        {
+        char buf[4096];
+        if (getcwd(buf, sizeof(buf)) == NULL)
+            {
+            syslog(LOG_CRIT, "Failed to get the path to my current working directory.");
+            exit(1);
+            }
+        who_am_i = text_easy_sprintf("%s/%s", buf, argv[0]);
+        }
+
     /* Parse the command line. */
 
     argv_help_string = "Petidomo Mailing List Server";


ossp-pkg/petidomo/petidomo.h 1.16 -> 1.17

--- petidomo.h   2001/01/18 20:30:50     1.16
+++ petidomo.h   2001/01/19 12:49:44     1.17
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v $
-   $Revision: 1.16 $
+   $Revision: 1.17 $
 
    Copyright (C) 2000 by CyberSolutions GmbH, Germany.
 
@@ -51,6 +51,7 @@
 /********** main.c **********/
 
 extern char g_is_approved;
+extern const char* who_am_i;
 
 /********** config.c **********/
 


ossp-pkg/petidomo/queue_command.c 1.3 -> 1.4

--- queue_command.c      2001/01/18 20:30:50     1.3
+++ queue_command.c      2001/01/19 12:49:44     1.4
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/Attic/queue_command.c,v $
-   $Revision: 1.3 $
+   $Revision: 1.4 $
 
    Copyright (C) 2000 by Peter Simons <simons@computer.org>.
 
@@ -39,7 +39,7 @@
         }
     fprintf(fh, "#! /bin/sh\n");
     fprintf(fh, "\n");
-    fprintf(fh, BINDIR "/petidomo --mode=listserv --approved <<[end-of-mail-marker]\n");
+    fprintf(fh, "%s --mode=listserv --approved <<[end-of-mail-marker]\n", who_am_i);
     fprintf(fh, "Sender: %s\n", mail->Envelope);
     fprintf(fh, "From: %s\n", mail->From);
     if (mail->Reply_To)


ossp-pkg/petidomo/queue_posting.c 1.3 -> 1.4

--- queue_posting.c      2001/01/18 20:30:50     1.3
+++ queue_posting.c      2001/01/19 12:49:44     1.4
@@ -1,6 +1,6 @@
 /*
    $Source: /v/ossp/cvs/ossp-pkg/petidomo/Attic/queue_posting.c,v $
-   $Revision: 1.3 $
+   $Revision: 1.4 $
 
    Copyright (C) 2000 by Peter Simons <simons@computer.org>.
 
@@ -39,7 +39,7 @@
         }
     fprintf(fh, "#! /bin/sh\n");
     fprintf(fh, "\n");
-    fprintf(fh, BINDIR "/petidomo --mode=deliver --listname=%s --approved <<[end-of-mail-marker]\n", listname);
+    fprintf(fh, "%s --mode=deliver --listname=%s --approved <<[end-of-mail-marker]\n", who_am_i, listname);
     fprintf(fh, "%s\n", mail->Header);
     fprintf(fh, "%s", mail->Body);
     fprintf(fh, "[end-of-mail-marker]\n");

CVSTrac 2.0.1