From owner-freebsd-python@freebsd.org Fri Jun 19 14:01:28 2020 Return-Path: Delivered-To: freebsd-python@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3005334C9B1 for ; Fri, 19 Jun 2020 14:01:28 +0000 (UTC) (envelope-from freebsd-python@dino.sk) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49pL7q10Zsz47NN for ; Fri, 19 Jun 2020 14:01:26 +0000 (UTC) (envelope-from freebsd-python@dino.sk) Received: from zeta.dino.sk (fw3.dino.sk [84.245.95.254]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Fri, 19 Jun 2020 16:01:15 +0200 id 00F3A9DB.5EECC52B.00008DFF Date: Fri, 19 Jun 2020 16:01:13 +0200 From: Milan Obuch To: freebsd-python@freebsd.org Subject: Any way to access db5 data with python? Message-ID: <20200619160113.3280a8d1@zeta.dino.sk> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; i386-portbld-freebsd11.4) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 49pL7q10Zsz47NN X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd-python@dino.sk designates 84.245.65.72 as permitted sender) smtp.mailfrom=freebsd-python@dino.sk X-Spamd-Result: default: False [-0.89 / 15.00]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[dino.sk]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.78)[-0.784]; NEURAL_HAM_MEDIUM(-0.64)[-0.643]; NEURAL_HAM_SHORT(-0.16)[-0.158]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:16160, ipnet:84.245.64.0/18, country:SK]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 14:01:28 -0000 Hi, I am trying to upgrade mail/courier-pythonfilter port to new version using Python 3. While it basically works, I found there is some problem accessing database from courier mail server. In log file I see courierfilter[2875]: Error reading /usr/local/etc/courier/smtpaccess.dat This file exists, it is -rw-r--r-- 1 root courier 131072 May 26 13:30 smtpaccess.dat Pythonfilter author wrote me it probably means there is no module for accessing it and suggested test $ python3 >>> import dbm >>> dbm.open('/usr/local/etc/courier/smtpaccess.dat', 'r') This gives an error: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.7/dbm/__init__.py", line 88, in open raise error[0]("db type could not be determined") dbm.error: db type could not be determined With some tests I found a way to display file contents: # dbmmanage /usr/local/etc/courier/smtpaccess.dat view 127.0.0.1:allow,RELAYCLIENT :0000:0000:0000:0000:0000:0000:0000:0001:allow,RELAYCLIENT 10:allow,RELAYCLIENT 192.168:allow,RELAYCLIENT or # db_dump185-5.3 -p /usr/local/etc/courier/smtpaccess.dat format=print type=hash h_ffactor=65536 db_lorder=1234 db_pagesize=32768 HEADER=END 127.0.0.1 allow,RELAYCLIENT :0000:0000:0000:0000:0000:0000:0000:0001 allow,RELAYCLIENT 10 allow,RELAYCLIENT 192.168 allow,RELAYCLIENT First one uses binary installed with apache web server, second one uses binary from db5 package. One more test: # file /usr/local/etc/courier/smtpaccess.dat /usr/local/etc/courier/smtpaccess.dat: Berkeley DB 1.85 (Hash, version 2, native byte-order) Could anybody offer a hint? I found no Python package for db5, at least not with name like py-db5 or some such tricial. Regards, Milan