I want username and auth method in mailheaders.
pbs* allows the storage of env variables for the IP. great, but
unfortunately, auth_* writes the username to USER and qmail-smtpd needs it
in TCPREMOTEINFO. As shellscripts or perl or the like would have a hughe
performance penalty here, I wrote pbsset. I decided against a patch to
pbscheck, this would cause maintainance problems in the long run.

maybe someone has a use for it...

--- TARGETS.orig        Thu May 16 17:05:08 2002
+++ TARGETS     Thu May 16 17:06:20 2002
@@ -420,9 +420,11 @@
 pbscheck.o
 pbsdbd.o
 pbsadd.o
+pbsset.o
 pbscheck
 pbsadd
 pbsdbd
+pbsset
 qmail-todo.o
 qmail-todo
 byte_repl.o
--- FILES.orig  Thu May 16 17:04:54 2002
+++ FILES       Thu May 16 17:06:35 2002
@@ -477,6 +477,7 @@
 pbscheck.c
 pbsdbd.c
 pbsadd.c
+pbsset.c
 POPBEFORESMTP
 qmail-todo.c
 byte_repl.c
--- install-big.c.orig  Thu May 16 17:05:25 2002
+++ install-big.c       Thu May 16 17:06:01 2002
@@ -159,6 +159,7 @@
   c(auto_qmail,"bin","pbsadd",auto_uido,auto_gidq,0755);
   c(auto_qmail,"bin","pbscheck",auto_uido,auto_gidq,0755);
   c(auto_qmail,"bin","pbsdbd",auto_uido,auto_gidq,0755);
+  c(auto_qmail,"bin","pbsset",auto_uido,auto_gidq,0755);
   
   c(auto_qmail,"man/man5","addresses.5",auto_uido,auto_gidq,0644);
   c(auto_qmail,"man/cat5","addresses.0",auto_uido,auto_gidq,0644);
--- pbsset.c.orig       Thu May 16 17:00:15 2002
+++ pbsset.c    Thu May 16 17:33:43 2002
@@ -0,0 +1,56 @@
+/* pbsset.c, (c) 2002 Henning Brauer <[EMAIL PROTECTED]> */
+/* BSD-Licensed */
+
+#include "alloc.h"
+#include "byte.h"
+#include "env.h"
+#include "error.h" 
+#include "exit.h"
+#include "readwrite.h" 
+#include "stralloc.h"
+#include "substdio.h"
+
+char sserrbuf[128];
+substdio sserr = SUBSTDIO_FDBUF(write,2,sserrbuf,sizeof sserrbuf);
+
+char **childargs;
+
+static void log(char* s)
+{
+  substdio_puts(&sserr,s);
+  substdio_puts(&sserr,"\n");
+  substdio_flush(&sserr);  
+}
+
+static void die() { _exit(1); }
+void die_usage() { log("usage: pbsset subprogram ..."); die(); }
+void die_exec() { log("pbsset unable to exec subprogram"); die(); }
+void log_nomem()
+{
+  log("pbsset out of memory"); 
+  execvp(*childargs,childargs);
+  /* should never reach this point */
+  die_exec();
+}
+
+void main(int argc, char **argv)
+{
+   stralloc remoteinfo = {0};
+   char *authuser;
+   
+   childargs = argv + 1;
+   if (!*childargs) die_usage();
+   
+   if ( authuser = env_get("USER") ) {
+     if (!stralloc_copys(&remoteinfo, authuser)) log_nomem();
+   } else {
+     if (!stralloc_cats(&remoteinfo, "unknown")) log_nomem();      
+   }
+   if (!stralloc_cats(&remoteinfo, "[pbs]")) log_nomem();
+   if (!stralloc_0(&remoteinfo)) log_nomem();
+   if (!env_put2("TCPREMOTEINFO", remoteinfo.s)) log_nomem(); 
+
+   execvp(*childargs,childargs);
+   /* should never reach this point */
+   die_exec();
+}


-- 
| Henning Brauer  | PGP-Key: http://misc.bsws.de/hb/pubkey.asc          
| BS Web Services | Roedingsmarkt 14, 20459 Hamburg, DE | http://bsws.de
Unix is very simple, but it takes a genius to understand the simplicity.
(Dennis Ritchie)

Reply via email to