|
33 | 33 |
|
34 | 34 | @require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
|
35 | 35 | require_api( 'install_helper_functions_api.php' );
|
| 36 | +require_api( 'crypto_api.php' ); |
36 | 37 | $g_error_send_page_header = false; # bypass page headers in error handler
|
37 | 38 |
|
38 | 39 | $g_failed = false;
|
@@ -712,7 +713,7 @@ function InsertData( $p_table, $p_data ) {
|
712 | 713 | if( $f_log_queries ) {
|
713 | 714 | if( $t_sql ) {
|
714 | 715 | foreach( $sqlarray as $sql ) {
|
715 |
| - echo htmlentities( $sql ) . ";\r\n\r\n"; |
| 716 | + echo htmlentities( $sql ) . ";\n\n"; |
716 | 717 | }
|
717 | 718 | }
|
718 | 719 | } else {
|
@@ -741,7 +742,7 @@ function InsertData( $p_table, $p_data ) {
|
741 | 742 | }
|
742 | 743 | if( $f_log_queries ) {
|
743 | 744 | # add a query to set the database version
|
744 |
| - echo 'INSERT INTO ' . db_get_table( 'config' ) . ' ( value, type, access_reqd, config_id, project_id, user_id ) VALUES (\'' . $lastid . '\', 1, 90, \'database_version\', 0, 0 );' . "\r\n"; |
| 745 | + echo 'INSERT INTO ' . db_get_table( 'config' ) . ' ( value, type, access_reqd, config_id, project_id, user_id ) VALUES (\'' . $lastid . '\', 1, 90, \'database_version\', 0, 0 );' . "\n"; |
745 | 746 | echo '</pre><br /><p style="color:red">Your database has not been created yet. Please create the database, then install the tables and data using the information above before proceeding.</p></td></tr>';
|
746 | 747 | }
|
747 | 748 | }
|
@@ -801,22 +802,28 @@ function InsertData( $p_table, $p_data ) {
|
801 | 802 | ?>
|
802 | 803 | </td>
|
803 | 804 | <?php
|
804 |
| - $t_config = '<?php' . "\r\n"; |
805 |
| - $t_config .= "\t\$g_hostname = '$f_hostname';\r\n"; |
806 |
| - $t_config .= "\t\$g_db_type = '$f_db_type';\r\n"; |
807 |
| - $t_config .= "\t\$g_database_name = '$f_database_name';\r\n"; |
808 |
| - $t_config .= "\t\$g_db_username = '$f_db_username';\r\n"; |
809 |
| - $t_config .= "\t\$g_db_password = '$f_db_password';\r\n"; |
| 805 | + $t_config = '<?php' . "\n"; |
| 806 | + $t_config .= "\t\$g_hostname = '$f_hostname';\n"; |
| 807 | + $t_config .= "\t\$g_db_type = '$f_db_type';\n"; |
| 808 | + $t_config .= "\t\$g_database_name = '$f_database_name';\n"; |
| 809 | + $t_config .= "\t\$g_db_username = '$f_db_username';\n"; |
| 810 | + $t_config .= "\t\$g_db_password = '$f_db_password';\n"; |
810 | 811 |
|
811 | 812 | if( $f_db_type == 'db2' ) {
|
812 |
| - $t_config .= "\t\$g_db_schema = '$f_db_schema';\r\n"; |
| 813 | + $t_config .= "\t\$g_db_schema = '$f_db_schema';\n"; |
813 | 814 | }
|
814 | 815 |
|
815 |
| - $t_config .= "\r\n"; |
816 |
| - |
817 |
| - # generate a crypto salt based on time of installation. |
818 |
| - $t_crypto_master_salt = md5((string)time()); |
819 |
| - $t_config .= "\t\$g_crypto_master_salt = '$t_crypto_master_salt';\r\n"; |
| 816 | + $t_config .= "\n"; |
| 817 | + |
| 818 | + /* Automatically generate a strong master salt/nonce for MantisBT |
| 819 | + * cryptographic purposes. If a strong source of randomness is not |
| 820 | + * available the user will have to manually set this value post |
| 821 | + * installation. |
| 822 | + */ |
| 823 | + $t_crypto_master_salt = crypto_generate_random_string(32); |
| 824 | + if ($t_crypto_master_salt !== null) { |
| 825 | + $t_config .= "\t\$g_crypto_master_salt = '$t_crypto_master_salt';\n"; |
| 826 | + } |
820 | 827 |
|
821 | 828 | $t_write_failed = true;
|
822 | 829 |
|
|
0 commit comments