Friday, December 5, 2008

pecl_http and sub-second timeouts

Just a quick info, because I forget this again and again--and it's not noted in the documentation yet either.

Sub-second timeouts are supported by libcurl and thus by pecl_http--yes but only if libcurl is built with (c-)ares support:

<quote url="curl_easy_setopt.html">

If libcurl is built to use the standard system name resolver, that portion of the transfer will still use full-second resolution for timeouts with a minimum timeout allowed of one second.


Tuesday, November 18, 2008

Vpopmail and people reaching their maildir quota

This tiny program lists all users of a domain with a maildir quota usage above 90%.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <pwd.h>
#include <errno.h>

#include <vpopmail.h>
#include <vauth.h>

int main(int argc, char **argv) {
struct vqpasswd *user;
char dir[1024];
uid_t uid;
gid_t gid;
int offset_counter = -1, sort = 1, usage;

if (argc != 2) {
fprintf(stderr, "Usage: %s <domain>n", argv[0]);
if (vget_assign(argv[1], NULL, 0, &uid, &gid) == NULL) {
fprintf(stderr, "domain '%s' does not existn", argv[1]);
if (setgid(gid) || setuid(uid)) {
fprintf(stderr, "could not setuid/setgid to %d:%dn", uid, gid);

while (NULL != (user = vauth_getall(argv[1], !++offset_counter, sort))) {
if (strcmp(user->pw_shell, "NOQUOTA")) {
snprintf(dir, sizeof(dir), "%s/Maildir", user->pw_dir);
usage = vmaildir_readquota(dir,

if (usage >= 90) {
printf("%s %s %dn", user->pw_name, user->pw_shell, usage);


Qmail + SpamAssassin + selectivity

Here's how my qmail-queue script looks like to selectively check messages with SpamAssassin for non-relay clients only:

(if [ -n "${RELAYCLIENT+1}" -o `id -u` != 64011 ];
then cat -;
else /usr/bin/spamc -x -U /var/run/spamd/spamd.sock;
fi) | /usr/sbin/qmail-queue.orig

For the records.