[Bps-public-commit] Net-IMAP-Server branch, master, updated. 1.24-7-g6626a9a

Alex M Vandiver alexmv at bestpractical.com
Sat Nov 7 23:54:30 EST 2009


The branch, master has been updated
       via  6626a9a8f1d87f8b6ccd40d73249e7cdce72a7b7 (commit)
       via  c1a8cd5ee8f428dbb951ceca92ad31412d136599 (commit)
       via  9f3cce3c058c6737ea3355b4ec2a7e1e397f288a (commit)
       via  9945201eaf79577d11eb990d8d04ae59009f0089 (commit)
       via  58438f902e25dd1ccf1376c2fbca45a28fef8c73 (commit)
      from  0e40f88de7c9c61d9aae71d27285b742f3d7d840 (commit)

Summary of changes:
 Changes                                     |    9 +++
 META.yml                                    |    3 +-
 Makefile.PL                                 |    1 +
 SIGNATURE                                   |   36 ++++++------
 lib/Net/IMAP/Server.pm                      |   80 ++++++++++++++++++++------
 lib/Net/IMAP/Server/Command.pm              |    4 +-
 lib/Net/IMAP/Server/Command/Authenticate.pm |    2 +-
 lib/Net/IMAP/Server/Command/Login.pm        |    2 +-
 lib/Net/IMAP/Server/Connection.pm           |   26 ++++----
 9 files changed, 108 insertions(+), 55 deletions(-)

- Log -----------------------------------------------------------------
commit 58438f902e25dd1ccf1376c2fbca45a28fef8c73
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Nov 7 23:17:33 2009 -0500

    All calls to ->log are now prefixed with loglevel, a la Net::Server
    
    Use Net::Server's logging infrastructure, by having
    Net::IMAP::Server::Connection's ->log method defer to
    Net::IMAP::Server's (and hence Net::Server's) ->log.  This also
    involves all calls to ->log having a first argument, which is the
    severity.  This may break existing log methods on Net::IMAP::Server
    subclasses, however.

diff --git a/lib/Net/IMAP/Server.pm b/lib/Net/IMAP/Server.pm
index 0f27954..840c6d1 100644
--- a/lib/Net/IMAP/Server.pm
+++ b/lib/Net/IMAP/Server.pm
@@ -358,14 +358,23 @@ sub add_command {
     my $self = shift;
     my ($name, $package) = @_;
     if (not $package->require) {
-        warn $@;
+        $self->log( 1, $@ );
     } elsif (not $package->isa('Net::IMAP::Server::Command')) {
-        warn "$package is not a Net::IMAP::Server::Command!";
+        $self->log( 1, "$package is not a Net::IMAP::Server::Command!" );
     } else {
         $self->command_class->{uc $name} = $package;
     }
 }
 
+=head2 log SEVERITY, MESSAGE
+
+By default, defers to L<Net::Server/log>, which outputs to syslog, a
+logfile, or STDERR, depending how it was configured.  L<Net::Server>'s
+default is to print to STDERR.  If you have custom logging needs,
+override this method, or L<Net::Server/write_to_log_hook>.
+
+=cut
+
 1;    # Magic true value required at end of module
 __END__
 
diff --git a/lib/Net/IMAP/Server/Command.pm b/lib/Net/IMAP/Server/Command.pm
index 545b322..0e7606c 100644
--- a/lib/Net/IMAP/Server/Command.pm
+++ b/lib/Net/IMAP/Server/Command.pm
@@ -374,9 +374,9 @@ sub bad_command {
     return 0;
 }
 
-=head2 log MESSAGE
+=head2 log SEVERITY, MESSAGE
 
-Identical to L<Net::IMAP::Server::Connection/log>.
+Defers to L<Net::IMAP::Server::Connection/log>.
 
 =cut
 
