Skip to content

Instantly share code, notes, and snippets.

@line-o
Last active November 8, 2018 04:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save line-o/0aa2901efd535a931a784180d15cb0f8 to your computer and use it in GitHub Desktop.
Save line-o/0aa2901efd535a931a784180d15cb0f8 to your computer and use it in GitHub Desktop.
Rough sketch of a password reset for eXist-db
xquery version '3.1';
(:~
this script must be run with a user in the DBA group
add this line to your post-install script or run it manually
it will set the GID sticky bit
chown('/path/to/this/script.xq', 'admin', 'dba')
chmod('/path/to/this/script.xq', 'rwxr-S---')
:)
(:~
do some checks on the password
:)
declare function local:pass-ok($password) {
string-length($password) > 11
};
declare variable $local:user := request:get-parameter('user', '')
declare variable $local:pass := request:get-parameter('pass', '')
(: check if user exists and new password is good :)
if (
sm:user-exists($local:user) and
local:pass-ok($local:pass)
)
then (sm:passwd($local:user, $local:pass))
else ('ERROR')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment