Re: cvm-vmailmgr lookup problem (internal temporary error)

Scott Gifford <[email protected]> Thu, 15 Sep 2005 00:02:24 -0400
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
Josh Trutwin <[email protected]> writes:

> On Wed, 14 Sep 2005 22:28:29 -0400
> Scott Gifford <[email protected]> wrote:
>
>> Yeah.  Lately I've been modifying my CVM installations to support
>> distinct "I dunno" and "No such user" exit codes, which makes a
>> setup like this possible (if cvm-vmailmgr says "I dunno" cvm-chain
>> goes on to cvm-qmail, but if it says "I *do* know and there's no
>> such user" cvm-chain reports failure).  I can probably dig out the
>> patches if anybody's interested.
>
> Please, I wouldn't mind looking at this.  

Here's a patch of what I'm currently using at one of my installations
vs. stock CVM 0.32; no guarantees about anything.  It creates a new
CVME_DONTKNOW error code.  If a module returns anything other than
CVME_DONTKNOW, cvm-chain won't look any further.  It contains a random
assortment of other, unrelated changes, too.  :)

----ScottG.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
cvm-0.32-sg2.patch (text/x-patch, 20.8 KB)
diff -ur cvm-0.32/Makefile cvm-0.32-sg2/Makefile
--- cvm-0.32/Makefile	Thu Mar 31 19:23:25 2005
+++ cvm-0.32-sg2/Makefile	Thu May 12 02:19:48 2005
@@ -112,6 +112,12 @@
 cvm-qmail.o: compile cvm-qmail.c module.h facts.h errors.h qmail.h
 	./compile cvm-qmail.c
 
+cvm-qmail-vmailmgr: load cvm-qmail-vmailmgr.o getpwnam.o vmlookup.o module.a qmail.a crypt.lib
+	./load cvm-qmail-vmailmgr getpwnam.o vmlookup.o module.a qmail.a -lbg `cat crypt.lib`
+
+cvm-qmail-vmailmgr.o: compile cvm-qmail-vmailmgr.c module.h facts.h errors.h qmail.h
+	./compile cvm-qmail-vmailmgr.c
+
 cvm-testclient: load cvm-testclient.o client.a socket.lib
 	./load cvm-testclient client.a -lbg `cat socket.lib`
 
@@ -127,9 +133,6 @@
 cvm-vmailmgr: load cvm-vmailmgr.o vmmain.o vmlookup.o getpwnam.o module.a qmail.a socket.lib crypt.lib
 	./load cvm-vmailmgr vmmain.o vmlookup.o getpwnam.o module.a qmail.a -lbg `cat socket.lib` `cat crypt.lib`
 
-cvm-vmlookup: load cvm-vmlookup.o vmmain.o vmlookup.o getpwnam.o module.a qmail.a socket.lib crypt.lib
-	./load cvm-vmailmgr vmmain.o vmlookup.o getpwnam.o module.a qmail.a -lbg `cat socket.lib` `cat crypt.lib`
-
 cvm-vmailmgr-local: load cvm-vmailmgr-local.o cvm-vmailmgr.o vmmain.o vmlookup.o getpwnam.o local.a qmail.a socket.lib crypt.lib
 	./load cvm-vmailmgr-local cvm-vmailmgr.o vmmain.o vmlookup.o getpwnam.o local.a qmail.a -lbg `cat socket.lib` `cat crypt.lib`
 
@@ -145,6 +148,18 @@
 cvm-vmailmgr.o: compile cvm-vmailmgr.c module.h facts.h errors.h cvm-vmailmgr.h
 	./compile cvm-vmailmgr.c
 
+cvm-anon: load cvm-anon.o command.a crypt.lib shadow.lib socket.lib s.lib
+	./load cvm-anon command.a client.a `cat socket.lib` `cat s.lib` -lbg-net
+
+cvm-anon.o: compile cvm-anon.c 
+	./compile cvm-anon.c
+
+cvm-chain: load cvm-chain.o module.a crypt.lib shadow.lib socket.lib s.lib
+	./load cvm-chain module.a client.a `cat socket.lib` `cat s.lib` -lbg-net
+
+cvm-chain.o: compile cvm-chain.c 
+	./compile cvm-chain.c
+
 facts.o: compile facts.c facts.h
 	./compile facts.c
 
