Skip to content

Postinst: do not ask for password if it was already specified#12413

Closed
alexey-milovidov wants to merge 7 commits intomasterfrom
postinst-dont-ask-for-password-if-already-have
Closed

Postinst: do not ask for password if it was already specified#12413
alexey-milovidov wants to merge 7 commits intomasterfrom
postinst-dont-ask-for-password-if-already-have

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Do not ask for password for default user during installation of debian package if the password was already specified in condiguration but this fact was not saved earlier inside debian tools. This closes #8316.

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Jul 10, 2020
chmod 600 ${CLICKHOUSE_CONFDIR}/users.d/default-password.xml
fi
# Ask for password for default user. But only if it was not specified in configuration.
if [ -z "$($(su -s $SHELL ${CLICKHOUSE_USER} -c "$CLICKHOUSE_BINDIR/$EXTRACT_FROM_CONFIG --config-file=\"$CLICKHOUSE_USERS\" --key=users.default.password" 2>/dev/null; su -s $SHELL ${CLICKHOUSE_USER} -c "$CLICKHOUSE_BINDIR/$EXTRACT_FROM_CONFIG --config-file=\"$CLICKHOUSE_USERS\" --key=users.default.password_sha256_hex" 2>/dev/null) ||: )" ]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this quite long line out of if clause and store both values in a separate variable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

The main concern is that I cannot add a test and have to test it manually just once before merging...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also Debian already remembers that the password was specified.
And the fix is only for corner case when the password already specified in config but clickhouse-server package was not installed before.

@alexey-milovidov
Copy link
Copy Markdown
Member Author

alexey-milovidov commented Jul 16, 2020

Unfortunately CI did not create a build for this PR
(the reason is clear and it's not an issue).

@alexey-milovidov
Copy link
Copy Markdown
Member Author

I will modify some unrelated file for this purpose...

@alexey-milovidov
Copy link
Copy Markdown
Member Author

Yandex synchronization check (only for Yandex employees) Pending — error, check will be restarted

This check is unreliable @exprmntr

@alexey-milovidov alexey-milovidov marked this pull request as draft July 17, 2020 14:01
@alexey-milovidov
Copy link
Copy Markdown
Member Author

This modification is practially untestable. The only way is to test manually... I have tested and it does not work.

@alexey-milovidov
Copy link
Copy Markdown
Member Author

Test 1:

Install debian package and check that it's asking for password.
It should not break with this PR.

Test 2:

Install ClickHouse without debian package (by any other means), set up default password either with plaintext or with sha256 (both options should be tested). Then install ClickHouse with debian package and check that it does not ask for password.

Test 3:

Install ClickHouse with debian package, do dpkg purge but save config file with password. Then install again and check that it does not ask for password.

@alexey-milovidov alexey-milovidov added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Aug 26, 2020
@robot-clickhouse robot-clickhouse added pr-bugfix Pull request with bugfix, not backported by default and removed pr-improvement Pull request with some product improvements labels Aug 26, 2020
@alexey-milovidov
Copy link
Copy Markdown
Member Author

I've changed "bugfix" to "improvement" so no one will dare to backport this insignificant mostly unneeded useless fix.

@alexey-milovidov alexey-milovidov added the minor Priority: minor label Aug 26, 2020
@akuzm
Copy link
Copy Markdown
Contributor

akuzm commented Aug 26, 2020

I've changed "bugfix" to "improvement" so no one will dare to backport this insignificant mostly unneeded useless fix.

The bots fight you again... better use pr-no-backport.

@alexey-milovidov
Copy link
Copy Markdown
Member Author

debconf does not follow script execution. Instead it parses the script and tries to ask for configuration for all options listed inside:

root@4b0efbc31f64:/packages# ar x clickhouse-server_20.8.1.4478_all.deb 
root@4b0efbc31f64:/packages# bash -x ./postinst 
+ set -e
+ CLICKHOUSE_USER=clickhouse
+ CLICKHOUSE_GROUP=clickhouse
+ CLICKHOUSE_CONFDIR=/etc/clickhouse-server
+ CLICKHOUSE_DATADIR=/var/lib/clickhouse
+ CLICKHOUSE_LOGDIR=/var/log/clickhouse-server
+ CLICKHOUSE_BINDIR=/usr/bin
+ CLICKHOUSE_GENERIC_PROGRAM=clickhouse
+ EXTRACT_FROM_CONFIG=clickhouse-extract-from-config
+ CLICKHOUSE_CONFIG=/etc/clickhouse-server/config.xml
+ CLICKHOUSE_USERS=/etc/clickhouse-server/users.xml
+ '[' -f /usr/share/debconf/confmodule ']'
+ . /usr/share/debconf/confmodule
++ '[' '!' '' ']'
++ PERL_DL_NONLAZY=1
++ export PERL_DL_NONLAZY
++ '[' '' ']'
++ exec /usr/share/debconf/frontend ./postinst
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Enter password for default user:

@alexey-milovidov
Copy link
Copy Markdown
Member Author

Note: These questions are asked by a separate config script, not by the postinst, so the package can be configured before it is installed, or reconfigured after it is installed. Do not make your postinst use debconf to ask questions.

http://www.fifi.org/doc/debconf-doc/tutorial.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Priority: minor pr-bugfix Pull request with bugfix, not backported by default pr-no-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflicting user configuration files created during update

4 participants