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.
This commit is contained in:
parent
eb482aad0a
commit
50cc469881
@ -2,10 +2,43 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
user_config - basic plugin for storing per-user configuration directives
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
# in config/plugins
|
||||||
|
|
||||||
|
user_config [B<filename pattern>]
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item B<config file search pattern>
|
||||||
|
|
||||||
|
Pattern to use when searching for user config directory
|
||||||
|
Substitute %u for username, %h for host, or %a for full addressn.
|
||||||
|
Default: I</home/%u/.qpsmtpd/>
|
||||||
|
|
||||||
|
=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 {
|
sub hook_user_config {
|
||||||
my ($self,$txn,$user,$conf) = @_;
|
my ($self,$txn,$user,$conf) = @_;
|
||||||
my $username = $user->host or return DECLINED;
|
my $path = $self->{pattern} or return DECLINED;
|
||||||
my $filename = "/home/$username/.qpsmtpd/$conf";
|
$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;
|
return DECLINED unless -f $filename;
|
||||||
my $fh;
|
my $fh;
|
||||||
unless (open $fh,$filename) {
|
unless (open $fh,$filename) {
|
||||||
|
Loading…
Reference in New Issue
Block a user