@@ -188,8 +203,10 @@
 	) >makelib
 	chmod 755 makelib
 
-module.a: makelib facts.o module_command.o module_local.o module_log.o module_main.o module_output.o module_request.o module_udp.o
-	./makelib module.a facts.o module_command.o module_local.o module_log.o module_main.o module_output.o module_request.o module_udp.o
+module.a: makelib facts.o module_command.o module_local.o module_log.o module_main.o module_output.o \
+		module_request.o module_udp.o
+	./makelib module.a facts.o module_command.o module_local.o module_log.o module_main.o module_output.o \
+		module_request.o module_udp.o
 
 module_command.o: compile module_command.c module.h facts.h errors.h
 	./compile module_command.c
@@ -225,7 +242,7 @@
 
 pgsql: cvm-pgsql cvm-pgsql-local cvm-pgsql-udp
 
-programs: cvm-vmailmgr-udp sql-query-test cvm-testclient cvm-checkpassword cvm-vmailmgr cvm-qmail cvm-pwfile cvm-unix cvm-vmailmgr-local cvm-benchclient
+programs: cvm-vmailmgr-udp sql-query-test cvm-testclient cvm-checkpassword cvm-vmailmgr cvm-qmail cvm-pwfile cvm-unix cvm-vmailmgr-local cvm-benchclient cvm-anon cvm-chain
 
 qmail-domains.o: compile qmail-domains.c qmail.h
 	./compile qmail-domains.c
Only in cvm-0.32-sg2: Makefile~
Only in cvm-0.32-sg2: README.sg1.patch
diff -ur cvm-0.32/TARGETS cvm-0.32-sg2/TARGETS
--- cvm-0.32/TARGETS	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/TARGETS	Thu Mar 31 20:28:19 2005
@@ -20,6 +20,10 @@
 cvm-mysql-udp
 cvm-mysql-udp.o
 cvm-mysql.o
+cvm-anon
+cvm-anon.o
+cvm-chain
+cvm-chain.o
 cvm-pgsql
 cvm-pgsql-local
 cvm-pgsql-local.o
diff -ur cvm-0.32/client.h cvm-0.32-sg2/client.h
--- cvm-0.32/client.h	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/client.h	Thu Mar 31 20:55:59 2005
@@ -6,15 +6,34 @@
 
 #define CVM_PROTOCOL 1
 
-extern const char* cvm_account_split_chars;
-extern const char* cvm_ucspi_domain(void);
-extern int cvm_authenticate(const char* module, const char* account,
+extern const char* cvm_client_account_split_chars;
+extern const char* cvm_client_ucspi_domain(void);
+extern int cvm_client_authenticate(const char* module, const char* account,
 			    const char* domain, const char** credentials,
 			    int parse_account);
-extern int cvm_fact_str(int number, const char** data);
-extern int cvm_fact_uint(int number, unsigned long* data);
+extern int cvm_client_fact_str(int number, const char** data);
+extern int cvm_client_fact_uint(int number, unsigned long* data);
 
-extern int cvm_setugid(void);
-extern int cvm_setenv(void);
+extern int cvm_client_setugid(void);
+extern int cvm_client_setenv(void);
+
+/* legacy */
+#define cvm_account_split_chars	cvm_client_account_split_chars
+#define cvm_ucspi_domain	cvm_client_ucspi_domain
+#define cvm_setugid		cvm_client_setugid
+#define cvm_setenv		cvm_client_setenv
+
+/* can't be duplicated */
+#ifndef CVM__MODULE__H__
+# define cvm_authenticate	cvm_client_authenticate
+# define cvm_lookup	        cvm_client_lookup
+# define cvm_fact_str		cvm_client_fact_str
+# define cvm_fact_uint		cvm_client_fact_uint
+#else
+# undef cvm_authenticate
+# undef cvm_lookup
+# undef cvm_fact_str
+# undef cvm_fact_uint
+#endif
 
 #endif
Only in cvm-0.32-sg2: cvm-anon.c
Only in cvm-0.32-sg2: cvm-chain.c
Only in cvm-0.32-sg2: cvm-patch-0.31.sg1.dw.chain-anon.1-freebsd
Only in cvm-0.32-sg2: cvm-qmail-vmailmgr
Only in cvm-0.32-sg2: cvm-qmail-vmailmgr.c
Only in cvm-0.32-sg2: cvm-qmail-vmailmgr.c~
Only in cvm-0.32-sg2: cvm-qmail-vmailmgr.o
diff -ur cvm-0.32/cvm-qmail.c cvm-0.32-sg2/cvm-qmail.c
--- cvm-0.32/cvm-qmail.c	Sat May  7 10:38:55 2005
+++ cvm-0.32-sg2/cvm-qmail.c	Sat May  7 10:39:46 2005
@@ -75,7 +75,8 @@
   cvm_fact_sys_username = user.user.s;
   cvm_fact_sys_directory = user.homedir.s;
   cvm_fact_domain = domain.s;
-  cvm_fact_mailbox = user.homedir.s;
+/*  cvm_fact_mailbox = user.homedir.s; */
+  cvm_fact_mailbox = 0;
   return 0;
 }
 
