Skip to content

Commit

Permalink
contrib: remove rpcpassword from init scripts
Browse files Browse the repository at this point in the history
Init scripts will now warn, but not exit, if deprecated rpcuser or
rpcpassword keys are found.
  • Loading branch information
willcl-ark committed Jan 16, 2024
1 parent 2350eaf commit 6db8aa6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
25 changes: 9 additions & 16 deletions contrib/init/bitcoind.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@ pre-start script
# long after forking, leaving upstart to think everything started fine.
# since this is a commonly encountered case on install, just check and
# warn here.
if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then
echo "ERROR: You must set a secure rpcpassword to run bitcoind."
echo "The setting must appear in $BITCOIND_CONFIGFILE"
echo
echo "This password is security critical to securing wallets "
echo "and must not be the same as the rpcuser setting."
echo "You can generate a suitable random password using the following "
echo "command from the shell:"
echo
echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
echo
echo "It is recommended that you also set alertnotify so you are "
echo "notified of problems:"

# check for deprecated rpcuser and rpcpassword settings
if grep -qs '^rpcuser=' "$BITCOIND_CONFIGFILE" || grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE"; then
echo "WARNING: The `rpcuser` and `rpcpassword` options are now deprecated and should be removed from the configuration file."
echo "Use cookie file or the `rpcauth` configuration setting for RPC authentication."
echo "See share/rpcauth/README.md for more information on `rpcauth`."
echo "The presence of `rpcuser` or `rpcpassword` in $BITCOIND_CONFIGFILE will in a future version cause bitcoind to fail startup."
echo
echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
"[email protected]"
echo "It is recommended that you also set alertnotify so you are notified of problems:"
echo
exit 1
echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\" [email protected]"
fi

mkdir -p "$BITCOIND_PIDDIR"
Expand Down
31 changes: 11 additions & 20 deletions contrib/init/bitcoind.openrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/sbin/openrc-run

# backward compatibility for existing gentoo layout
# backward compatibility for existing gentoo layout
#
if [ -d "/var/lib/bitcoin/.bitcoin" ]; then
BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"
Expand Down Expand Up @@ -69,25 +69,16 @@ start_pre() {

checkconfig()
{
if grep -qs '^rpcuser=' "${BITCOIND_CONFIGFILE}" && \
! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
# check for deprecated rpcuser and rpcpassword settings
if grep -qs '^rpcuser=' "$BITCOIND_CONFIGFILE" || grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE"; then
eerror "WARNING: The `rpcuser` and `rpcpassword` options are now deprecated and should be removed from the configuration file."
eerror "Use cookie file or the `rpcauth` configuration setting for RPC authentication."
eerror "See share/rpcauth/README.md for more information on `rpcauth`."
eerror "The presence of `rpcuser` or `rpcpassword` in $BITCOIND_CONFIGFILE will in a future version cause bitcoind to fail startup."
eerror ""
eerror "It is recommended that you also set alertnotify so you are notified of problems:"
eerror ""
eerror "ERROR: You must set a secure rpcpassword to run bitcoind."
eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"
eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\" [email protected]"
eerror ""
eerror "This password is security critical to securing wallets "
eerror "and must not be the same as the rpcuser setting."
eerror "You can generate a suitable random password using the following "
eerror "command from the shell:"
eerror ""
eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
eerror ""
eerror "It is recommended that you also set alertnotify so you are "
eerror "notified of problems:"
eerror ""
eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
"[email protected]"
eerror ""
return 1
fi
fi
}

0 comments on commit 6db8aa6

Please sign in to comment.