From: naoki i. <am...@us...> - 2008-05-01 15:21:38
|
Update of /cvsroot/popfile/engine/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8666/UI Modified Files: HTML.pm HTTP.pm Log Message: Change Log 1. New HTML module option 'cookie_cipher' UI/HTML.pm UI/HTTP.pm Users can choose Crypt::DES instead of Crypt::Blowfish. 2. Update POPFile::Random module POPFile/Random.pm POPFile/Module.pm Classifier/Bayes.pm UI/HTML.pm UI/HTTP.pm 3. New test script for POPFile::Random tests/TestRandom.tst 4. Fixed a bug that users couldn't login to the UI on some environment UI/HTTP.pm 5. Add some tests for UI::HTML 6. Update TestHTML.tst to pass tests/TestHTML.script Config bar History tab View log file View text message Session timeout Change language in the multiuser mode 7. Minor fix of the test scripts tests/TestXMLRPC.tst tests/TestPOP3.tst tests/TestHTTP.tst Current state of the test suite: TestBayesScript PASS TestBayes PASS TestConfiguration PASS TestHistory PASS TestHTML PASS TestHTTP PASS TestIMAP PASS TestInsertScript PASS * TestLogger PASS TestMailParse PASS TestModule PASS TestMQ PASS TestMutex PASS TestPipeScript PASS TestPOP3 PASS TestProxy PASS TestWordMangle PASS TestXMLRPC PASS * : TODO : needs to add tests for multi user support Index: HTML.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v retrieving revision 1.394 retrieving revision 1.395 diff -C2 -d -r1.394 -r1.395 *** HTML.pm 30 Apr 2008 14:41:49 -0000 1.394 --- HTML.pm 1 May 2008 15:21:43 -0000 1.395 *************** *** 176,179 **** --- 176,183 ---- $self->config_( 'https_port', 8443 ); + # Encryption module for cookies + + $self->config_( 'cookie_cipher', 'Blowfish' ); + # Load skins *************** *** 424,433 **** # MD5 checksum of the data (hex encoded) - my $module = $self->global_config_( 'random_module' ); - $self->log_( 1, "Generating random octet using $module" ); - $cookie_string = encode_base64( # PROFILE BLOCK START $self->random_()->generate_random_string( - $module, 16, $self->global_config_( 'crypt_strength' ), --- 428,433 ---- *************** *** 490,494 **** my $timeout = 0; ! if ( $cookie ne '' ) { $session = $self->handle_cookie__( $cookie, $client ); if ( defined($session) && ( $session eq 'TIMEOUT' ) ) { --- 490,494 ---- my $timeout = 0; ! if ( defined($cookie) && ( $cookie ne '' ) ) { $session = $self->handle_cookie__( $cookie, $client ); if ( defined($session) && ( $session eq 'TIMEOUT' ) ) { *************** *** 644,649 **** if ( $url =~ /^\/(.+\.ico)/ ) { ! $self->http_file_( $client, $self->get_root_path_( $1 ), ! 'image/x-icon' ); return 1; } --- 644,649 ---- if ( $url =~ /^\/(.+\.ico)/ ) { ! $self->http_file_( $client, $self->get_root_path_( $1 ), # PROFILE BLOCK START ! 'image/x-icon' ); # PROFILE BLOCK STOP return 1; } *************** *** 1725,1730 **** # Handle user creation ! if ( exists( $self->{form_}{create} ) && ! ( $self->{form_}{newuser} ne '' ) ) { my ( $result, $password ) = $self->classifier_()->create_user( # PROFILE BLOCK START $session, --- 1725,1730 ---- # Handle user creation ! if ( exists( $self->{form_}{create} ) && # PROFILE BLOCK START ! ( $self->{form_}{newuser} ne '' ) ) { # PROFILE BLOCK STOP my ( $result, $password ) = $self->classifier_()->create_user( # PROFILE BLOCK START $session, *************** *** 1951,1956 **** $templ->param( 'Users_Loop_ChangePassword' => \@user_loop ); ! if ( exists( $self->{form_}{edituser} ) && ! ( $self->{form_}{editname} ne '' ) ) { my $id = $self->classifier_()->get_user_id( $session, $self->{form_}{editname} ); my @parameters = $self->classifier_()->get_user_parameter_list( $session ); --- 1951,1956 ---- $templ->param( 'Users_Loop_ChangePassword' => \@user_loop ); ! if ( exists( $self->{form_}{edituser} ) && # PROFILE BLOCK START ! ( $self->{form_}{editname} ne '' ) ) { # PROFILE BLOCK STOP my $id = $self->classifier_()->get_user_id( $session, $self->{form_}{editname} ); my @parameters = $self->classifier_()->get_user_parameter_list( $session ); *************** *** 2057,2062 **** if ( defined($self->{form_}{word}) ) { ! my $result = $self->classifier_()->remove_stopword( $session, ! $self->{form_}{word} ); if ( $result == 0 ) { $self->error_message__( $templ, $self->language($session)->{Advanced_Error2} ); --- 2057,2062 ---- if ( defined($self->{form_}{word}) ) { ! my $result = $self->classifier_()->remove_stopword( $session, # PROFILE BLOCK START ! $self->{form_}{word} ); # PROFILE BLOCK STOP if ( $result == 0 ) { $self->error_message__( $templ, $self->language($session)->{Advanced_Error2} ); *************** *** 2136,2141 **** $templ->param( 'Advanced_Loop_Word' => \@word_loop ); ! $templ->param( 'Advanced_POPFILE_CFG' => ! $self->get_user_path_( 'popfile.cfg' ) ); my $last_module = ''; --- 2136,2141 ---- $templ->param( 'Advanced_Loop_Word' => \@word_loop ); ! $templ->param( 'Advanced_POPFILE_CFG' => # PROFILE BLOCK START ! $self->get_user_path_( 'popfile.cfg' ) ); # PROFILE BLOCK STOP my $last_module = ''; *************** *** 2226,2231 **** if ( defined( $self->{form_}{delete} ) ) { for my $i ( 1 .. $self->{form_}{count} ) { ! if ( defined( $self->{form_}{"remove$i"} ) && ! ( $self->{form_}{"remove$i"} ) ) { my $mtype = $self->{form_}{"type$i"}; my $mtext = $self->{form_}{"text$i"}; --- 2226,2231 ---- if ( defined( $self->{form_}{delete} ) ) { for my $i ( 1 .. $self->{form_}{count} ) { ! if ( defined( $self->{form_}{"remove$i"} ) && # PROFILE BLOCK START ! ( $self->{form_}{"remove$i"} ) ) { # PROFILE BLOCK STOP my $mtype = $self->{form_}{"type$i"}; my $mtext = $self->{form_}{"text$i"}; *************** *** 2260,2266 **** } ! if ( ( defined($mbucket) ) && ( $mbucket ne '' ) && ! ( $mtext ne '' ) ) { # Support for feature request 77646 - import function. --- 2260,2266 ---- } ! if ( ( defined($mbucket) ) && # PROFILE BLOCK START ( $mbucket ne '' ) && ! ( $mtext ne '' ) ) { # PROFILE BLOCK STOP # Support for feature request 77646 - import function. *************** *** 2630,2635 **** } ! if ( ( $s == 2 ) && ! ( $self->classifier_()->is_pseudo_bucket( $session, $bucket ) ) ) { $count = ''; $percent = ''; --- 2630,2635 ---- } ! if ( ( $s == 2 ) && # PROFILE BLOCK START ! ( $self->classifier_()->is_pseudo_bucket( $session, $bucket ) ) ) { # PROFILE BLOCK STOP $count = ''; $percent = ''; *************** *** 2725,2730 **** $self->error_message__( $templ, $self->language($session)->{Bucket_Error1} ); } else { ! if ( $self->classifier_()->is_bucket( $session, $self->{form_}{cname} ) || ! $self->classifier_()->is_pseudo_bucket( $session, $self->{form_}{cname} ) ) { $self->error_message__( # PROFILE BLOCK START $templ, --- 2725,2730 ---- $self->error_message__( $templ, $self->language($session)->{Bucket_Error1} ); } else { ! if ( $self->classifier_()->is_bucket( $session, $self->{form_}{cname} ) || # PROFILE BLOCK START ! $self->classifier_()->is_pseudo_bucket( $session, $self->{form_}{cname} ) ) { # PROFILE BLOCK STOP $self->error_message__( # PROFILE BLOCK START $templ, *************** *** 3028,3035 **** while ( $i < $self->history_()->get_query_size( $q ) ) { my %row_data; ! if ( ( $i == 0 ) || ( ( $i + $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) >= $self->history_()->get_query_size( $q ) ) || ( ( ( $i - 2 * $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) <= $start_message ) && ! ( ( $i + 2 * $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) >= $start_message ) ) ) { $row_data{History_Navigator_Page} = $p; $row_data{History_Navigator_I} = $i; --- 3028,3035 ---- while ( $i < $self->history_()->get_query_size( $q ) ) { my %row_data; ! if ( ( $i == 0 ) || # PROFILE BLOCK START ( ( $i + $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) >= $self->history_()->get_query_size( $q ) ) || ( ( ( $i - 2 * $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) <= $start_message ) && ! ( ( $i + 2 * $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ) ) >= $start_message ) ) ) { # PROFILE BLOCK STOP $row_data{History_Navigator_Page} = $p; $row_data{History_Navigator_I} = $i; *************** *** 3201,3205 **** if ( defined( $self->{form_}{gopage} ) ) { ! my $destination = ( $self->{form_}{jumptopage} - 1 ) * # PROFILE BLOCK START $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ); # PROFILE BLOCK STOP my $q = $self->{sessions__}{$session}{q}; --- 3201,3207 ---- if ( defined( $self->{form_}{gopage} ) ) { ! my $jumptopage = $self->{form_}{jumptopage}; ! $jumptopage = 1 if ( ( $jumptopage eq '' ) || ( $jumptopage =~ /[^\d]/ ) ); ! my $destination = ( $jumptopage - 1 ) * # PROFILE BLOCK START $self->user_config_( $self->{sessions__}{$session}{user}, 'page_size' ); # PROFILE BLOCK STOP my $q = $self->{sessions__}{$session}{q}; *************** *** 3212,3217 **** } ! $templ = $self->handle_configuration_bar__( $client, $templ, $template, ! $page, $session ); $self->handle_history_bar__( $client, $templ, $template, $page, $session ); --- 3214,3219 ---- } ! $templ = $self->handle_configuration_bar__( $client, $templ, $template, # PROFILE BLOCK START ! $page, $session ); # PROFILE BLOCK STOP $self->handle_history_bar__( $client, $templ, $template, $page, $session ); *************** *** 3439,3443 **** my %row_data; $header =~ /^(.)/; ! next if ( $1 eq '-' ); $colspan++; $header =~ s/^.//; --- 3441,3445 ---- my %row_data; $header =~ /^(.)/; ! next if ( ( $1 eq '-' ) || ( $1 eq '' ) ); $colspan++; $header =~ s/^.//; *************** *** 3557,3564 **** $self->shorten__( $$row[4], $length, $language_for_user ); # PROFILE BLOCK STOP $col_data{History_Mail_File} = $$row[0]; ! $col_data{History_Fields} = ! $self->print_form_fields_(0,1, # PROFILE BLOCK START ('start_message','filter','search', ! 'sort','negate' ) ); # PROFILE BLOCK STOP push ( @column_data, \%col_data ); next; --- 3559,3566 ---- $self->shorten__( $$row[4], $length, $language_for_user ); # PROFILE BLOCK STOP $col_data{History_Mail_File} = $$row[0]; ! $col_data{History_Fields} = # PROFILE BLOCK START ! $self->print_form_fields_(0,1, ('start_message','filter','search', ! 'sort','negate' ) ); # PROFILE BLOCK STOP push ( @column_data, \%col_data ); next; *************** *** 3925,3930 **** $self->{form_}{username} = 'admin' if ( $single_user ); ! if ( exists( $self->{form_}{username} ) && ! exists( $self->{form_}{password} ) ) { $session = $self->classifier_()->get_session_key( # PROFILE BLOCK START $self->{form_}{username}, --- 3927,3932 ---- $self->{form_}{username} = 'admin' if ( $single_user ); ! if ( exists( $self->{form_}{username} ) && # PROFILE BLOCK START ! exists( $self->{form_}{password} ) ) { # PROFILE BLOCK STOP $session = $self->classifier_()->get_session_key( # PROFILE BLOCK START $self->{form_}{username}, Index: HTTP.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/HTTP.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** HTTP.pm 30 Apr 2008 14:41:49 -0000 1.42 --- HTTP.pm 1 May 2008 15:21:43 -0000 1.43 *************** *** 125,139 **** # Think of an encryption key for encrypting cookies using Blowfish ! my $module = $self->global_config_( 'random_module' ); ! $self->log_( 1, "Generating random octet using $module" ); my $key = $self->random_()->generate_random_string( # PROFILE BLOCK START ! $module, ! 56, $self->global_config_( 'crypt_strength' ), $self->global_config_( 'crypt_devide' ) ); # PROFILE BLOCK STOP $self->{crypto__} = new Crypt::CBC( { 'key' => $key, # PROFILE BLOCK START ! 'cipher' => 'Blowfish', 'padding' => 'standard', 'prepend_iv' => 0, --- 125,145 ---- # Think of an encryption key for encrypting cookies using Blowfish ! my $cipher = $self->config_( 'cookie_cipher' ); ! my $key_length = 8; ! ! if ( $cipher =~ /(Crypt::)?Blowfish/i ) { ! $key_length = 56; ! } ! if ( $cipher =~ /(Crypt::)?DES/i ) { ! $key_length = 8; ! } my $key = $self->random_()->generate_random_string( # PROFILE BLOCK START ! $key_length, $self->global_config_( 'crypt_strength' ), $self->global_config_( 'crypt_devide' ) ); # PROFILE BLOCK STOP $self->{crypto__} = new Crypt::CBC( { 'key' => $key, # PROFILE BLOCK START ! 'cipher' => $cipher, 'padding' => 'standard', 'prepend_iv' => 0, *************** *** 156,162 **** my ( $self ) = @_; ! if ( defined( $self->{server__} ) ) { foreach my $protocol ( keys %{$self->{server_}} ) { ! close $self->{server_}{$protocol}; } } --- 162,168 ---- my ( $self ) = @_; ! if ( defined( $self->{server_} ) ) { foreach my $protocol ( keys %{$self->{server_}} ) { ! close $self->{server_}{$protocol} if ( defined( $self->{server_}{$protocol} ) ); } } *************** *** 316,325 **** $cookie =~ /popfile=([^\r\n]+)/; ! if ( defined( $1 ) && ( length( $1 ) eq 216 ) ) { my $decoded_cookie = decode_base64( $1 ); ! if ( $decoded_cookie =~ /^Salted__(.{8})/ ) { ! # print "Decrypted : ", $self->{crypto__}->decrypt( $decoded_cookie ), "\n"; ! return $self->{crypto__}->decrypt( $decoded_cookie ); ! } } --- 322,336 ---- $cookie =~ /popfile=([^\r\n]+)/; ! if ( defined( $1 ) ) { my $decoded_cookie = decode_base64( $1 ); ! my $result = ''; ! ! # Workaround to avoid crash when a wrong cookie is sent ! ! eval { ! $result = $self->{crypto__}->decrypt( $decoded_cookie ); ! }; ! ! return $result; } |