1 |
From febdb001c684b3b9437fe4425e3f70785de9ba73 Mon Sep 17 00:00:00 2001 |
2 |
From: Robin Bowes <robin-lists@robinbowes.com> |
3 |
Date: Sat, 8 May 2010 18:25:08 +0100 |
4 |
Subject: new plugin auth_vpopmaild |
5 |
|
6 |
Signed-off-by: Robert <rspier@pobox.com> |
7 |
--- |
8 |
MANIFEST | 1 + |
9 |
plugins/auth/auth_vpopmaild | 97 +++++++++++++++++++++++++++++++++++++++++++ |
10 |
2 files changed, 98 insertions(+), 0 deletions(-) |
11 |
create mode 100644 plugins/auth/auth_vpopmaild |
12 |
|
13 |
diff --git a/MANIFEST b/MANIFEST |
14 |
index 9d5912a..7ae1b14 100644 |
15 |
--- a/MANIFEST |
16 |
+++ b/MANIFEST |
17 |
@@ -67,6 +67,7 @@ plugins/auth/auth_cvm_unix_local |
18 |
plugins/auth/auth_flat_file |
19 |
plugins/auth/auth_ldap_bind |
20 |
plugins/auth/auth_vpopmail_sql |
21 |
+plugins/auth/auth_vpopmaild |
22 |
plugins/auth/authdeny |
23 |
plugins/check_badmailfrom |
24 |
plugins/check_badmailfromto |
25 |
diff --git a/plugins/auth/auth_vpopmaild b/plugins/auth/auth_vpopmaild |
26 |
new file mode 100644 |
27 |
index 0000000..e4ab940 |
28 |
--- /dev/null |
29 |
+++ b/plugins/auth/auth_vpopmaild |
30 |
@@ -0,0 +1,97 @@ |
31 |
+#!/usr/bin/env perl |
32 |
+ |
33 |
+use strict; |
34 |
+use warnings; |
35 |
+use IO::Socket; |
36 |
+use version; my $VERSION = qv('1.0.0'); |
37 |
+ |
38 |
+sub register { |
39 |
+ my ($self, $qp, %args) = @_; |
40 |
+ |
41 |
+ my %DEFAULT = ( |
42 |
+ host => q{localhost}, |
43 |
+ port => 89, |
44 |
+ ); |
45 |
+ |
46 |
+ $self->{_vpopmaild_host} = |
47 |
+ defined $args{host} ? $args{host} : $DEFAULT{host}; |
48 |
+ $self->{_vpopmaild_port} = |
49 |
+ defined $args{port} ? $args{port} : $DEFAULT{port}; |
50 |
+ |
51 |
+ $self->register_hook('auth-plain', 'auth_vpopmaild'); |
52 |
+ $self->register_hook('auth-login', 'auth_vpopmaild'); |
53 |
+} |
54 |
+ |
55 |
+sub auth_vpopmaild { |
56 |
+ my ($self, $transaction, $method, $user, $passClear, $passHash, $ticket) = |
57 |
+ @_; |
58 |
+ |
59 |
+ # create socket |
60 |
+ my $vpopmaild_socket = |
61 |
+ IO::Socket::INET->new( |
62 |
+ PeerAddr => $self->{_vpopmaild_host}, |
63 |
+ PeerPort => $self->{_vpopmaild_port}, |
64 |
+ Proto => 'tcp', |
65 |
+ Type => SOCK_STREAM |
66 |
+ ) or return DECLINED; |
67 |
+ |
68 |
+ # Get server greeting (+OK) |
69 |
+ my $connect_response = <$vpopmaild_socket>; |
70 |
+ if (!$connect_response =~ /\+OK.*/) { |
71 |
+ return DECLINED; |
72 |
+ } |
73 |
+ |
74 |
+ # send login details |
75 |
+ print $vpopmaild_socket "login $user $passClear\n\r"; |
76 |
+ |
77 |
+ # get response from server |
78 |
+ my $login_response = <$vpopmaild_socket>; |
79 |
+ |
80 |
+ close($vpopmaild_socket); |
81 |
+ |
82 |
+ # check for successful login |
83 |
+ if ($login_response =~ /\+OK.*/) { |
84 |
+ return (OK, 'authcheckpassword'); |
85 |
+ } |
86 |
+ else { |
87 |
+ return DECLINED; |
88 |
+ } |
89 |
+} |
90 |
+ |
91 |
+__END__ |
92 |
+ |
93 |
+=head1 NAME |
94 |
+ |
95 |
+auth_vpopmaild - Authenticate to vpopmaild |
96 |
+ |
97 |
+=head1 DESCRIPTION |
98 |
+ |
99 |
+Authenticates the user against against vpopmaild [1] daemon. |
100 |
+ |
101 |
+=head1 CONFIGURATION |
102 |
+ |
103 |
+Add a line to C<config/plugins> as follows: |
104 |
+ |
105 |
+auth_vpopmaild |
106 |
+ |
107 |
+By default, the plugin connects to localhot on port 89. If your vpopmaild |
108 |
+daemon is running on a different host or port, specify as follows: |
109 |
+ |
110 |
+auth_vpopmaild host [host] port [port] |
111 |
+ |
112 |
+=head1 LINKS |
113 |
+ |
114 |
+[1] http://www.qmailwiki.org/Vpopmaild |
115 |
+ |
116 |
+=head1 AUTHOR |
117 |
+ |
118 |
+Robin Bowes <robin.bowes@yo61.com> |
119 |
+ |
120 |
+=head1 COPYRIGHT AND LICENSE |
121 |
+ |
122 |
+Copyright (c) 2010 Robin Bowes |
123 |
+ |
124 |
+This plugin is licensed under the same terms as the qpsmtpd package itself. |
125 |
+Please see the LICENSE file included with qpsmtpd for details. |
126 |
+ |
127 |
+=cut |
128 |
-- |
129 |
1.7.2.2 |
130 |
|