diff --git a/lib/Net/IMAP/Server/Command/Authenticate.pm b/lib/Net/IMAP/Server/Command/Authenticate.pm
index d087d0b..6b72730 100644
--- a/lib/Net/IMAP/Server/Command/Authenticate.pm
+++ b/lib/Net/IMAP/Server/Command/Authenticate.pm
@@ -28,7 +28,7 @@ sub run {
     my $self = shift;
 
     my($type, $arg) = $self->parsed_options;
-    $self->server->auth_class->require || warn $@;
+    $self->server->auth_class->require || $self->log( 1, $@ );
     my $auth = $self->server->auth_class->new;
     if ( grep {uc $type eq uc $_} $auth->sasl_provides ) {
         $type = lc $type;
diff --git a/lib/Net/IMAP/Server/Command/Login.pm b/lib/Net/IMAP/Server/Command/Login.pm
index 5c50533..3d12787 100644
--- a/lib/Net/IMAP/Server/Command/Login.pm
+++ b/lib/Net/IMAP/Server/Command/Login.pm
@@ -24,7 +24,7 @@ sub validate {
 sub run {
     my $self = shift;
 
-    $self->server->auth_class->require || warn $@;
+    $self->server->auth_class->require || $self->log( 1, $@ );
     my $auth = $self->server->auth_class->new;
     if (    $auth->provides_plain
         and $auth->auth_plain( $self->parsed_options ) )
diff --git a/lib/Net/IMAP/Server/Connection.pm b/lib/Net/IMAP/Server/Connection.pm
index 52cea1d..14655a9 100644
--- a/lib/Net/IMAP/Server/Connection.pm
+++ b/lib/Net/IMAP/Server/Connection.pm
@@ -92,7 +92,7 @@ sub auth {
     my $self = shift;
     if (@_) {
         $self->{auth} = shift;
-        $self->server->model_class->require || warn $@;
+        $self->server->model_class->require || $self->log(1, $@);
         $self->update_timer;
         $self->model(
             $self->server->model_class->new( { auth => $self->{auth} } ) );
@@ -182,12 +182,12 @@ sub handle_lines {
             cede;
         }
 
-        $self->log(
+        $self->log( 4,
             "-(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): Connection closed by remote host"
         );
     };
     my $err = $@;
-    warn $err
+    $self->log(1, $err)
         if $err and not( $err eq "Error printing\n" or $err eq "Timeout\n" );
     eval { $self->out("* BYE Idle timeout; I fell asleep.") if $err eq "Timeout\n"; };
     $self->close;
@@ -241,8 +241,10 @@ sub handle_command {
     my $self    = shift;
     my $content = shift;
 
-    $self->log(
-        "C(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $content"
+    my $output = $content;
+    $output =~ s/[\r\n]+$//;
+    $self->log( 4,
+        "C(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $output"
     );
 
     if ( $self->pending ) {
@@ -273,7 +275,7 @@ sub handle_command {
             $handler->bad_command($1);
         } else {
             $handler->no_command("Server error");
-            $self->log($error);
+            $self->log(1, $error);
         }
     }
 }
@@ -297,7 +299,7 @@ sub class_for {
     $cmd_class->require();
     my $err = $@;
     if ($err and $err !~ /^Can't locate $class_path.pm in \@INC/) {
-        warn $@;
+        $self->log(1, $@);
         $cmd_class = "Net::IMAP::Server::Error";
     }
 
@@ -565,17 +567,15 @@ sub capability {
     return $base;
 }
 
-=head2 log MESSAGE
+=head2 log SEVERITY, MESSAGE
 
-Logs the message to standard error, using C<warn>.
+Defers to L<Net::IMAP::Server/log>.
 
 =cut
 
 sub log {
     my $self = shift;
-    my $msg  = shift;
-    chomp($msg);
-    warn $msg . "\n";
+    $self->server->log(@_);
 }
 
 =head2 untagged_response STRING
@@ -603,7 +603,7 @@ sub out {
     my $msg  = shift;
     if ( $self->io_handle and $self->io_handle->peerport ) {
         if ( $self->io_handle->print( $msg . "\r\n" ) ) {
-            $self->log(
+            $self->log( 4,
                 "S(@{[$self]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $msg"
             );
         } else {

commit 9945201eaf79577d11eb990d8d04ae59009f0089
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Nov 7 23:39:49 2009 -0500

    Pass through a large number of Net::Server arguments to ->new
    
    Since logging is now Net::Server-based, pass through the
    logging-related arguments of ->new to Net::Server.  This also allows
    us to remove our custom ->user and ->group methods, in favor of
    Net::Server's.

diff --git a/lib/Net/IMAP/Server.pm b/lib/Net/IMAP/Server.pm
index 840c6d1..e8b62e0 100644
--- a/lib/Net/IMAP/Server.pm
+++ b/lib/Net/IMAP/Server.pm
@@ -60,7 +60,6 @@ __PACKAGE__->mk_accessors(
     qw/port ssl_port
        auth_class model_class connection_class
        command_class
-       user group
        poll_every
        unauth_idle auth_idle unauth_commands
       /
@@ -99,19 +98,6 @@ be a subclass of L<Net::IMAP::Server::DefaultModel>.
 On rare occasions, you may wish to subclass the connection class; this
 class must be a subclass of L<Net::IMAP::Server::Connection>.
 
-=item user
-
-The name or ID of the user that the server should run as; this
-defaults to the current user.  Note that privileges are dropped after
-binding to the port and reading the certificates, so escalated
-privileges should not be needed.  Running as your C<nobody> user or
-equivalent is suggested.
-
-=item group
-
-The name or ID of the group that the server should run as; see
-C<user>, above.
-
 =item poll_every
 
 How often the current mailbox should be polled, in seconds; defaults
@@ -146,6 +132,43 @@ be either a relative or absolute path.
 
 =back
 
+It also accepts the following L<Net::Server> arguments -- see its
+documentation for details on their use.
+
+=over
+
+=item L<Net::Server/log_level>
+
+=item L<Net::Server/log_file>
+
+=item L<Net::Server/syslog_logsock>
+
+=item L<Net::Server/syslog_ident>
+
+=item L<Net::Server/syslog_logopt>
+
+=item L<Net::Server/syslog_facility>
+
+=item L<Net::Server/pid_file>
+
+=item L<Net::Server/chroot>
+
+=item L<Net::Server/user>
+
+=item L<Net::Server/group>
+
+=item L<Net::Server/reverse_lookups>
+
+=item L<Net::Server/allow>
+
+=item L<Net::Server/deny>
+
+=item L<Net::Server/cidr_allow>
+
+=item L<Net::Server/cidr_deny>
+
+=back
+
 =cut
 
 sub new {
@@ -167,6 +190,15 @@ sub new {
             connection       => {},
         }
     );
+
+    $self->{server}{$_} = $self->{$_}
+        for grep {defined $self->{$_}}
+            qw/log_level log_file
+               syslog_logsock syslog_ident syslog_logopt syslog_facility
+               pid_file chroot user group
+               reverse_lookups allow deny cidr_allow cidr_deny
+              /;
+
     UNIVERSAL::require( $self->auth_class )
         or die "Can't require auth class: $@\n";
     $self->auth_class->isa("Net::IMAP::Server::DefaultAuth")
@@ -210,8 +242,6 @@ sub run {
     $self->SUPER::run(
         proto => \@proto,
         port  => \@port,
-        user  => $self->user,
-        group => $self->group,
     );
 }
 

commit 9f3cce3c058c6737ea3355b4ec2a7e1e397f288a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Nov 7 23:43:17 2009 -0500

    Add repository to META.yml

diff --git a/META.yml b/META.yml
index 475326e..e6306db 100644
--- a/META.yml
+++ b/META.yml
@@ -36,4 +36,5 @@ requires:
   UNIVERSAL::require: 0
 resources:
   license: http://dev.perl.org/licenses/
+  repository: http://github.com/bestpractical/net-imap-server/
 version: 1.24
diff --git a/Makefile.PL b/Makefile.PL
index d16a82f..30713ac 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,6 +4,7 @@ name ('Net-IMAP-Server');
 author ('Alex Vandiver <alexmv at mit.edu>');
 version_from ('lib/Net/IMAP/Server.pm');
 abstract_from('lib/Net/IMAP/Server.pm');
+repository("http://github.com/bestpractical/net-imap-server/");
 license('perl');
 
 requires('Class::Accessor');

commit c1a8cd5ee8f428dbb951ceca92ad31412d136599
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Nov 7 23:51:54 2009 -0500

    Pass through arguments to Net::Server any arguments to ->run

diff --git a/lib/Net/IMAP/Server.pm b/lib/Net/IMAP/Server.pm
index e8b62e0..e3d6c6b 100644
--- a/lib/Net/IMAP/Server.pm
+++ b/lib/Net/IMAP/Server.pm
@@ -228,6 +228,8 @@ that this was called on; thus, all IMAP objects have a way of
 referring to the server -- and though L</connection>, whatever parts
 of the IMAP internals they need.
 
+Any arguments are passed through to L<Net::Server/run>.
+
 =cut
 
 sub run {
@@ -240,6 +242,7 @@ sub run {
     }
     local $Net::IMAP::Server::Server = $self;
     $self->SUPER::run(
+        @_,
         proto => \@proto,
         port  => \@port,
     );

commit 6626a9a8f1d87f8b6ccd40d73249e7cdce72a7b7
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Nov 7 23:53:42 2009 -0500

    Version 1.25 releng

diff --git a/Changes b/Changes
index e88e015..4e657fb 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,14 @@
 Revision history for Net-IMAP-Server
 
+1.25   Sat Nov  7 23:58:17 2009
+        * BACKWARDS-INCOMPATIBLE CHANGE: Net::IMAP::Server::Command's
+          ->log method takes a loglevel argument by default, and simply
+          defers to Net::Server's logging infratructure.
+        * Handle more of Net::Server's arguments to ->new, including logging
+        * Pass through arguments to Net::Server any arguments to ->run
+        * Support mailboxes with flat hierarchies (undef hierarchy separator)
+        * Fix a bug where UID COPY set two OK responses
+
 1.24   Fri Oct 16 11:01:17 2009
         * Fix overzealous caching during mailbox renaming
         * Bump Net::Server::Coro dep, to be able to specify SSL
diff --git a/META.yml b/META.yml
index e6306db..434d82d 100644
--- a/META.yml
+++ b/META.yml
@@ -37,4 +37,4 @@ requires:
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/bestpractical/net-imap-server/
-version: 1.24
+version: 1.25
diff --git a/SIGNATURE b/SIGNATURE
index 6919eaa..dd3d351 100644
--- a/SIGNATURE
+++ b/SIGNATURE
@@ -14,10 +14,10 @@ not run its Makefile.PL or Build.PL.
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 aa971f9f152b3cf769a24a5a8ece7159753c829c Changes
+SHA1 82560ae74033b2be79ee08301ee6835c2c6d843a Changes
 SHA1 422032f0595e2e18fca67c2975c2c5f617d95569 MANIFEST
-SHA1 d80bca57a1201513490a425aa2921c65467acd35 META.yml
-SHA1 d2f1e54620e4900958d382d42db33b0a68c847eb Makefile.PL
+SHA1 5c7cd13e5a65df62d14d568ec7f20ebf115b5041 META.yml
+SHA1 3028ae2462e9de33c1dbc19b787689d59baeda9d Makefile.PL
 SHA1 f4c6e4793fd7815aec4abfcd69018d8f34d832a8 README
 SHA1 f5333026061a6f347e7f2a3ce8bb6847081c200c certs/server-cert.pem
 SHA1 4b963cd4c2b0a7e073241b4bac727cb6f96276f8 certs/server-key.pem
@@ -30,48 +30,48 @@ SHA1 3e83972921d54198d1246f7278f08664006cd65d inc/Module/Install/Makefile.pm
 SHA1 12bf1867955480d47d5171a9e9c6a96fabe0b58f inc/Module/Install/Metadata.pm
 SHA1 f7ee667e878bd2faf22ee9358a7b5a2cc8e91ba4 inc/Module/Install/Win32.pm
 SHA1 8ed29d6cf217e0977469575d788599cbfb53a5ca inc/Module/Install/WriteAll.pm
-SHA1 b63716db365391882fbe34f3e3a74e0595cfff72 lib/Net/IMAP/Server.pm
-SHA1 e0016d978a1d896866cf27494ae9651d8af50311 lib/Net/IMAP/Server/Command.pm
+SHA1 5280aafdad2518b425ea562b6b54e985e36bb1a2 lib/Net/IMAP/Server.pm
+SHA1 297222972fd9ec4057d427153aa42e050cf0b77e lib/Net/IMAP/Server/Command.pm
 SHA1 14fe0f304abc29508e7871571bd0d3ac739479e6 lib/Net/IMAP/Server/Command/Append.pm
-SHA1 5c203d47099444ceb8ce9e8927353d91ba0545cd lib/Net/IMAP/Server/Command/Authenticate.pm
+SHA1 dd12c27c403385bbfddf52b37b4c9f7c15f0e7a4 lib/Net/IMAP/Server/Command/Authenticate.pm
 SHA1 70f2aeb901dde845183ef6b70f56b4d777641a5d lib/Net/IMAP/Server/Command/Capability.pm
 SHA1 de6607dec53f35b3b3fd41ad12191a83c59ae21b lib/Net/IMAP/Server/Command/Check.pm
 SHA1 514b741e13d400a6c44215ab9bd66b77a16ef18c lib/Net/IMAP/Server/Command/Close.pm
 SHA1 a73779c162243b7c0a0b8af6663f24533b044906 lib/Net/IMAP/Server/Command/Copy.pm
-SHA1 65589737cc3fb5298ff42f10aed5ea9f103931b6 lib/Net/IMAP/Server/Command/Create.pm
+SHA1 2e9d7c336b808d9dffdd261f951614cac500c974 lib/Net/IMAP/Server/Command/Create.pm
 SHA1 a4a9324f35403ed4ff483045fbe51081593ca50a lib/Net/IMAP/Server/Command/Delete.pm
 SHA1 02746080dc893a9673d3ddd3b9d4bbca503b1203 lib/Net/IMAP/Server/Command/Examine.pm
 SHA1 e2a53e75f10e35e4935b807c202a10753c34ce4d lib/Net/IMAP/Server/Command/Expunge.pm
 SHA1 6e8ba2d1fdfa02de45c595d9a5f8c2f444f36aaa lib/Net/IMAP/Server/Command/Fetch.pm
 SHA1 fddb82fad844966a68d38270277c1c7acdb4e998 lib/Net/IMAP/Server/Command/Id.pm
-SHA1 4f526e5a0d1b49e3a37632675980e14c687272ef lib/Net/IMAP/Server/Command/List.pm
-SHA1 7ec3ec0e5f4d7b17105b9ea16d7450f846de5c78 lib/Net/IMAP/Server/Command/Login.pm
+SHA1 20b2b8d5ba56519259b7dc7ef47e190cb55305e9 lib/Net/IMAP/Server/Command/List.pm
+SHA1 ed3e264e5b2d66b5429be5eb0d9ae30449442f38 lib/Net/IMAP/Server/Command/Login.pm
 SHA1 30579885dfc9b80c2c7873bb283e4105d3c74f2a lib/Net/IMAP/Server/Command/Logout.pm
 SHA1 757faacdf957afddd0b0ff659258b8b0e09a0e4b lib/Net/IMAP/Server/Command/Lsub.pm
 SHA1 9184f034fb9e0ba9c504bd0954f3e02283c61b18 lib/Net/IMAP/Server/Command/Namespace.pm
 SHA1 78902aa13c8e79d5abc95fc6de637c1af8783ce2 lib/Net/IMAP/Server/Command/Noop.pm
-SHA1 98545b9ae8eb2420f45c5f08276982d92faadb99 lib/Net/IMAP/Server/Command/Rename.pm
+SHA1 2e4ffb2680ca2b24e7ff85bcc806f9a2f437579a lib/Net/IMAP/Server/Command/Rename.pm
 SHA1 683821b21fc5b4a6c701b7769451516bb9ed205f lib/Net/IMAP/Server/Command/Search.pm
 SHA1 a6d47a6160d2899b33950a93f3d021666269e4f3 lib/Net/IMAP/Server/Command/Select.pm
 SHA1 ffe0dddf90fa8ff02815431e1e2a72ed3f85daf4 lib/Net/IMAP/Server/Command/Starttls.pm
 SHA1 46d29fc4c67ee0e90ddf0a8d018bb8d1545856ed lib/Net/IMAP/Server/Command/Status.pm
 SHA1 bd5fe7da9d541a86d5ae0072e85b1392196227f2 lib/Net/IMAP/Server/Command/Store.pm
 SHA1 3fbb8ce46e696eeb62a97264cb564924a7ccfb57 lib/Net/IMAP/Server/Command/Subscribe.pm
-SHA1 74fcde19d1a8a827f6bb085345cd920ae4cb25f0 lib/Net/IMAP/Server/Command/Uid.pm
+SHA1 fe08fab9418f3dd62cbc0973c228b3c9b4687ef3 lib/Net/IMAP/Server/Command/Uid.pm
 SHA1 4591be8d501ea8877f3b4d4418620cce094256ab lib/Net/IMAP/Server/Command/Unsubscribe.pm
-SHA1 9d8dd9d79ce307cc93495d9074c1a2ae5f37774e lib/Net/IMAP/Server/Connection.pm
+SHA1 41ad22304c7303c4b6e054c25b41972ee6e2937a lib/Net/IMAP/Server/Connection.pm
 SHA1 716c1bb33a3b970dfc80b2d19366b719a48caef3 lib/Net/IMAP/Server/DefaultAuth.pm
-SHA1 9eea45b97044ad2d07db6b8959c6e41d60c550d5 lib/Net/IMAP/Server/DefaultModel.pm
+SHA1 9c919510040feb6aa7c482d72611a663cb609db6 lib/Net/IMAP/Server/DefaultModel.pm
 SHA1 688651b7e624fe1d4bf29e320b05d0872fb54dd0 lib/Net/IMAP/Server/Error.pm
-SHA1 b941a63cdee1518d48a41a6541e21c312e2806b8 lib/Net/IMAP/Server/Mailbox.pm
+SHA1 e745f6390615aa06789078dff8a9e0e0ec6772c0 lib/Net/IMAP/Server/Mailbox.pm
 SHA1 3d7d3d5693b352dfebb5c151c404f627bf52ebb5 lib/Net/IMAP/Server/Message.pm
 SHA1 2e67e318edc490da7367ebcc789d35d0810e00e6 t/00.load.t
 SHA1 ec035a09e3f370620874e9c706d6c8ae4bdfa6a1 t/pod-coverage.t
 SHA1 0190346d7072d458c8a10a45c19f86db641dcc48 t/pod.t
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2.0.11 (GNU/Linux)
+Version: GnuPG v2.0.13 (GNU/Linux)
 
-iEYEARECAAYFAkrYircACgkQMflWJZZAbqCC0wCeP/RNjUDm8qnCyHXplOGAupag
-vJ0An3kW/BGgHc6JtFHYnI3UW+Y4oC5d
-=9o0h
+iEYEARECAAYFAkr2TscACgkQMflWJZZAbqDRHACgkJNALR4TXEi1V4sedmUkLBxQ
+J+IAniUVRV+RNKqG5wljQ6GIEi66OpKW
+=u/Xx
 -----END PGP SIGNATURE-----
diff --git a/lib/Net/IMAP/Server.pm b/lib/Net/IMAP/Server.pm
index e3d6c6b..72108e0 100644
--- a/lib/Net/IMAP/Server.pm
+++ b/lib/Net/IMAP/Server.pm
@@ -8,7 +8,7 @@ use base qw/Net::Server::Coro Class::Accessor/;
 use UNIVERSAL::require;
 use Coro;
 
-our $VERSION = '1.24';
+our $VERSION = '1.25';
 
 =head1 NAME
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list