diff -ur cvm-0.32/cvm-testclient.c cvm-0.32-sg2/cvm-testclient.c
--- cvm-0.32/cvm-testclient.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/cvm-testclient.c	Thu May 12 01:21:48 2005
@@ -44,12 +44,14 @@
 	 "system user name: %s\n"
 	 "system directory: %s\n"
 	 "domain:           %s\n"
-	 "mailbox path:     %s\n",
+	 "mailbox path:     %s\n"
+	 ".qmail file:      %s\n",
 	 cvm_fact_username, cvm_fact_userid, cvm_fact_groupid,
 	 cvm_fact_realname, cvm_fact_directory,
 	 cvm_fact_shell, cvm_fact_groupname,
 	 cvm_fact_sys_username, cvm_fact_sys_directory,
-	 cvm_fact_domain, cvm_fact_mailbox);
+	 cvm_fact_domain, cvm_fact_mailbox,
+	 cvm_fact_dotqmail);
   while (cvm_fact_uint(CVM_FACT_SUPP_GROUPID, &u) == 0)
     printf("supp. group ID:   %ld\n", u);
   return 0;
Only in cvm-0.32-sg2: cvm-testclient.c~
diff -ur cvm-0.32/cvm-unix.c cvm-0.32-sg2/cvm-unix.c
--- cvm-0.32/cvm-unix.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/cvm-unix.c	Thu Mar 31 20:28:19 2005
@@ -16,11 +16,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <errno.h>
+#include <sys/types.h>
 #include <grp.h>
 #include <pwd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include <sysdeps.h>
 
@@ -47,14 +47,18 @@
 {
   int err;
   if ((err = cvm_getpwnam(cvm_account_name, &pw)) != 0) return err;
-  if (pw->pw_passwd == 0) return CVME_PERMFAIL;
+  if (!getenv("CVM_ALREADYAUTH")) {
+    if (pw->pw_passwd == 0) return CVME_PERMFAIL;
+  }
   return 0;
 }
 
 int cvm_authenticate(void)
 {
-  if (strcmp(crypt(cvm_credentials[0], pw->pw_passwd), pw->pw_passwd) != 0)
-    return CVME_PERMFAIL;
+  if (!getenv("CVM_ALREADYAUTH")) {
+    if (strcmp(crypt(cvm_credentials[0], pw->pw_passwd), pw->pw_passwd) != 0)
+      return CVME_PERMFAIL;
+  }
   return 0;
 }
 
