From: naoki i. <am...@us...> - 2008-04-06 08:27:05
|
Update of /cvsroot/popfile/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14448 Modified Files: insert.pl Log Message: Change Log 1. There's no need to create account if pop3 transparent proxy server is used 2. Add a new option to use SSL when using pop3 transparent proxy 3. Add a new test for get_session_key_from_token with pop3 transparent proxy Proxy/POP3.pm Classifier/Bayes.pm skins/default/pop3-chain-panel.thtml languages/English.msg tests/TestBayes.tst Memo: If the pop3 transparent proxy server is defined (e.g. mail.example.com), POPFile will accept 'USER username' command and act as if the user 'username' has an account 'use...@ma...'. 4. insert.pl now supports multiuser mode insert.pl Classifier/Bayes.pm New command line options: insert.pl - insert mail messages into a specific bucket of the specific user Usage: insert.pl [<user>] <bucket> <messages> <user> The name of the user (multiuser mode only) <bucket> The name of the bucket <messages> Filename of message(s) to insert 5. A new session key is generated in the single user mode to avoid releasing administrator's session key Proxy/POP3.pm Classifier/Bayes.pm tests/TestBayes.tst 6. Merged a patch to solve the sqlite3 (DBD::SQLite 1.x) issues POPFile/History.pm 7. Fixed a bug that POP3.pm had not passed get_slot_fields no session keys Proxy/POP3.pm 8. New tips for deleting accounts from user skins/users-page.thtml languages/English.msg 9. New XMLRPC APIs (Ticket #39) POPFile/API.pm New APIs get_user_name_from_session initialize_users_password (ADMIN ONLY) change_users_password (ADMIN ONLY) set_password_for_user get_user_name_from_id 10. Update language file languages/Nihongo.msg Current state of the test suite: TestBayesScript PASS TestBayes PASS TestConfiguration PASS * TestHistory PASS * TestHTML PASS * TestHTTP PASS TestIMAP not tested yet TestInsertScript PASS * TestLogger PASS TestMailParse PASS TestModule PASS TestMQ PASS TestMutex PASS TestPipeScript PASS TestPOP3 fail (horribly) TestProxy PASS TestWordMangle PASS TestXMLRPC PASS (but child process does not terminate) * : needs to add tests for multi user support TODO 1. multi user mode tests are needed tests/TestConfiguration.tst tests/TestHistory.tst tests/TestHTML.tst tests/TestInsertScript.tst Index: insert.pl =================================================================== RCS file: /cvsroot/popfile/engine/insert.pl,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** insert.pl 6 Feb 2006 15:09:54 -0000 1.41 --- insert.pl 6 Apr 2008 08:27:07 -0000 1.42 *************** *** 44,57 **** $POPFile->CORE_initialize(); ! my $bucket = shift @ARGV; ! ! my @files; ! ! if ($^O =~ /linux/) { ! @files = @ARGV[0 .. $#ARGV]; ! } else { ! @files = map { glob } @ARGV[0 .. $#ARGV]; ! } ! @ARGV = (); --- 44,48 ---- $POPFile->CORE_initialize(); ! my @argv_backup = @ARGV; @ARGV = (); *************** *** 63,66 **** --- 54,70 ---- $c->config_( 'piddir', $c->config_( 'piddir' ) . 'insert.pl.' ); + my $multiuser_mode = ( $c->global_config_( 'single_user' ) != 1 ); + + my $user = shift @argv_backup if ( $multiuser_mode ); + my $bucket = shift @argv_backup; + + my @files; + + if ($^O =~ /linux/) { + @files = @argv_backup[0 .. $#argv_backup]; + } else { + @files = map { glob } @argv_backup[0 .. $#argv_backup]; + } + $POPFile->CORE_start(); *************** *** 69,73 **** my $b = $POPFile->get_module('Classifier::Bayes'); ! my $session = $b->get_session_key( 'admin', '' ); # Check for the existence of each file first because the API --- 73,77 ---- my $b = $POPFile->get_module('Classifier::Bayes'); ! my $session = $b->get_administrator_session_key(); # Check for the existence of each file first because the API *************** *** 82,101 **** } if ( $code == 0 ) { ! if ( !$b->is_bucket( $session, $bucket ) ) { print STDERR "Error: Bucket `$bucket' does not exist, insert aborted.\n"; $code = 1; } else { ! $b->add_messages_to_bucket( $session, $bucket, @files ); print "Added ", $#files+1, " files to `$bucket'\n"; } } $b->release_session_key( $session ); $POPFile->CORE_stop(); } } else { ! print "insert.pl - insert mail messages into a specific bucket\n\n"; ! print "Usage: insert.pl <bucket> <messages>\n"; print " <bucket> The name of the bucket\n"; print " <messages> Filename of message(s) to insert\n"; --- 86,124 ---- } + # Multiuser support + + my $user_session; + + if ( $multiuser_mode ) { + + # Get user's session id + + $user_session = $b->get_session_key_from_token( $session, 'insert', $user ); + if ( !defined($user_session) ) { + print STDERR "Error: User `$user' does not exist, insert aborted.\n"; + $code = 1; + } + } else { + $user_session = $session; + } + if ( $code == 0 ) { ! if ( !$b->is_bucket( $user_session, $bucket ) ) { print STDERR "Error: Bucket `$bucket' does not exist, insert aborted.\n"; $code = 1; } else { ! $b->add_messages_to_bucket( $user_session, $bucket, @files ); print "Added ", $#files+1, " files to `$bucket'\n"; } } + $b->release_session_key( $user_session ) if ( $multiuser_mode && defined($user_session) ); $b->release_session_key( $session ); $POPFile->CORE_stop(); } } else { ! print "insert.pl - insert mail messages into a specific bucket of the specific user\n\n"; ! print "Usage: insert.pl [<user>] <bucket> <messages>\n"; ! print " <user> The name of the user (multiuser mode only)\n"; print " <bucket> The name of the bucket\n"; print " <messages> Filename of message(s) to insert\n"; |