From 50cc469881230c76b43ab21d9580a9b1999b122b Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Fri, 12 Sep 2014 03:16:45 -0500 Subject: [PATCH] Add docs and flexible path to user_config plugin I needed to make the path modifyable for testing anyway, might as well make it actually usable. Not yet tested. --- plugins/user_config | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/plugins/user_config b/plugins/user_config index 092d01d..2ce405b 100644 --- a/plugins/user_config +++ b/plugins/user_config @@ -2,10 +2,43 @@ use strict; use warnings; +=head1 NAME + +user_config - basic plugin for storing per-user configuration directives + +=head1 SYNOPSIS + +# in config/plugins + +user_config [B] + +=over 4 + +=item B + +Pattern to use when searching for user config directory +Substitute %u for username, %h for host, or %a for full addressn. +Default: I + +=head1 DESCRIPTION + +This plugin implements very basic support for storing user configuration +in separate directories similar to the global qpsmtpd config directory. + +=cut + +sub init { + my ( $self, $qp, $pattern ) = @_; + $self->{pattern} = $pattern || '/home/%u/.qpsmtpd'; +} + sub hook_user_config { my ($self,$txn,$user,$conf) = @_; - my $username = $user->host or return DECLINED; - my $filename = "/home/$username/.qpsmtpd/$conf"; + my $path = $self->{pattern} or return DECLINED; + $path =~ s/%u/$user->user/g; + $path =~ s/%h/$user->host/g; + $path =~ s/%a/$user->address/g; + my $filename = "$path/$conf"; return DECLINED unless -f $filename; my $fh; unless (open $fh,$filename) {