From: naoki i. <am...@us...> - 2008-04-06 08:27:05
|
Update of /cvsroot/popfile/engine/Classifier In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14448/Classifier Modified Files: Bayes.pm 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: Bayes.pm =================================================================== RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v retrieving revision 1.361 retrieving revision 1.362 diff -C2 -d -r1.361 -r1.362 *** Bayes.pm 5 Apr 2008 16:50:45 -0000 1.361 --- Bayes.pm 6 Apr 2008 08:27:07 -0000 1.362 *************** *** 297,300 **** --- 297,302 ---- # characters(EUC-JP). + # TODO : hardcoded 1 + if ( defined( $self->user_module_config_( 1, 'html', 'language' ) ) && ( $self->user_module_config_( 1, 'html', 'language' ) =~ /^Nihongo|Korean$/ )) { *************** *** 305,308 **** --- 307,312 ---- # Pass in the current interface language for language specific parsing + # TODO : hardcoded 1 + $self->{parser__}->{lang__} = $self->user_module_config_( 1, 'html', 'language' ) || ''; $self->{unclassified__} = log( $self->user_config_( 1, 'unclassified_weight' ) ); *************** *** 1711,1715 **** #---------------------------------------------------------------------------- # ! # get_session_key_from_token # # Gets a session key from a account token --- 1715,1746 ---- #---------------------------------------------------------------------------- # ! # get_single_user_session_key ! # ! # Returns a string based session key for the administrator. WARNING ! # this is not for external use. This function bypasses all ! # authentication checks and gives admin access. Should only be called ! # in the top-level POPFile process. ! # ! #---------------------------------------------------------------------------- ! sub get_single_user_session_key ! { ! my ( $self ) = @_; ! ! my $single_user_session = $self->generate_unique_session_key__(); ! $self->{api_sessions__}{$single_user_session} = 1; ! $self->db_update_cache__( $single_user_session ); ! $self->log_( 1, "get_session_key_from_token returning key $single_user_session for the single user mode" ); ! ! # Send the session to the parent so that it is recorded and can ! # be correctly shutdown ! ! $self->mq_post_( 'CREAT', $single_user_session, 1 ); ! ! return $single_user_session; ! } ! ! #---------------------------------------------------------------------------- ! # ! # get_session_key_from_token (ADMIN ONLY) # # Gets a session key from a account token *************** *** 1726,1741 **** my ( $self, $session, $module, $token ) = @_; ! # Verify that the user has an administrator session set up ! if ( !$self->is_admin_session( $session ) ) { ! return undef; } ! # If we are in single user mode then simply return the ! # administrator session for compatibility with old versions of ! # POPFile. ! if ( $self->global_config_( 'single_user' ) == 1 ) { ! return $session; } --- 1757,1774 ---- my ( $self, $session, $module, $token ) = @_; ! # If we are in single user mode then return the single user ! # mode session (a new administrator session) for compatibility ! # with old versions of POPFile. ! if ( $self->global_config_( 'single_user' ) == 1 ) { ! # Generate a new session for the single user mode ! ! return $self->get_single_user_session_key(); } ! # Verify that the user has an administrator session set up ! if ( !$self->is_admin_session( $session ) ) { ! return undef; } *************** *** 1744,1763 **** # accounts. ! if ( $module ne 'pop3' ) { ! return $session; } ! # Check the token against the associations in the database and ! # figure out which user is being talked about ! my $result = $self->{db_get_user_from_account__}->execute( ! "$module:$token" ); ! if ( !defined( $result ) ) { ! $self->log_( 1, "Unknown account $module:$token" ); ! return undef; ! } ! my $rows = $self->{db_get_user_from_account__}->fetchrow_arrayref; ! my $user = defined( $rows )?$rows->[0]:undef; if ( !defined( $user ) ) { --- 1777,1824 ---- # accounts. ! if ( ( $module ne 'pop3' ) && ( $module ne 'insert' ) ) { ! return $self->get_single_user_session_key(); } ! my $user; ! if ( $module eq 'pop3' ) { ! my ( $server, $username ) = split( /:/, $token ); ! my $secure_server = $self->module_config_( 'pop3', 'secure_server' ); ! ! if ( defined( $secure_server ) && ( $secure_server eq $server ) ) { ! ! # transparent proxy mode ! ! $self->log_( 2, "Connect $server via transparent proxy mode" ); ! ! if ( !defined($server) || !defined($username) ) { ! $self->log_( 1, "Unknown account $module:$token" ); ! return undef; ! } ! ! $user = $self->get_user_id( $session, $username ); ! ! } else { ! ! # Check the token against the associations in the database and ! # figure out which user is being talked about ! ! my $result = $self->{db_get_user_from_account__}->execute( ! "$module:$token" ); ! if ( !defined( $result ) ) { ! $self->log_( 1, "Unknown account $module:$token" ); ! return undef; ! } ! ! my $rows = $self->{db_get_user_from_account__}->fetchrow_arrayref; ! $user = defined( $rows )?$rows->[0]:undef; ! } ! } elsif ( $module eq 'insert' ) { ! # insert.pl ! ! $user = $self->get_user_id( $session, $token ); ! } if ( !defined( $user ) ) { *************** *** 2400,2403 **** --- 2461,2467 ---- my $msg_file; + # User's id of the current session + my $userid = $self->valid_session_key__( $session ); + # If we don't yet know the classification then start the parser *************** *** 2405,2409 **** if ( $class eq '' ) { $self->{parser__}->start_parse(); - my $userid = $self->valid_session_key__( $session ); ( $slot, $msg_file ) = $self->history_()->reserve_slot( $session, $userid ); } else { --- 2469,2472 ---- *************** *** 2542,2548 **** my $quarantine = $self->get_bucket_parameter( $session, $classification, 'quarantine' ); ! # TODO : Should we use user's configuration? ! ! my $modification = $self->user_config_( 1, 'subject_mod_left' ) . $classification . $self->user_config_( 1, 'subject_mod_right' ); # Add the Subject line modification or the original line back again --- 2605,2609 ---- my $quarantine = $self->get_bucket_parameter( $session, $classification, 'quarantine' ); ! my $modification = $self->user_config_( $userid, 'subject_mod_left' ) . $classification . $self->user_config_( $userid, 'subject_mod_right' ); # Add the Subject line modification or the original line back again *************** *** 2572,2578 **** # Add the XPL header ! # TODO : Should we use user's configuration? ! ! my $xpl = $self->user_config_( 1, 'xpl_angle' )?'<':''; my $xpl_localhost = ($self->config_( 'localhostname' ) eq '')?"127.0.0.1":$self->config_( 'localhostname' ); --- 2633,2637 ---- # Add the XPL header ! my $xpl = $self->user_config_( $userid, 'xpl_angle' )?'<':''; my $xpl_localhost = ($self->config_( 'localhostname' ) eq '')?"127.0.0.1":$self->config_( 'localhostname' ); *************** *** 2582,2588 **** $xpl .= ":" . $self->module_config_( 'html', 'port' ) . "/jump_to_message?view=$slot"; ! # TODO : Should we use user's configuration? ! ! if ( $self->user_config_( 1, 'xpl_angle' ) ) { $xpl .= '>'; } --- 2641,2645 ---- $xpl .= ":" . $self->module_config_( 'html', 'port' ) . "/jump_to_message?view=$slot"; ! if ( $self->user_config_( $userid, 'xpl_angle' ) ) { $xpl .= '>'; } *************** *** 3571,3574 **** --- 3628,3632 ---- if ( defined( $id ) ) { my $result = $self->set_password_for_user( $session, $id, $password ); + $self->log_( 1, "Password initialized for user '$user' by user $userid" ); if ( $result == 1 ) { return (0, $password); *************** *** 3610,3613 **** --- 3668,3672 ---- if ( defined( $id ) ) { my $result = $self->set_password_for_user( $session, $id, $password ); + $self->log_( 1, "Password changed for user '$user' by user $userid" ); if ( $result == 1 ) { return 0; *************** *** 4588,4592 **** # Pass language parameter to add_stopword() ! # TODO : hard-coded 1 return $self->{parser__}->{mangle__}->add_stopword( $stopword, $self->user_module_config_( 1, 'html', 'language' ) ); --- 4647,4651 ---- # Pass language parameter to add_stopword() ! # TODO : hardcoded 1 return $self->{parser__}->{mangle__}->add_stopword( $stopword, $self->user_module_config_( 1, 'html', 'language' ) ); *************** *** 4602,4606 **** # Pass language parameter to remove_stopword() ! # TODO : hard-coded 1 return $self->{parser__}->{mangle__}->remove_stopword( $stopword, $self->user_module_config_( 1, 'html', 'language' ) ); --- 4661,4665 ---- # Pass language parameter to remove_stopword() ! # TODO : hardcoded 1 return $self->{parser__}->{mangle__}->remove_stopword( $stopword, $self->user_module_config_( 1, 'html', 'language' ) ); |