@@ -76,7 +80,7 @@
   cvm_fact_groupname = 0;
   setgrent();
   while ((gr = getgrent()) != 0) {
-    if (gr->gr_gid == pw->pw_gid)
+    if ((gid_t)gr->gr_gid == pw->pw_gid)
       cvm_fact_groupname = strdup(gr->gr_name);
     else {
       unsigned i;
diff -ur cvm-0.32/errors.h cvm-0.32-sg2/errors.h
--- cvm-0.32/errors.h	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/errors.h	Thu Mar 31 21:11:03 2005
@@ -8,6 +8,7 @@
 #define CVME_NOFACT 5
 #define CVME_CONFIG 6
 #define CVME_NOCRED 7
+#define CVME_DONTKNOW 10
 #define CVME_PERMFAIL 100
 
 /* This error code is only used by modules, to signal that the error
diff -ur cvm-0.32/facts.c cvm-0.32-sg2/facts.c
--- cvm-0.32/facts.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/facts.c	Thu May 12 01:20:08 2005
@@ -28,3 +28,4 @@
 const char* cvm_fact_sys_directory = 0;
 const char* cvm_fact_domain = 0;
 const char* cvm_fact_mailbox = 0;
+const char* cvm_fact_dotqmail = 0;
Only in cvm-0.32-sg2: facts.c~
diff -ur cvm-0.32/facts.h cvm-0.32-sg2/facts.h
--- cvm-0.32/facts.h	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/facts.h	Thu May 12 01:20:08 2005
@@ -16,6 +16,7 @@
 #define CVM_FACT_HOME_PHONE 13
 #define CVM_FACT_DOMAIN 14
 #define CVM_FACT_MAILBOX 15
+#define CVM_FACT_DOTQMAIL 16
 
 extern const char* cvm_fact_username;
 extern unsigned long cvm_fact_userid;
@@ -28,5 +29,6 @@
 extern const char* cvm_fact_sys_directory;
 extern const char* cvm_fact_domain;
 extern const char* cvm_fact_mailbox;
+extern const char *cvm_fact_dotqmail;
 
 #endif
Only in cvm-0.32-sg2: facts.h~
diff -ur cvm-0.32/insthier.c cvm-0.32-sg2/insthier.c
--- cvm-0.32/insthier.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/insthier.c	Thu Mar 31 20:28:19 2005
@@ -31,6 +31,8 @@
   c(dir, "cvm-vmailmgr-local",  -1, -1, 0755);
   c(dir, "cvm-vmailmgr-udp",    -1, -1, 0755);
   c(dir, "cvm-unix",            -1, -1, 0755);
+  c(dir, "cvm-anon",            -1, -1, 0755);
+  c(dir, "cvm-chain",           -1, -1, 0755);
 
   dir = d(home, "include",      -1, -1, 0755);
   s(dir, "cvm-sasl.h",          "cvm/sasl.h");
diff -ur cvm-0.32/module.h cvm-0.32-sg2/module.h
--- cvm-0.32/module.h	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/module.h	Thu Mar 31 20:28:19 2005
@@ -1,6 +1,8 @@
 #ifndef CVM__MODULE__H__
 #define CVM__MODULE__H__
 
+#include <pwd.h>
+
 #include "facts.h"
 #include "errors.h"
 
@@ -12,39 +14,82 @@
 
 #define CVM_PROTOCOL 1
 
-extern const char program[];
+extern const char cvm_module_program[];
 
-extern const char* cvm_account_name;
-extern const char* cvm_account_domain;
-extern const char* cvm_lookup_secret;
-
-extern char outbuffer[BUFSIZE];
-extern unsigned outbuflen;
-extern char inbuffer[BUFSIZE+1];
-extern unsigned inbuflen;
-
-extern void cvm_fact_start(void);
-extern int cvm_fact_str(int number, const char* data);
-extern int cvm_fact_uint(int number, unsigned long data);
-extern void cvm_fact_end(int code);
-
-extern void init_request(void);
-extern int handle_request(void);
-
-extern void log_startup(void);
-extern void log_request(void);
-extern void log_shutdown(void);
+extern const char* cvm_module_account_name;
+extern const char* cvm_module_account_domain;
+extern const char* cvm_module_lookup_secret;
+
+extern char cvm_module_outbuffer[BUFSIZE];
+extern unsigned cvm_module_outbuflen;
+extern char cvm_module_inbuffer[BUFSIZE+1];
+extern unsigned cvm_module_inbuflen;
+
+extern void cvm_module_fact_start(void);
+extern int cvm_module_fact_str(int number, const char* data);
+extern int cvm_module_fact_uint(int number, unsigned long data);
+extern void cvm_module_fact_end(int code);
+
+extern void cvm_module_init_request(void);
+extern int cvm_module_handle_request(void);
+
+extern void cvm_module_log_startup(void);
+extern void cvm_module_log_request(void);
+extern void cvm_module_log_shutdown(void);
 
-extern int cvm_parse_domain(const char* seperators);
+extern int cvm_module_parse_domain(const char* seperators);
 
 /* The following need to be provided by the module.
  * The "credentials" global is filled by the input handling code. */
-extern const unsigned cvm_credential_count;
-extern const char* cvm_credentials[];
-extern int cvm_auth_init(void);
-extern int cvm_lookup(void);
-extern int cvm_authenticate(void);
-extern int cvm_results(void);
-extern void cvm_auth_stop(void);
+extern const unsigned cvm_module_credential_count;
+extern const char* cvm_module_credentials[];
+extern int cvm_module_auth_init(void);
+extern int cvm_module_lookup(void);
+extern int cvm_module_authenticate(void);
+extern int cvm_module_results(void);
+extern void cvm_module_auth_stop(void);
+
+
+/* legacy */
+#define program			cvm_module_program
+
+#define cvm_account_name	cvm_module_account_name
+#define cvm_account_domain	cvm_module_account_domain
+#define cvm_lookup_secret	cvm_module_lookup_secret
+
+#define outbuffer		cvm_module_outbuffer
+#define outbuflen		cvm_module_outbuflen
+#define inbuffer		cvm_module_inbuffer
+#define inbuflen		cvm_module_inbuflen
+
+#define cvm_fact_start		cvm_module_fact_start
+#define cvm_fact_end		cvm_module_fact_end
+
+#define init_request		cvm_module_init_request
+#define handle_request		cvm_module_handle_request
+
+#define log_startup		cvm_module_log_startup
+#define log_request		cvm_module_log_request
+#define log_shutdown		cvm_module_log_shutdown
+
+#define cvm_parse_domain	cvm_module_parse_domain
+
+#define cvm_credential_count	cvm_module_credential_count
+#define cvm_credentials		cvm_module_credentials
+#define cvm_auth_init		cvm_module_auth_init
+#define cvm_lookup		cvm_module_lookup
+#define cvm_results		cvm_module_results
+#define cvm_auth_stop		cvm_module_auth_stop
+
+/* can't be duplicated */
+#ifndef CVM__CLIENT__H__
+# define cvm_authenticate	cvm_module_authenticate
+# define cvm_fact_str		cvm_module_fact_str
+# define cvm_fact_uint		cvm_module_fact_uint
+#else
+# undef cvm_authenticate
+# undef cvm_fact_str
+# undef cvm_fact_uint
+#endif
 
 #endif
diff -ur cvm-0.32/module_request.c cvm-0.32-sg2/module_request.c
--- cvm-0.32/module_request.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/module_request.c	Thu Mar 31 22:18:52 2005
@@ -75,8 +75,8 @@
   for (i = 0; i < credential_count; ++i)
     if (!copy_advance(&credentials[i], &buf, &len))
       return CVME_BAD_CLIDATA;
-
-  if (len != 1) return CVME_BAD_CLIDATA;
+  /* hack --sg */
+  if (len > 2) return CVME_BAD_CLIDATA;
   return 0;
 }
 
diff -ur cvm-0.32/qmail-dotfile.c cvm-0.32-sg2/qmail-dotfile.c
--- cvm-0.32/qmail-dotfile.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/qmail-dotfile.c	Thu May 12 01:44:31 2005
@@ -22,27 +22,48 @@
 
 #include <str/str.h>
 
+#include "facts.h"
 #include "qmail.h"
 
+char * qmail_get_dotfile(const struct qmail_user* user, const char* ext);
+
+
 int qmail_dotfile_exists(const struct qmail_user* user, const char* ext)
 {
-  static str path;
-  struct stat st;
-  int split;
-  int baselen;
+  char *file;
 
   /* System users are not required to have a .qmail file */
   if (user->dash == 0)
     return ext == 0 || *ext == 0;
+  
+  if ((file = qmail_get_dotfile(user,ext)) == (char *)-1) {
+    return -1;
+  } else if (file == (char *)0) {
+    return 0;
+  } else {
+    return 1;
+  }
+}
 
-  if (!str_copy(&path, &user->homedir)) return -1;
-  if (!str_cats(&path, "/.qmail")) return -1;
+char * qmail_get_dotfile(const struct qmail_user* user, const char* ext)
+{
+  static str path;
+  struct stat st;
+  int split;
+  int baselen;
+
+  if (!str_copy(&path, &user->homedir)) return (char *)-1;
+  if (!str_cats(&path, "/.qmail")) return (char *)-1;
   baselen = path.len;
-  if (!str_catc(&path, user->dash)) return -1;
-  if (!str_cat(&path, &user->ext)) return -1;
+  if (user->dash) {
+    if (!str_catc(&path, user->dash)) return (char *)-1;
+  }
+  if (user->ext.len) {
+    if (!str_cat(&path, &user->ext)) return (char *)-1;
+  }
   if (ext != 0) {
     split = path.len;
-    if (!str_cats(&path, ext)) return -1;
+    if (!str_cats(&path, ext)) return (char *)-1;
     for (; split < (int)path.len; ++split)
       if (isupper(path.s[split]))
 	path.s[split] = tolower(path.s[split]);
@@ -50,15 +71,18 @@
 
   split = path.len;
   for (;;) {
-    if (stat(path.s, &st) == 0)
-      return 1;
+    if (stat(path.s, &st) == 0) {
+      /* path is static and we aren't called recursively, so this is OK. */
+      cvm_fact_dotqmail = path.s; 
+      return path.s;
+    }
     if (errno != ENOENT)
-      return -1;
+      return (char *)-1;
     if ((split = str_findprev(&path, '-', split - 1)) == -1
 	|| split < baselen)
       break;
     path.len = split + 1;
-    if (!str_cats(&path, "default")) return -1;
+    if (!str_cats(&path, "default")) return (char *)-1;
   }
-  return 0;
+  return NULL;
 }
Only in cvm-0.32-sg2: qmail-dotfile.c~
diff -ur cvm-0.32/qmail-lookup.c cvm-0.32-sg2/qmail-lookup.c
--- cvm-0.32/qmail-lookup.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/qmail-lookup.c	Sun Mar 20 14:52:38 2005
@@ -52,26 +52,28 @@
   if (qmail_users_reinit() != 0
       || qmail_domains_reinit() != 0)
     return -1;
-
-  switch (qmail_domains_lookup(cvm_account_domain, domain, &prefix)) {
-  case -1:
-    return -1;
-  case 0:
-    if (missingdomain == 0)
-      return 0;
-    if (!str_copys(domain, missingdomain)
-	|| !str_copys(&fullname, missinguser))
+  
+  if (cvm_account_domain && cvm_account_domain[0] != 0) {
+    switch (qmail_domains_lookup(cvm_account_domain, domain, &prefix)) {
+    case -1:
       return -1;
-    break;
-  default:
-    fullname.len = 0;
-    if (prefix.len > 0)
-      if (!str_copy(&fullname, &prefix)
-	  || !str_catc(&fullname, '-'))
+    case 0:
+      if (missingdomain == 0)
+	return 0;
+      if (!str_copys(domain, missingdomain)
+	  || !str_copys(&fullname, missinguser))
 	return -1;
-    if (!str_cats(&fullname, cvm_account_name))
-      return -1;
+      break;
+    }
   }
+
+  fullname.len = 0;
+  if (prefix.len > 0)
+    if (!str_copy(&fullname, &prefix)
+	|| !str_catc(&fullname, '-'))
+      return -1;
+  if (!str_cats(&fullname, cvm_account_name))
+    return -1;
 
   switch (qmail_users_lookup_split(user, fullname.s, username, ext)) {
   case -1:
diff -ur cvm-0.32/sql-query-test.c cvm-0.32-sg2/sql-query-test.c
--- cvm-0.32/sql-query-test.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/sql-query-test.c	Thu Mar 31 20:28:19 2005
@@ -1,8 +1,8 @@
 #include <stdio.h>
 #include "sql.h"
 
-const char* cvm_account_name;
-const char* cvm_account_domain;
+const char* cvm_module_account_name;
+const char* cvm_module_account_domain;
 
 int main(int argc, char* argv[])
 {
@@ -15,8 +15,8 @@
     puts("sql-query-test: validation of query failed");
     return 2;
   }
-  cvm_account_name = argv[2];
-  cvm_account_domain = argv[3];
+  cvm_module_account_name = argv[2];
+  cvm_module_account_domain = argv[3];
   if (!sql_query_build(argv[1], &s)) {
     puts("sql-query-test: query building failed");
     return 3;
Only in cvm-0.32-sg2: test.in
Only in cvm-0.32-sg2: test2.in
Only in cvm-0.32-sg2: test3.in
Only in cvm-0.32-sg2: test4.in
diff -ur cvm-0.32/vmlookup.c cvm-0.32-sg2/vmlookup.c
--- cvm-0.32/vmlookup.c	Fri Jan 14 17:10:25 2005
+++ cvm-0.32-sg2/vmlookup.c	Thu May 12 02:16:37 2005
@@ -68,37 +68,43 @@
   int fd;
   struct cdb cdb;
 
-  DEBUG("cvm_account_domain='", cvm_account_domain, "'");
+/*   DEBUG("cvm_account_domain='", cvm_account_domain, "'"); */
   switch (qmail_lookup_cvm(&vmuser, &domain, &baseuser, &virtuser)) {
   case -1: return CVME_IO;
   case 0:  return CVME_PERMFAIL;
   }
-  if (virtuser.len == 0)
-    return CVME_PERMFAIL;
+  if (virtuser.len == 0) /* System user? */
+    return CVME_DONTKNOW;
 
   memset(&cdb, 0, sizeof cdb);
   str_lower(&virtuser);
   /* Found a virtual user, authenticate it. */
   if (chdir(vmuser.homedir.s) == -1) return CVME_IO;
-  if ((fd = open(pwfile, O_RDONLY)) == -1) return CVME_IO;
+  if ((fd = open(pwfile, O_RDONLY)) == -1) {
+    if (errno == ENOENT) {
+      /* It's not a vmailmgr file */
+      return CVME_DONTKNOW;
+    }
+    return CVME_IO;
+  }
   cdb_init(&cdb, fd);
   switch (cdb_get(&cdb, &virtuser, &vpwdata)) {
   case -1:
-    DEBUG("cdb_get returned error", 0, 0);
+/*     DEBUG("cdb_get returned error", 0, 0); */
     err = CVME_IO;
     break;
   case 0:
-    DEBUG("cdb_get failed", 0, 0);
+/*     DEBUG("cdb_get failed", 0, 0); */
     /* Only handle the default user when in lookup mode, as
        authenticating the default user shouldn't happen. */
     if (cvm_lookup_secret != 0) {
       switch (cdb_get(&cdb, &default_user, &vpwdata)) {
       case -1:
-	DEBUG("cdb_get returned error", 0, 0);
+/* 	DEBUG("cdb_get returned error", 0, 0); */
 	err = CVME_IO;
 	break;
       case 0:
-	DEBUG("cdb_get failed", 0, 0);
+/* 	DEBUG("cdb_get failed", 0, 0); */
 	err = CVME_PERMFAIL;
 	break;
       default:
Only in cvm-0.32-sg2: vmlookup.c~
diff -ur cvm-0.32/vmmain.c cvm-0.32-sg2/vmmain.c
--- cvm-0.32/vmmain.c	Thu Mar 31 20:35:50 2005
+++ cvm-0.32-sg2/vmmain.c	Fri Jan 14 17:10:25 2005
@@ -83,30 +83,13 @@
   int err;
 
   if ((err = lookup_virtuser()) != 0) return err;
-  if (virtuser.len == 0) {
-    if (!qmail_import(&vpw)) {
-      DEBUG("Could not import virtual password data", 0, 0);
-      return CVME_IO;
-    }
-  }
-  else if (!vpwentry_import(&vpw, &virtuser, &vpwdata)) {
+
+  if (!vpwentry_import(&vpw, &virtuser, &vpwdata)) {
     DEBUG("Could not import virtual password data", 0, 0);
     return CVME_IO;
   }
 
   return 0;
-}
-
-int qmail_import(vpwentry *vpw)
-{
-  struct qmail_user vmuser;
-
-  switch (qmail_lookup_cvm(&vmuser, &domain, &baseuser, &virtuser)) {
-  case -1: return CVME_IO;
-  case 0:  return CVME_PERMFAIL;
-  }
-  
-  
 }
 
 int cvm_results(void)