Re: cvm-vmailmgr lookup problem (internal temporary error)
Dale Woolridge <[email protected]> Thu, 15 Sep 2005 03:08:24 -0400
| Newsgroups | gmane.comp.sysutils.bgware |
|---|---|
| Message-ID | <[email protected]> |
On 15-Sep-2005 00:02 Scott Gifford wrote: | Josh Trutwin <[email protected]> writes: | > | > 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. :) Attached is a version for cvm 0.76, with changes isolated to the specific features under discussion. In case it's not obvious, cvm-vmailmgr must precede cvm-qmail with this patch. Notable differences: - renamed DONTKNOW to CHAIN_OK and made it a flag instead of a code - check for env var CVM_CHAIN_WEAK and enable the CHAIN_OK/DONTKNOW behaviour only when it's set (old behaviour otherwise) Special note: patch not tested, heck not even compiled. -- -dale --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
cvm-0.76-sg.dw.chainok.1-freebsd
(text/plain, 2.2 KB)
Index: vmlookup.c
===================================================================
--- vmlookup.c (revision 406)
+++ vmlookup.c (working copy)
@@ -73,14 +73,16 @@
case -1: return CVME_IO;
case 0: return CVME_PERMFAIL;
}
- if (virtuser.len == 0)
- return CVME_PERMFAIL;
+ if (virtuser.len == 0) return CVME_PERMFAIL | CVME_CHAIN_OK;
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) return CVME_IO | CVME_CHAIN_OK;
+ return CVME_IO;
+ }
cdb_init(&cdb, fd);
switch (cdb_get(&cdb, &virtuser, &vpwdata)) {
case -1:
Index: errors.h
===================================================================
--- errors.h (revision 406)
+++ errors.h (working copy)
@@ -14,6 +14,11 @@
is fatal and should cause module shutdown. */
#define CVME_FATAL 0x100
+/* This is for chaining. Modules can return errors, but ones
+ that are masked with this flag indicate it's okay to pass
+ along to next chain entry */
+#define CVME_CHAIN_OK 0x200
+
#define CVME_MASK 0x0ff
extern const char* const cvm_errlist[];
Index: cvm-chain.c
===================================================================
--- cvm-chain.c (revision 406)
+++ cvm-chain.c (working copy)
@@ -12,6 +12,7 @@
const char* chains[10];
int chain_count;
+int chain_weak = 0;
static void cvm_chain_init()
{
@@ -33,6 +34,8 @@
int i;
char varname[] = "CVM_CHAIN#";
+ chain_weak = !!getenv("CVM_CHAIN_WEAK");
+
chain_count = 0;
for (i = 0; i <= 9; ++i) {
varname[9] = i + '0';
@@ -48,6 +51,7 @@
int cvm_module_lookup(void)
{
+#define CHAIN_BROKEN(c) (chain_weak?(((c) & CVME_CHAIN_OK) == 0):(((c) & CVME_FATAL) != 0))
int i;
int credcount;
int code;
@@ -61,11 +65,10 @@
}
}
- for (code = i = 0; i < chain_count && ((code & CVME_FATAL) == 0); i++) {
+ for (code = i = 0; i < chain_count; i++) {
cvm_chain_init();
code = cvm_client_authenticate(chains[i], credcount, creds);
- if (code == 0)
- return 0;
+ if (CHAIN_BROKEN(code)) break;
}
return code;
}