When deploying an app during autodeploy (first start of the db with *.xar at ./autodeploy) the usage of sm:passwd#2 in pre-install.xql or post-install.xql throws an error and stops execution of the script.
The usage of sm:passwd#2 should work as expected during autodeploy.
git clone [email protected]:eXist-db/exist.git /tmp/eXist-test
cd /tmp/eXist-test
git checkout eXist-3.5.0
# but it fails on recent as well, i guess
./build.sh
unzip autodeploy/dashboard-0.4.7.xar pre-install.xql
# will cancel the pre-install script and stop the deployment
echo ', sm:passwd("admin", "somepass")' >> pre-install.xql
zip autodeploy/dashboard-0.4.7.xar pre-install.xql
# just a little clean up here:
rm pre-install.xql
./bin/startup.sh
If you like to try it on a post-install script (the app will be deployed) you can modify the monex application like this:
# wipe the data at first
rm -rf webapp/WEB-INF/{data/*,logs/*.log}
unzip autodeploy/monex-0.9.10.xar post-install.xql
# insert on line 10, everything below will not be executed
sed -i '10i\let $test := sm:passwd("admin", "somepass")' post-install.xql
zip autodeploy/monex-0.9.10.xar post-install.xql
rm post-install.xql
./bin/startup.sh
So the trick is to set sm:passwd#2 as last function call in post-install.xql, so the app will be deployed, the password will be set, but the error is still reported in the logfile expath-repo.log:
at org.exist.security.internal.SecurityManagerImpl.updateAccount(SecurityManagerImpl.java:239) ~[exist.jar:3.5.0]
Please can you share the file post-install.xql ? The text is interesting but zipping/unzipping is not really the issue right? Does the error occur when deploying the XAR file when the database is already running?
isn't your question in essence: how can I setup the admin password before the database is running? Please rephrase your question and provide the ready-to-go xq files.
unzipping here is just for reproducing this error.
i propose to use any post-install.xq or pre-install.xq. it doesnt matter, you just have to include a line like stated in the test.
my question is not about how to do it, but why i can not do it in this way. why sm:passwd throws an error when used during autodeploy?
but does it throw an error when deploying it via the package manager?
No.
This bug is still valid for eXist 4.3.1 and 5.0.0 RC (see https://sourceforge.net/p/exist/mailman/message/36399501/ ).
A simplified xar that demonstrates the failure is at https://github.com/EfraimFeinstein/exist-issue-1610
Most helpful comment
This bug is still valid for eXist 4.3.1 and 5.0.0 RC (see https://sourceforge.net/p/exist/mailman/message/36399501/ ).
A simplified xar that demonstrates the failure is at https://github.com/EfraimFeinstein/exist-issue-1610