Hello,

In my upgrade from qadmin-tmda to TMDA-CGI on
our production mail server I noticed that TMDA-CGI
is currently lacking the ability to determine a
vpopmail user's domain name properly at auto-install
time.

Authentication works properly, but TMDA-CGI
uses "localhost" for all vpopmail user's %(Domain)s
variables during auto-installation.

Please see attached for a patch to Session.py
and a new script to be placed in the "stubs"
directory alongside the existing "vpopmail1.py":
vpopmaildom.py

Together, these two pieces make it possible to
successfully use TMDA-CGI's auto-installation
with the vpopmail virtual domain manager.

However, please note that the patch DOES NOT include
the necessary TMDA-CGI configure logic required to
*BUILD* the TMDA-CGI C wrapper with the new
TMDA_VDOMLOOKUP environment variable set! Perhaps
Gre7g can add this logic in the future, but for
now I am simply putting this in my Apache config
to set the environment variable at run time:

<Location /cgi-bin/tmda.cgi>
Setenv TMDA_VDOMLOOKUP "vpopmaildom /usr/local/vpopmail/bin/vuserinfo ~"
Options FollowSymlinks
Order allow,deny
Allow from all
</Location>


Thanks!

-- 
Jesse Guardiani, Systems Administrator
WingNET Internet Services,
P.O. Box 2605 // Cleveland, TN 37320-2605
423-559-LINK (v)  423-559-5145 (f)
http://www.wingnet.net
--- Session.py.bak.20040925	2004-09-26 00:42:26.000000000 -0400
+++ Session.py	2004-09-26 02:33:48.000000000 -0400
@@ -261,6 +261,7 @@
     if Match:
       self.Vars["HOME"] = Match.group(1)
     os.environ["HOME"] = self.Vars["HOME"]
+    os.environ["DOMAIN"] = self.Vars["DOMAIN"]
     self.__suid__("user")
     self.Valid = 1
 
@@ -407,6 +408,28 @@
       Template.Template.Dict["ErrMsg"] = \
         "Username %s not found in system.\nstr=%s" % (self.Vars["User"], str)
       return
+    try:
+      if os.environ.has_key("TMDA_VDOMLOOKUP"):
+        self.Vars["DOMAIN"] = "localhost"
+        VDomLookup = \
+          CgiUtil.ParseString(os.environ["TMDA_VDOMLOOKUP"], self.Vars["User"])
+        List = Util.RunTask(VDomLookup[1:])
+        Sandbox = {"User": self.Vars["User"]}
+        Filename = os.path.join("stubs", "%s.py" % VDomLookup[0])
+        try:
+          execfile(Filename, Sandbox)
+        except IOError:
+          CgiUtil.TermError("Can't load virtual user stub.",
+            "Cannot execute %s" % Filename, "execute stub",
+            "TMDA_VDOMLOOKUP = %s" % os.environ["TMDA_VDOMLOOKUP"], "Recompile CGI.")
+        Params = Sandbox["getuserparams"](List)
+	self.Vars["DOMAIN"] = Params
+      else:
+        self.Vars["DOMAIN"] = "localhost"
+    except KeyError, str:
+      Template.Template.Dict["ErrMsg"] = \
+        "Domain for user %s not found in system.\nstr=%s\n<br>domain=%s" % (self.Vars["User"], str, self.Vars["DOMAIN"])
+      return
     # When getuserparams returns a UID of 0 or 1, assume it is a virtual user
     if int(self.Vars["UID"]) < 2:
       PasswordRecord = pwd.getpwnam(os.environ["TMDA_VUSER"])

Attachment: vpopmaildom.py
Description: application/python

_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to