Hello,

I needed to use vmailmgr and qmail-ldap on the same machine, so I wrote
the following checkpassword program which allow to chain several backend
until one returns successfully. Nothing cutting edge. I hope it can help
others. If there was a better way to do please let me know.

(It would not be hard to modify the code to read the program to execute
from an environment variable passwd from the run script)

Thomas
---
# cat /var/qmail/bin/auth_multi_pop
#!/usr/bin/env python
 
# For some information about the interface used, see :
# http://cr.yp.to/checkpwd/interface.html
 
import os
import sys
 
INPUT_FD = 3
data = ""

try:
        file = os.fdopen(INPUT_FD)
        data = os.read(file.fileno(),512)
        file.close()
except:
        sys.exit(111)

res = 0
 
for check in ['/usr/bin/checkvpw', '/var/qmail/bin/auth_pop']:
        sys.argv[0] = check.split('/')[-1]
 
        # r is 3, w is 4        
        (r,w) = os.pipe()
 
        os.write(w,data)
        os.close(w)
 
        pid = os.fork()
 
        if pid:
                os.close(r)

                (pid, res) = os.waitpid(pid,0)
                res = res >> 8
                if res == 0:
                        break
 
        else:
                os.execve(check,sys.argv,os.environ)
 
 
sys.exit(res)

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to