Bug 25538

Summary: koha-shell should pass --login to sudo if no command
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Command-line UtilitiesAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: major    
Priority: P5 - low CC: aleisha, lucas, martin.renvoize, robin, tomascohen, victor
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.01, 19.11.07, 19.05.12
Bug Depends on: 24458    
Bug Blocks: 25551, 25752, 26031    
Attachments: Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty
Bug 25538: Use sudo -i in koha-shell
Bug 25538: Default to --login|-i if no command passed
Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty
Bug 25538: Use sudo -i in koha-shell
Bug 25538: Default to --login|-i if no command passed
Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty
Bug 25538: Use sudo -i in koha-shell
Bug 25538: Default to --login|-i if no command passed

Description Jonathan Druart 2020-05-19 09:22:35 UTC
This is a new failure, we got it twice in the last couple of days:

Master_D8 #870 and Master_U18 #790, the output is (quite verbose):

14:12:44 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 259.
14:12:44 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:12:44 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: deuteros'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: deuteros'  2 result(s) found for 'kw,wrdl: deuteros'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopicsGardeningΚηπουρική学協会. μμ'
14:12:44 koha_1       | #     doesn't match '(?^u:Publisher: Αθήνα)'
14:12:44 koha_1       | 
14:12:44 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 268.
14:12:44 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:12:44 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: Αθήνα'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: Αθήνα'  2 result(s) found for 'kw,wrdl: Αθήνα'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopicsGardeningΚηπουρική学協会. μμ'
14:12:44 koha_1       | #     doesn't match '(?^u:Publisher: Αθήνα)'
14:12:45 koha_1       | 
14:12:45 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 282.
14:12:45 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:12:45 koha_1       | #                   'Koha online catalog › Results of search for 'deuteros'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for 'deuteros'Refine your searchAvailabilityLimit to currently available items.TopicsGardeningΚηπουρική学協会. μμYour search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:12:45 koha_1       | #     doesn't match '(?^u:Publisher: Αθήνα)'
14:12:46 koha_1       | 
14:12:46 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 291.
14:12:46 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:12:46 koha_1       | #                   'Koha online catalog › Results of search for 'Αθήνα'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for 'Αθήνα'Refine your searchAvailabilityLimit to currently available items.TopicsGardeningΚηπουρική学協会. μμYour search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:12:46 koha_1       | #     doesn't match '(?^u:Publisher: Αθήνα)'
14:13:29 koha_1       | 
14:13:29 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 259.
14:13:29 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:13:29 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: Tòmas'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: Tòmas'  2 result(s) found for 'kw,wrdl: Tòmas'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopicsThomas Aquinas, s.AuthorsTòmas, Giovanni Feli...'
14:13:29 koha_1       | #     doesn't match '(?^u:Publisher: Ramòn)'
14:13:30 koha_1       | 
14:13:30 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 268.
14:13:30 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:13:30 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: Ramòn'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: Ramòn'  2 result(s) found for 'kw,wrdl: Ramòn'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopicsThomas Aquinas, s.AuthorsTòmas, Giovanni Feli...'
14:13:30 koha_1       | #     doesn't match '(?^u:Publisher: Ramòn)'
14:13:30 koha_1       | 
14:13:30 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 282.
14:13:30 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:13:30 koha_1       | #                   'Koha online catalog › Results of search for 'Tòmas'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for 'Tòmas'Refine your searchAvailabilityLimit to currently available items.AuthorsTòmas, Giovanni Feli...TopicsThomas Aquinas, s.Your search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:13:30 koha_1       | #     doesn't match '(?^u:Publisher: Ramòn)'
14:13:31 koha_1       | 
14:13:31 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 291.
14:13:31 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:13:31 koha_1       | #                   'Koha online catalog › Results of search for 'Ramòn'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for 'Ramòn'Refine your searchAvailabilityLimit to currently available items.AuthorsTòmas, Giovanni Feli...TopicsThomas Aquinas, s.Your search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:13:31 koha_1       | #     doesn't match '(?^u:Publisher: Ramòn)'
14:14:13 koha_1       | 
14:14:13 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 259.
14:14:13 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:14:13 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: A tiny record'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: A tiny record'  2 result(s) found for 'kw,wrdl: A tiny record'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopics😀'
14:14:13 koha_1       | #     doesn't match '(?^u:Publisher: 𠻺tomasito𠻺)'
14:14:14 koha_1       | 
14:14:14 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 268.
14:14:14 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:14:14 koha_1       | #                   'Koha › Catalog › Results of search for 'kw,wrdl: 𠻺tomasito𠻺'  Menu CirculationPatronsSearchAdvanced searchItem searchCartMore ListsCatalogingAcquisitionsAuthoritiesSerialsCourse reservesReportsToolsAdministrationAbout Koha     koha |  Centerville CPL     Logged in as:koha Location: Centerville CPLSet libraryMy accountMy checkoutsLog out HelpYour cart is empty.Enter patron card number or partial name: Scan a barcode to check in: Scan a barcode to renew: Enter search keywords: Check outCheck inRenewSearch the catalogHome › Catalog › Search for 'kw,wrdl: 𠻺tomasito𠻺'  2 result(s) found for 'kw,wrdl: 𠻺tomasito𠻺'.  Select all |  Clear all | Unhighlight Highlight |  Add to cart Add to list New list Place hold Z39.50/SRU search Edit Batch editBatch deleteMerge records Sort RelevancePopularityPopularity (most to least)Popularity (least to most)AuthorAuthor (A-Z)Author (Z-A)Call numberCall number (0-9 to A-Z)Call number (Z-A to 9-0)DatesPublication/Copyright date: newest to oldestPublication/Copyright date: oldest to newestAcquisition date: newest to oldestAcquisition date: oldest to newestTitleTitle (A-Z)Title (Z-A) ResultsLocation 1. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items 2. Material type:  Text No holds allowed | Add to cart (remove) | Edit record | Edit items  | OPAC view No items   Refine your searchAvailabilityLimit to currently available itemsTopics😀'
14:14:14 koha_1       | #     doesn't match '(?^u:Publisher: 𠻺tomasito𠻺)'
14:14:15 koha_1       | 
14:14:15 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 282.
14:14:15 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:14:15 koha_1       | #                   'Koha online catalog › Results of search for 'A tiny record'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for 'A tiny record'Refine your searchAvailabilityLimit to currently available items.Topics😀Your search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:14:15 koha_1       | #     doesn't match '(?^u:Publisher: 𠻺tomasito𠻺)'
14:14:15 koha_1       | 
14:14:15 koha_1       | #   Failed test at t/db_dependent/www/search_utf8.t line 291.
14:14:15 koha_1       | Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105.
14:14:15 koha_1       | #                   'Koha online catalog › Results of search for '𠻺tomasito𠻺'  Koha online Your cart is empty.  Cart   Lists Your listsNo private listsNew list  Welcome, koha  Your accountSearch history   Clear Log out Search Library catalogTitleAuthorSubjectISBNISSNSeriesCall numberGoAdvanced searchCourse reservesAuthority searchTag cloud Libraries ×Log in to your accountLogin:Password:Forgot your password?Don't have an account? Register here.Home ›Results of search for '𠻺tomasito𠻺'Refine your searchAvailabilityLimit to currently available items.Topics😀Your search returned 2 results.    RelevancePopularity (most to least)Popularity (least to most)Author (A-Z)Author (Z-A)Call number (0-9 to A-Z)Call number (Z-A to 9-0)Publication/Copyright date: Newest to oldestPublication/Copyright date: Oldest to newestAcquisition date: Newest to oldestAcquisition date: Oldest to newestTitle (A-Z)Title (Z-A)  Unhighlight  Highlight|    |     1.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) 2.  Material type:  Text Availability: No items available :      Save to lists  Add to cart (remove) Not finding what you're looking for? Make a purchase suggestionPowered by Koha'
14:14:15 koha_1       | #     doesn't match '(?^u:Publisher: 𠻺tomasito𠻺)'
14:14:22 koha_1       | # Looks like you failed 12 tests of 99.
14:14:22 koha_1       | [12:14:22] t/db_dependent/www/search_utf8.t ........................................
Comment 1 Jonathan Druart 2020-05-19 09:22:58 UTC
Maybe caused by bug 24458 (?)
Comment 2 Jonathan Druart 2020-05-22 14:58:59 UTC
Again on Master_D9_MDB_Latest #303
Comment 3 Tomás Cohen Arazi 2020-06-06 00:34:13 UTC
You need to make sure the used fw has the checked girls set to display in the relevant interface.
Comment 4 Jonathan Druart 2020-06-08 09:41:23 UTC
(In reply to Tomás Cohen Arazi from comment #3)
> You need to make sure the used fw has the checked girls set to display in
> the relevant interface.

Why would that make it fail randomly?
Comment 5 Jonathan Druart 2020-06-10 08:49:30 UTC
This is because KOHA_OPAC_URL is not set.
On both U18 and D11 I get the following (known error that should not have been ignored so long):

root@c4adf9b9b785:koha(master|BISECTING)$ kshell
bash: /root/.bashrc: Permission denied


This can be recreated easily by defining a wrong KOHA_OPAC_URL.

 $ koha-shell ${KOHA_INSTANCE} -p -c "echo $KOHA_OPAC_URL"
Comment 6 Jonathan Druart 2020-06-10 08:50:27 UTC
Created attachment 105675 [details] [review]
Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty
Comment 7 Jonathan Druart 2020-06-10 08:55:02 UTC
koha-testing-docker related issue: https://gitlab.com/koha-community/koha-testing-docker/-/issues/202
Comment 8 Jonathan Druart 2020-06-10 09:20:18 UTC
Created attachment 105676 [details] [review]
Bug 25538: Use sudo -i in koha-shell

See man sudo, -i parameter.
Should we expect regressions?

Test plan:
0. Use D11 or U18.
Don't apply this patch
1.
$ echo $KOHA_INTRANET_URL
$ sudo koha-shell kohadev
$ echo $KOHA_INTRANET_URL
2. Apply this patch
$ cp debian/scripts/koha-shell /usr/sbin/koha-shell
3. Repeat 1.
Comment 9 Jonathan Druart 2020-06-10 11:22:00 UTC
Created attachment 105685 [details] [review]
Bug 25538: Default to --login|-i if no command passed
Comment 10 Martin Renvoize 2020-06-10 11:49:40 UTC
Created attachment 105686 [details] [review]
Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2020-06-10 11:49:43 UTC
Created attachment 105687 [details] [review]
Bug 25538: Use sudo -i in koha-shell

See man sudo, -i parameter.
Should we expect regressions?

Test plan:
0. Use D11 or U18.
Don't apply this patch
1.
$ echo $KOHA_INTRANET_URL
$ sudo koha-shell kohadev
$ echo $KOHA_INTRANET_URL
2. Apply this patch
$ cp debian/scripts/koha-shell /usr/sbin/koha-shell
3. Repeat 1.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2020-06-10 11:49:46 UTC
Created attachment 105688 [details] [review]
Bug 25538: Default to --login|-i if no command passed

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize 2020-06-10 11:50:54 UTC
Looks good to me and works as expected when running in koha-testing-docker interactively.

Signing off
Comment 14 Tomás Cohen Arazi 2020-06-10 15:46:32 UTC
I tried it on an Ubuntu 18.04 KTD (19.11-bionic) and it doesn't seem to fix the issue, and it also feels like it is choosing a different shell:

root@744612f9fc98:kohadevbox$ export KOHA_INTRANET_URL=hola
root@744612f9fc98:kohadevbox$ echo $KOHA_INTRANET_URL
hola
root@744612f9fc98:kohadevbox$ koha/debian/scripts/koha-shell kohadev
$ echo $KOHA_INTRANET_URL

$

Will try on different images.
Comment 15 Jonathan Druart 2020-06-11 08:33:02 UTC
$KOHA_INTRANET_URL is not supposed to be the one coming from the shell you had before (does it?). It is defined in the .bashrc of the kohadev-koha

$ grep KOHA_INTRANET_URL /var/lib/koha/kohadev/.bashrc                                                                                                                    
export KOHA_INTRANET_URL=http://koha:8081
Comment 16 Jonathan Druart 2020-06-11 08:41:46 UTC
I think the env vars must be kept if --preserve-env is passed.
But in that case we should do the test in the bashrc (if vars exist, don't reset them with the default values).

Also I guess the following lines should be removed (var must be defined in bashrc?)
 51     "env "
 52   . "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml "
 53   . "PERL5LIB=$perl5lib

But we are going to far, the whole script needs its own bug report (if the above is correct).
Comment 17 Tomás Cohen Arazi 2020-06-11 14:41:55 UTC
(In reply to Jonathan Druart from comment #16)
> I think the env vars must be kept if --preserve-env is passed.
> But in that case we should do the test in the bashrc (if vars exist, don't
> reset them with the default values).
> 
> Also I guess the following lines should be removed (var must be defined in
> bashrc?)
>  51     "env "
>  52   . "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml "
>  53   . "PERL5LIB=$perl5lib
> 
> But we are going to far, the whole script needs its own bug report (if the
> above is correct).

It smells like this is a problem in KTD, the run.sh script should be doing things in a different way. We passed things like KOHA_INTRANET_URL to the koha-shell because the different default shells pick or not the variables depending on which is being used.
Comment 18 Tomás Cohen Arazi 2020-06-11 14:48:00 UTC
Created attachment 105763 [details] [review]
Bug 25538: Don't run search_utf8.t if KOHA_*_URL empty

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 19 Tomás Cohen Arazi 2020-06-11 14:48:05 UTC
Created attachment 105764 [details] [review]
Bug 25538: Use sudo -i in koha-shell

See man sudo, -i parameter.
Should we expect regressions?

Test plan:
0. Use D11 or U18.
Don't apply this patch
1.
$ echo $KOHA_INTRANET_URL
$ sudo koha-shell kohadev
$ echo $KOHA_INTRANET_URL
2. Apply this patch
$ cp debian/scripts/koha-shell /usr/sbin/koha-shell
3. Repeat 1.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 20 Tomás Cohen Arazi 2020-06-11 14:48:09 UTC
Created attachment 105765 [details] [review]
Bug 25538: Default to --login|-i if no command passed

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 21 Tomás Cohen Arazi 2020-06-11 14:49:00 UTC
It all makes sense now that I've spent enough time trying myself to fix.
Comment 22 Jonathan Druart 2020-06-11 16:01:20 UTC
root@3c7b0504a2a3:koha(master|BISECTING)$ cp debian/scripts/koha-shell /usr/sbin/koha-shell                                                                                                                       
root@3c7b0504a2a3:koha(master|BISECTING)$ kshell                                                                                                                                                                  
bash: /root/.bashrc: Permission denied                                                                                                                                                                            
kohadev-koha@3c7b0504a2a3:/kohadevbox/koha$ pwd                                                                                                                                                                   
/kohadevbox/koha                                                                                                                                                                                                  
kohadev-koha@3c7b0504a2a3:/kohadevbox/koha$ exit     

# Switching to branch bug_25538
                                                                                                                                                             
root@3c7b0504a2a3:koha(master|BISECTING)$ cp debian/scripts/koha-shell /usr/sbin/koha-shell                                                                                                                       
root@3c7b0504a2a3:koha(master|BISECTING)$ kshell                                                                                                                                                                  
kohadev-koha@3c7b0504a2a3:~$ pwd                                                                                                                                                                                  
/var/lib/koha/kohadev             

Isn't this actually a problem?
Comment 23 Jonathan Druart 2020-06-11 16:03:37 UTC
root@3c7b0504a2a3:koha(master|BISECTING)$ koha-shell kohadev -p -c "prove t/DateUtils.t"                                                                                                                          
t/DateUtils.t .. ok                                                                                                                                                                                               
All tests successful.                                                                                                                                                                                             
Files=1, Tests=79,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.49 cusr  0.03 csys =  0.55 CPU)                                                                                                                    
Result: PASS

So I should not break the tests launched by ktd.
Comment 24 Jonathan Druart 2020-06-11 16:07:02 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 25 Lucas Gass 2020-06-16 22:05:12 UTC
backported to 20.05.x for 20.05.01
Comment 26 Aleisha Amohia 2020-06-16 23:24:49 UTC
backported to 19.11.x for 19.11.07
Comment 27 Victor Grousset/tuxayo 2020-06-17 22:14:41 UTC
Backported to 19.05.x branch for 19.05.12
Comment 28 Jonathan Druart 2020-06-18 15:13:10 UTC
Still the same failure on 20.05_U18/11 (note that selenium/authentication.t is failing as well)

Please report here when it happens.
Comment 29 Jonathan Druart 2020-06-25 08:38:16 UTC
19.11_U18 #190
Comment 30 Victor Grousset/tuxayo 2020-07-02 22:09:15 UTC
> Please report here when it happens.

https://jenkins.koha-community.org/view/19.05/job/Koha_19.05_D9/246/consoleText
Comment 32 Jonathan Druart 2020-07-21 08:41:40 UTC
I moved the original issue to bug 26031.