Bug 31560 - koha-create fails with error pwgen invalid option -- 'r'
Summary: koha-create fails with error pwgen invalid option -- 'r'
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: 22.05
Hardware: All Linux
: P5 - low blocker
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-14 08:22 UTC by jesus
Modified: 2022-09-16 09:33 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jesus 2022-09-14 08:22:56 UTC
root@newkoha:~# koha-create --create-db gon
pwgen: invalid option -- 'r'
Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]

Options supported by pwgen:
  -c or --capitalize
	Include at least one capital letter in the password
  -A or --no-capitalize
	Don't include capital letters in the password
  -n or --numerals
	Include at least one number in the password
  -0 or --no-numerals
	Don't include numbers in the password
  -y or --symbols
	Include at least one special symbol in the password
  -s or --secure
	Generate completely random passwords
  -B or --ambiguous
	Don't include ambiguous characters in the password
  -h or --help
	Print a help message
  -H or --sha1=path/to/file[#seed]
	Use sha1 hash of given file as a (not so) random generator
  -C
	Print the generated passwords in columns
  -1
	Don't print the generated passwords in columns
  -v or --no-vowels
	Do not use any vowels so as to avoid accidental nasty words

root@newkoha:~# apt list --installed | grep pwgen

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

pwgen/oldoldstable,now 2.07-1.1+b1 amd64 [installed,automatic]
root@newkoha:~# apt list --installed | grep koha

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

koha-common/stable,now 22.05.04-1 all [installed]
Comment 1 Marcel de Rooy 2022-09-14 12:43:52 UTC
Tested under Debian 11
mysqlpwd=$(pwgen -s -y -r ":'&\\<>/" 16 1); echo $mysqlpwd
@q-rMH4xPF8XXmxx

Tested under Debian 10
root@shadow:/usr/share/koha# mysqlpwd=$(pwgen -s -y -r ":'&\\<>/" 16 1); echo $mysqlpwd
`=EYqf_TWTu8x"yx
root@shadow:/usr/share/koha# mysqlpwd=$(pwgen -s -y -r ":'&\\<>/" 16 1); echo $mysqlpwd
vi4O!M8FIzY6n%yU

So it works for me. Just noticing a few characters in the first D10 password that could be excluded also.

D10
apt list --installed | grep pwgen
pwgen/now 2.08-1 amd64 [installed,local]

D11
pwgen/now 2.08-2 amd64 [installed,local]

Your pwgen version is lower. You did not specify the distro you are working with. Maybe an idea to switch to Debian 11?
Comment 2 jesus 2022-09-14 15:04:28 UTC
I can confirm this not working on Debian 9:

root@newkoha:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.13 (stretch)
Release:	9.13
Codename:	stretch
root@newkoha:~# mysqlpwd=$(pwgen -s -y -r ":'&\\<>/" 16 1); echo $mysqlpwd
pwgen: invalid option -- 'r'
Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]

Options supported by pwgen:
  -c or --capitalize
	Include at least one capital letter in the password
  -A or --no-capitalize
	Don't include capital letters in the password
  -n or --numerals
	Include at least one number in the password
  -0 or --no-numerals
	Don't include numbers in the password
  -y or --symbols
	Include at least one special symbol in the password
  -s or --secure
	Generate completely random passwords
  -B or --ambiguous
	Don't include ambiguous characters in the password
  -h or --help
	Print a help message
  -H or --sha1=path/to/file[#seed]
	Use sha1 hash of given file as a (not so) random generator
  -C
	Print the generated passwords in columns
  -1
	Don't print the generated passwords in columns
  -v or --no-vowels
	Do not use any vowels so as to avoid accidental nasty words

root@newkoha:~#
Comment 3 jesus 2022-09-14 15:38:21 UTC
Indeed, upgrading to Debian 11 fixed the problem:

root@newkoha:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@newkoha:~# mysqlpwd=$(pwgen -s -y -r ":'&\\<>/" 16 1); echo $mysqlpwd
r2@~q`SO@F8$28DD
root@newkoha:~# koha-create --create-db gongora
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:en",
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
Koha instance is empty, no staff user created.
Starting Koha worker daemon for gongora (default):.
Starting Koha indexing daemon for gongora:.

root@newkoha:~#
Comment 4 Marcel de Rooy 2022-09-15 05:33:39 UTC
Ping Tomas and Mason.

Officially according to 
https://wiki.koha-community.org/wiki/System_requirements_and_recommendations
which is linked from the 22.05 release notes, we still support Debian 9:

Koha is continuously tested against the following configurations and as such these are the recommendations for deployment:
Operating system:
Debian 11
Debian 10
Debian 9
[etc]

Although this problem is resolved under D10 and D11, we should either update the wiki and advertize that change, or resolve this as a blocker?
Comment 5 Marcel de Rooy 2022-09-16 09:32:37 UTC
The wiki has been updated by Mason. We should still announce that.
This bug can be closed.