Skip to content

plugins: add functionality to allow setting plugin pubkey from gui #9765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

f321x
Copy link
Member

@f321x f321x commented Apr 28, 2025

Adds functionality that allows the user to store the plugin authorization pubkey without having to edit files/registry manually. On Linux systems it spawns the commands in a subprocess with polkits pkexec which will trigger an OS prompt to execute the commands as root. The user sees the executed commands and can either authorize with the root password or decline.
On windows it uses the windows ShellExecuteExW api execute reg.exe with elevated permissions to edit the registry, this also triggers an OS dialog the user can accept or decline (UAC dialog).
There is also functionality to reset the key again, which works in the same way.
I tested this from source on both plattforms and as AppImage and Windows installer.

This won't work on MacOS (no pkexec), would need access to a Mac to implement a similar solution.

The windows OS prompt:

Screenshot_20250428_145953

The Linux (KDE) prompt:

Screenshot_20250428_160719

@f321x f321x force-pushed the plugin_pubk_user_prompt branch 2 times, most recently from 1b7edb9 to a5c91fd Compare April 28, 2025 14:57
Adds functionality that allows the user to store the plugin authorization pubkey without having to edit files/registry manually.
On Linux systems it spawns the commands in a subprocess with pkexec which will trigger a OS prompt to execute the commands as root.
The user sees the executed commands and can either authorize with the root password or decline.
On windows it uses the windows `ShellExecuteExW` api to edit the registry, this also triggers a OS dialog to accept or decline (UAC dialog).
There is also functionality to reset the key again, which works in the same way.
@f321x f321x force-pushed the plugin_pubk_user_prompt branch from a5c91fd to 08927bb Compare May 5, 2025 07:38
"""
from winreg import ConnectRegistry, OpenKey, QueryValue, HKEY_LOCAL_MACHINE

key_path = r'HKEY_LOCAL_MACHINE\SOFTWARE\Electrum\PluginsKey'
Copy link
Member

Choose a reason for hiding this comment

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

can this be deduped somehow with self.keyfile_windows?

auto_setup_btn = QPushButton(_('Try Auto-Setup'))
def on_auto_setup_clicked():
if not self.plugins.try_auto_key_setup(key_hex):
self.show_error(_("Auto-Setup not possible. Try the manual setup."))
Copy link
Member

Choose a reason for hiding this comment

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

ideally we should still show the manual setup instructions if this happens, but the popup gets closed

Copy link
Member

Choose a reason for hiding this comment

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

(btw at the same time, we should probably improve the manual instructions, e.g. for Linux, write copy-pasteable and readable commands, such as:
$ sudo sh -c 'echo "015d0f863d213e7bd4549ec45d1155d43268b7dd5387728936e5a937346d53b3fe02f8495dabc5111401d7a5b897ccb11c34f3dc6b51afeff637d55efe61aa75edf3" > /etc/electrum/plugins_key'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants