nilsteampassnet / TeamPass

Collaborative Passwords Manager
https://www.teampass.net
1.66k stars 543 forks source link

Upgrade 2.1.27.36 to 3.0.0.20 does not work #3375

Open fuserke opened 1 year ago

fuserke commented 1 year ago
### Steps to reproduce 1. install old latest 2.1.27.36 we've imported a backup of the db (everything is working) 2. follow the upgrade procedure to 3.0.0.20 (copy original dir to teampassv2, copy new files in the original dir teampass) 3. run /install/upgrade.php ### Expected behaviour Upgrade.php should ask for uid and pw of the admin. START -> follow all the other upgrade steps and then upgrade should start with changing the db. ### Actual behaviour Upgrade.php ask for uid and pw of the admin. We press START and then the ajax keeps on turning. The we rename the file tp.config.php and we rerun the upgrade.php -> uid and pw > and we can start and follow till the end. But when we want to start doing the db upgrade the script stays on Loop#1. ### Server configuration **Operating system**: Windows 2019 **Web server:** IIS **Database:** Mysql 8.0.31 **PHP version:** PHP 7.4.32 **Teampass version:** 2.1.27.36 **Teampass configuration file:** global $SETTINGS; $SETTINGS = array ( 'max_latest_items' => '10', 'enable_favourites' => '1', 'show_last_items' => '1', 'enable_pf_feature' => '1', 'log_connections' => '1', 'log_accessed' => '1', 'time_format' => 'H:i:s', 'date_format' => 'd/m/Y', 'duplicate_folder' => '1', 'item_duplicate_in_same_folder' => '0', 'duplicate_item' => '1', 'number_of_used_pw' => '5', 'manager_edit' => '1', 'cpassman_dir' => 'C:/inetpub/wwwroot/secrettest', 'cpassman_url' => 'https://secrettest', 'favicon' => 'https://secrettest/favicon.ico', 'path_to_upload_folder' => 'C:/inetpub/wwwroot/secrettest/upload', 'url_to_upload_folder' => 'https://secrettest/upload', 'path_to_files_folder' => 'C:/inetpub/wwwroot/secrettest/files', 'url_to_files_folder' => 'https://secrettest/files', 'activate_expiration' => '0', 'pw_life_duration' => '0', 'maintenance_mode' => '1', 'enable_sts' => '0', 'encryptClientServer' => '1', 'cpassman_version' => '2.1.27', 'ldap_mode' => '1', 'ldap_type' => '**REDACTED**', 'ldap_suffix' => '**REDACTED**', 'ldap_domain_dn' => '**REDACTED**', 'ldap_domain_controler' => '**REDACTED**', 'ldap_user_attribute' => '0', 'ldap_ssl' => '0', 'ldap_tls' => '0', 'ldap_elusers' => '0', 'ldap_search_base' => '0', 'ldap_port' => '389', 'richtext' => '0', 'allow_print' => '1', 'roles_allowed_to_print' => '12', 'show_description' => '1', 'anyone_can_modify' => '1', 'anyone_can_modify_bydefault' => '1', 'nb_bad_authentication' => '0', 'utf8_enabled' => '1', 'restricted_to' => '0', 'restricted_to_roles' => '0', 'enable_send_email_on_user_login' => '0', 'enable_user_can_create_folders' => '1', 'insert_manual_entry_item_history' => '0', 'enable_kb' => '0', 'enable_email_notification_on_item_shown' => '0', 'enable_email_notification_on_user_pw_change' => '0', 'custom_logo' => '', 'custom_login_text' => '**REDACTED**', 'default_language' => 'english', 'send_stats' => '0', 'send_statistics_items' => '', 'send_stats_time' => '1544449076', 'get_tp_info' => '0', 'send_mail_on_user_login' => '0', 'nb_items_by_query' => 'auto', 'enable_delete_after_consultation' => '0', 'enable_personal_saltkey_cookie' => '0', 'personal_saltkey_cookie_duration' => '90', 'email_smtp_server' => '10.133.0.46', 'email_smtp_auth' => '', 'email_auth_username' => '', 'email_auth_pwd' => '', 'email_port' => '25', 'email_security' => '', 'email_server_url' => '', 'email_from' => 'secret@**REDACTED**', 'email_from_name' => 'Password server', 'pwd_maximum_length' => '40', 'google_authentication' => '0', 'delay_item_edition' => '0', 'allow_import' => '1', 'proxy_ip' => '**REDACTED**', 'proxy_port' => '**REDACTED**', 'upload_maxfilesize' => '0mb', 'upload_docext' => 'doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx', 'upload_imagesext' => 'jpg,jpeg,gif,png', 'upload_pkgext' => '7z,rar,tar,zip', 'upload_otherext' => 'sql,xml', 'upload_imageresize_options' => '1', 'upload_imageresize_width' => '800', 'upload_imageresize_height' => '600', 'upload_imageresize_quality' => '90', 'use_md5_password_as_salt' => '0', 'ga_website_name' => '**REDACTED** Secret Server', 'api' => '1', 'subfolder_rights_as_parent' => '1', 'show_only_accessible_folders' => '1', 'enable_suggestion' => '0', 'otv_expiration_period' => '7', 'default_session_expiration_time' => '240', 'duo' => '0', 'enable_server_password_change' => '0', 'ldap_object_class' => '0', 'bck_script_path' => 'C:/inetpub/wwwroot/secrettest/backups', 'bck_script_filename' => 'bck_teampass', 'syslog_enable' => '0', 'syslog_host' => 'localhost', 'syslog_port' => '514', 'manager_move_item' => '1', 'create_item_without_password' => '0', 'otv_is_enabled' => '0', 'agses_authentication_enabled' => '0', 'item_extra_fields' => '0', 'saltkey_ante_2127' => 'none', 'migration_to_2127' => 'done', 'files_with_defuse' => 'done', 'timezone' => 'Europe/Brussels', 'enable_attachment_encryption' => '1', 'personal_saltkey_security_level' => '50', 'ldap_new_user_is_administrated_by' => '0', 'disable_show_forgot_pwd_link' => '1', 'offline_key_level' => '60', 'enable_http_request_login' => '0', 'ldap_and_local_authentication' => '1', 'secure_display_image' => '1', 'upload_zero_byte_file' => '0', 'upload_all_extensions_file' => '0', 'bck_script_passkey' => '**REDACTED**', 'admin_2fa_required' => '0', 'teampass_version' => '2.1.27', 'can_create_root_folder' => '1', 'copy_to_clipboard_small_icons' => '1', 'tree_counters' => '1', 'settings_offline_mode' => '1', 'ldap_new_user_role' => '21', 'ga_reset_by_user' => '1', 'use_http_request_login' => '0', 'yubico_authentication' => '0', ); **Updated from an older Teampass or fresh install:** PLEASE attach to this issue the file `/includes/config/tp.config.php`. Update from older Teampass ### Client configuration **Browser:** Chrome (cache cleared) Firefox (cache cleared) **Operating system:** Windows 11 ### Logs #### Web server error log none Insert your webserver log here ``` #### Log from the web-browser developer console (CTRL + SHIFT + i) ``` Insert the log here and especially the answer of the query that failed. No answer to be seen. It just stops working
Martinezio commented 1 year ago

I had the same issue. This issue occurs due to change of items table, column complexity_level from default null to not null default -1. Unfortunately, some items may have already contain the null value and this cause to crash the script.

Such error in apache's errorlog will appear:

PHP Fatal error: Uncaught mysqli_sql_exception: Invalid use of NULL value in /home/www/TeamPass-3.0.0.20/install/upgrade_run_3.0.0.php:1212\nStack trace:\n#0 /home/www/TeamPass-3.0.0.20/install/upgrade_run_3.0.0.php(1212): mysqli_query()\n#1 {main}\n thrown in /home/www/TeamPass-3.0.0.20/install/upgrade_run_3.0.0.php on line 1212, referer: https://teampass.host/install/upgrade.php

Proposed solution To fix this, You have to add to upgrade_run_3.0.0.php file following lines starting at line 1209:

mysqli_query( $db_link, "UPDATE " . $pre . "items SET complexity_level='-1' WHERE complexity_level IS NULL;" );

After this, upgrade will go through smoothly.

Good luck!

fuserke commented 1 year ago

@Martinezio I've added the lines in the upgrade_run_3.0.0.php but i still have the same behaviour that i do not go through the first step. Give uid and pw and then the ajax keeps on running. When i rename the tp.config file it goes through but that's not how the upgrade should work

fuserke commented 1 year ago

Hi all

Found why it was hanging on the first step. Seems that the tp.config.php was in encoding utf8-BOM instead of utf8. Changed the encoding and it is passing. But now it is stuck in the database updates step: 09:11:33 - upgrade_run_3.0.0.php - Loop #1 is now running ... Already there for a good amount of time. There are not that many items in the database.

gr

Martinezio commented 1 year ago

Just try on bare V2 database, that wasn't touched by upgrade script. When You re-try on the same database, that was already tried to upgrade, then You will have crashes of upgrade script due to existing keys or columns, that was done with previous attempt.

Restore database from last backup and it should be fine.

Good luck!

pon., 24 paź 2022, 08:07 użytkownik fuserke @.***> napisał:

@Martinezio https://github.com/Martinezio I've added the lines in the upgrade_run_3.0.0.php but i still have the same behaviour that i do not go through the first step. Give uid and pw and then the ajax keeps on running. When i rename the tp.config file it goes through but that's not how the upgrade should work

— Reply to this email directly, view it on GitHub https://github.com/nilsteampassnet/TeamPass/issues/3375#issuecomment-1288464306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR33PNABCI6LFRJYOKTEZ5DWEYRTRANCNFSM6AAAAAARIEQ5DE . You are receiving this because you were mentioned.Message ID: @.***>

fuserke commented 1 year ago

@Martinezio Yes i did that and all went through. Now everything is working except that it says: Personal Salt Key is incorrect. Thing is that i still have my V2 running and tried with the same salt key and there it is working like a charm. So i'm trying to find out why it is happening. Seems that there is already an issue logged for that but no solution other then keeping a V2 running next to a V3 and manually migrating. Which i cannot do cause i have a lot of users with a lot of private pw's

aleks001 commented 1 year ago

I had this same issue going from a 2.1.27xx version. In my case it was getting stuck on the upgrade step in the upgrade script: MODIFY COLUMN pw_len INT(5) NOT NULL DEFAULT 0

Inside the database I queried this column and had half the values as null and half as zero. So I simply updated all the values to zero as the modify column is trying to do and it fixed the error. Just run all of them manually and find out which one yours is bombing out on and fix the null values in it to what the modify column is trying to do. For you non sql people this was the query I ran:

update teampass_items set pw_len=0 where pw_len is null