[Bug 44244] New: koha-shell -c breaks on single quotes in the command, sometimes silently
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44244 Bug ID: 44244 Summary: koha-shell -c breaks on single quotes in the command, sometimes silently Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Command-line Utilities Assignee: koha-bugs@lists.koha-community.org Reporter: babarjunaid1122@gmail.com QA Contact: testopia@bugs.koha-community.org CC: jake.deery@openfifth.co.uk, robin@catalyst.net.nz Target Milestone: --- koha-shell builds one string, ... -c '<command>', and runs it through a shell. A single quote inside the command ends the wrapper's quoting: sudo koha-shell -c "echo 'Supplier load, August'" kohadev Supplier sudo koha-shell -c "perl -e 'print(1)'" kohadev sh: 1: Syntax error: "(" unexpected The first case is silent: with stage_file.pl, --comment 'Supplier load, August' arrives as --comment Supplier and the batch is staged with the wrong comment. Single quotes are the normal way to quote an argument, so anyone following a guide that wraps a command in koha-shell -c "..." can hit it. Reproduced on main (c8e8025) in KTD and on a Koha 26.05.05 package install. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44244 --- Comment #1 from babar junaid <babarjunaid1122@gmail.com> --- Created attachment 212474 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212474&action=edit Bug 44244: Do not let koha-shell -c break on quotes in the command Bug 44244: Do not let koha-shell -c break on quotes in the command koha-shell built one string, ... -c '<command>', and ran it through a shell, so a single quote in the command ended the wrapper's quoting: koha-shell -c "echo 'Supplier load, August'" kohadev -> Supplier koha-shell -c "perl -e 'print(1)'" kohadev -> sh: 1: Syntax error: "(" unexpected The first is silently truncated: stage_file.pl --comment 'Supplier load, August' got --comment Supplier. The sudo command is now passed to system() as a list, so the command reaches the instance user's shell exactly as given. Test plan: 1. In KTD: sudo perl debian/scripts/koha-shell -c "echo 'Supplier load, August'" kohadev prints only "Supplier". sudo perl debian/scripts/koha-shell -c "perl -e 'print(qq{ok\n})'" kohadev sh: 1: Syntax error: "(" unexpected 2. Apply the patch, repeat 1: "Supplier load, August" and "ok". 3. Check nothing else changed: - koha-shell -c 'echo $KOHA_CONF; whoami' kohadev: the instance's koha-conf.xml and kohadev-koha - koha-shell -l -c 'echo $HOME; exit 3' kohadev; echo $?: the instance's home and 3 - koha-shell kohadev: an interactive shell as kohadev-koha in the current directory - koha-shell -v -c true kohadev prints the command Sponsored-by: Koha Solutions -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44244 babar junaid <babarjunaid1122@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |babarjunaid1122@gmail.com |ity.org | Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org