[MDEV-9321] Client plugin dir not automatically determined Created: 2015-12-24 Updated: 2022-01-07 Resolved: 2022-01-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladislav Vaintroub | Assignee: | Sergei Golubchik |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
At least on Windows, server is always able to correctly determine correct client plugin dir, no matter if it is started from unpacked ZIP or in MSI. It finds mysql_home, as parent of the directory where mysqld.exe is located (using GetModuleFileName to get mysqld.exe's path), then it sets the plugin_dir as $mysql_home/lib/plugin. Clients do not have the same logic, so whenever I start
which needs client plugin, it dies with rather unspecific message , like below
Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR It is a little awkward to start mysql.exe with "--plugin-dir=C:\Program Files(x86)\MariaDB 10.1\lib\plugin", and whatever the path needs to be for the unpacked ZIP. Ideally, every client that can load plugins would implement the same logic as server, i.e resolving default path as _ ../${INSTALL_PLUGIN_DIR}_ relative to the location of the client binary. |
| Comments |
| Comment by Vladislav Vaintroub [ 2015-12-24 ] |
|
Assigning to Serg for now. Not sure where this resolve path logic should go, clients e.g mysql, client_plugin.cc, my.ini's or elsewhere. |
| Comment by Sergei Golubchik [ 2019-09-12 ] |
|
Attached the patch. Please, review and suggest how to test it. Note, that it's using GetFullPathName(argv[0]) now, not GetModuleFileName. Can be used for clients too, but this patch doesn't do it. |
| Comment by Vladislav Vaintroub [ 2020-03-25 ] |
|
Hi serg. This bug is about clients, not about the server. As far as I'm concerned, on Windows, the server is not broken, and GetFullPathName() worked reliably this far. argv[0], I'm not so sure about it, I'd prefer something that works without this extra info. On Linux you could use /proc to get current executable (hopefully), on Windows you can use GetModuleFileName(). Perhaps, you'd need something for BSD, that requires argv[[0] and what not, but less reliance on argv[0], the better. Why are environment variables looked up? I've never found any mentioning of them in the documentation. is it something that mysqld_safe is using, internally? But then again, mysqld_safe seems to start mysqld with the basedir parameter, so perhaps looking up basedir based on undocumented environment is not necessary? I'm not sure how to test it generally, once the bug is fixed. As for testing , I think the best is unpack bintar /ZIP , create user with authentication plugin (something that requires both client shared libraries) and execute some SELECT 'hello' as newly user, using command line client. maybe ed25519 can be used for this. I do not have a good proposal how to test that in MTR, unless we start to create executables and libraries such that the directory layout is similar to the installation |
| Comment by Sergei Golubchik [ 2020-04-02 ] |
|
But then it should be done in C/C, for all clients, shouldn't it? |
| Comment by Vladislav Vaintroub [ 2020-04-02 ] |
|
Hmm, not sure. Our clients, that are usually in "bin" directory under the installation root, could resolve the default plugins path as ../lib/plugin . For other clients , that may be using C/C indirectly, C/ODBC or C/Python and what not, perhaps it is not a good idea? |
| Comment by Sergei Golubchik [ 2020-04-03 ] |
|
client plugins are part of C/C. Any client linked with C/C might implicitly use them without even knowing. Looks like it's C/C job to be able to find its plugins as needed |
| Comment by Vladislav Vaintroub [ 2020-04-03 ] |
|
well, the bug is about being able to find plugin relative to current executable, because it is server's installer job to install our executables into bin and client plugins into lib/plugin. We can't do it right for any client, but for some we can. |
| Comment by Geoff Montee (Inactive) [ 2020-04-27 ] |
|
This problem does not just affect Windows. It also affects binary tarball installations on Linux. |
| Comment by Sergei Golubchik [ 2021-01-09 ] |
|
wlad,
|
| Comment by Vladislav Vaintroub [ 2021-01-09 ] |
|
It works for me for Windows for the server, anytime so I do not see any reason to fix what is not broken. If you like to fix it on Linux, on server, it is just fine, yet outside of the scope for this bug. I do not think Windows needs any fixing. |
| Comment by Sergei Golubchik [ 2022-01-07 ] |
|
I've downloaded a ZIP archive of MariaDB 10.6.5 for Windows, unzipped it (on desktop), started the server, installed auth_ed25519 plugin. Created a user that is authenticated via this plugin. After that no matter from where and how I invoked mysql.exe, I was always able to connect as long as the password was correct. Meaning mysql.exe was always able to find and load the client ed25519.dll plugin. |