Bugzilla – Attachment 84799 Details for
Bug 21976
koha-reset-passwd does not deal with password restrictions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21976: Make koha-reset-passwd respect restrictions
Bug-21976-Make-koha-reset-passwd-respect-restricti.patch (text/plain), 4.83 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-02-05 17:32:12 UTC
(
hide
)
Description:
Bug 21976: Make koha-reset-passwd respect restrictions
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-02-05 17:32:12 UTC
Size:
4.83 KB
patch
obsolete
>From f8381b6bec117f5a3608dd867f511161df782407 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Sat, 2 Feb 2019 09:49:44 +0000 >Subject: [PATCH] Bug 21976: Make koha-reset-passwd respect restrictions > >This patch makes the set_password.pl script default to respect the >restrictions, and adds a --skip_validation parameter to it. > >koha-reset-passwd is adapted so it also accepts this parameter. The >result is the default behaviour respects the restrictions, and they can >be skipped. > >To test: >- Try with and without the option switch >- Notice the randomly generated password is always strongest than what >we enforce. >- Sign off >--- > debian/docs/koha-reset-passwd.xml | 15 ++++++++++++-- > debian/scripts/koha-reset-passwd | 33 ++++++++++++++++++++++++++++--- > misc/admin/set_password.pl | 5 ++++- > 3 files changed, 47 insertions(+), 6 deletions(-) > >diff --git a/debian/docs/koha-reset-passwd.xml b/debian/docs/koha-reset-passwd.xml >index 5ded51d8ab..dc404b6e22 100644 >--- a/debian/docs/koha-reset-passwd.xml >+++ b/debian/docs/koha-reset-passwd.xml >@@ -23,14 +23,25 @@ > > <refsynopsisdiv> > <cmdsynopsis> >- <command>koha-reset-passwd</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> <arg choice="req" rep="norepeat">username</arg> >+ <command>koha-reset-passwd</command> [<arg rep="norepeat">--skip_validation</arg>]<arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> <arg choice="req" rep="norepeat">username</arg> > </cmdsynopsis> > </refsynopsisdiv> > > <refsect1><title>Description</title> > <para>Reset password for a user in a Koha instance.</para> > </refsect1> >- >+ >+ <refsect1><title>Options</title> >+ <variablelist> >+ <varlistentry> >+ <term><option>--skip_validation</option></term> >+ <listitem> >+ <para>If specified, no password enforcement policies will the applied.</para> >+ </listitem> >+ </varlistentry> >+ </variablelist> >+ </refsect1> >+ > <refsect1><title>See also</title> > <simplelist type="inline"> > <member><command>koha-dump-defaults(8)</command></member> >diff --git a/debian/scripts/koha-reset-passwd b/debian/scripts/koha-reset-passwd >index ac3c40673f..9bb46b0202 100755 >--- a/debian/scripts/koha-reset-passwd >+++ b/debian/scripts/koha-reset-passwd >@@ -34,7 +34,10 @@ usage() > cat <<EOF > Resets the password for the specified user on the Koha instance. > >-Usage: $scriptname instancename userid >+Usage: $scriptname [options] instancename userid >+Options: >+ --help | -h Display this help message >+ --skip_validation Skip the password enforcement policy > > Note: The generated password will be printed. > EOF >@@ -44,6 +47,7 @@ set_password() > { > local instancename=$1 > local userid=$2 >+ local skip_validation=$3 > local password=$(pwgen 12 1) > > # Optionally use alternative paths for a dev install >@@ -55,10 +59,15 @@ set_password() > KOHA_BINDIR=$KOHA_HOME/misc > fi > >+ SET_PASSWORD_OPTS="--userid $userid --password $password" >+ if [ "$skip_validation" = "yes" ]; then >+ SET_PASSWORD_OPTS="${SET_PASSWORD_OPTS} --skip_validation" >+ fi >+ > if sudo -u "$instancename-koha" -H \ > env PERL5LIB=$PERL5LIB \ > KOHA_CONF="/etc/koha/sites/$instancename/koha-conf.xml" \ >- $KOHA_BINDIR/admin/set_password.pl --userid $userid --password $password ; then >+ $KOHA_BINDIR/admin/set_password.pl ${SET_PASSWORD_OPTS} ; then > > echo "$userid $password" > return 0 >@@ -72,12 +81,30 @@ if [ $# -lt 2 ]; then > die "Wrong parameters" > fi > >+skip_validation="no" >+ >+while [ -n "$*" ]; do >+ case "$1" in >+ -h|--help) >+ usage ; exit 0 >+ ;; >+ --skip_validation) >+ skip_validation="yes" >+ ;; >+ *) >+ break >+ ;; >+ esac >+ >+ shift >+done >+ > instance="$1" > shift > > for userid in "$@" > do >- set_password $instance $userid >+ set_password $instance $userid $skip_validation > done > > exit 0 >diff --git a/misc/admin/set_password.pl b/misc/admin/set_password.pl >index 8ae1444bd9..ed66498cf3 100755 >--- a/misc/admin/set_password.pl >+++ b/misc/admin/set_password.pl >@@ -24,12 +24,15 @@ use Pod::Usage; > use Koha::Patrons; > > my ( $help, $password, $cardnumber, $patron_id, $userid ); >+my $skip_validation = 0; >+ > GetOptions( > 'help|?' => \$help, > 'userid=s' => \$userid, > 'password=s' => \$password, > 'patron_id=s' => \$patron_id, > 'cardnumber=s' => \$cardnumber, >+ 'skip_validation' => \$skip_validation > ); > > pod2usage(1) if $help; >@@ -62,7 +65,7 @@ unless ( $patrons->count > 0 ) { > } > > my $patron = $patrons->next; >-$patron->set_password({ password => $password, skip_validation => 1 }); >+$patron->set_password({ password => $password, skip_validation => $skip_validation }); > > =head1 NAME > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21976
: 84799