Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-9321

Client plugin dir not automatically determined

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Cannot Reproduce
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • N/A
    • Scripts & Clients
    • None

    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

      mysql -usome_user 
      

      which needs client plugin, it dies with rather unspecific message , like below

      C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
      ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
      

      Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
      C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

      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.

      Attachments

        Activity

          wlad Vladislav Vaintroub created issue -

          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.
          Also there might be equivalents on systems other than Windows to determine the path of currently running process (proc flle system on Linux for example)

          wlad Vladislav Vaintroub added a comment - 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. Also there might be equivalents on systems other than Windows to determine the path of currently running process (proc flle system on Linux for example)
          wlad Vladislav Vaintroub made changes -
          Field Original Value New Value
          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

          mysql -usome_user

          which needs client plugin, it dies with rather unspecific , like below

          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.

          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.
          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

          mysql -usome_user

          which needs client plugin, it dies with rather unspecific , like below
          ```
          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
          ```
          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.
          wlad Vladislav Vaintroub made changes -
          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

          mysql -usome_user

          which needs client plugin, it dies with rather unspecific , like below
          ```
          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
          ```
          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.
          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


          {noformat}
          mysql -usome_user
          {noformat}


          which needs client plugin, it dies with rather unspecific message , like below


          {noformat}
          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
          {noformat}


          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.
          elenst Elena Stepanova made changes -
          Fix Version/s 10.2 [ 14601 ]
          serg Sergei Golubchik made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Attachment MDEV-9321-basedir.diff [ 48951 ]

          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.

          serg Sergei Golubchik added a comment - 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.
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Vladislav Vaintroub [ wlad ]
          Status In Progress [ 3 ] In Review [ 10002 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          serg Sergei Golubchik made changes -
          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


          {noformat}
          mysql -usome_user
          {noformat}


          which needs client plugin, it dies with rather unspecific message , like below


          {noformat}
          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
          {noformat}


          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.
          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


          {noformat}
          mysql -usome_user
          {noformat}


          which needs client plugin, it dies with rather unspecific message , like below


          {noformat}
          C:\work\gssapi\_CPack_Packages\win32\ZIP\mariadb-10.1.9-win32>bin\mysql -uwlad
          ERROR 2059 (HY000): Authentication plugin 'auth_gssapi_client' cannot be loaded: The operation completed successfully.
          {noformat}


          Looking with ProcessMonitor, mysql.exe tries to load it from the hardcoded path PLUGINDIR
          C:\MariaDB10.1\lib\plugin. That path is btw almost never correct, as we're installing MSI by default into C:\Program Files\MariaDB 10.1 , or, for 32bit on x64, into C:\Program Files(x86)\MariaDB 10.1 , but this is a different story.

          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.

          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.
          Fixing server on Linux was not what this bug was about. I would not mind this addition personally, given there is another bug report about it, but this one is just about clients.

          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
          Eg use
          ${CMAKE_BINARY_DIR}/out/${CMAKE_INTDIR}/bin as OUTPUT_DIRECTORY for executables, and ${CMAKE_BINARY_DIR}/out/${CMAKE_INTDIR}/lib/plugin f or plugins.
          (But this is clearly be outside of the scope of this bug)

          wlad Vladislav Vaintroub added a comment - 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. Fixing server on Linux was not what this bug was about. I would not mind this addition personally, given there is another bug report about it, but this one is just about clients. 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 Eg use ${CMAKE_BINARY_DIR}/out/${CMAKE_INTDIR}/bin as OUTPUT_DIRECTORY for executables, and ${CMAKE_BINARY_DIR}/out/${CMAKE_INTDIR}/lib/plugin f or plugins. (But this is clearly be outside of the scope of this bug)
          wlad Vladislav Vaintroub made changes -
          Assignee Vladislav Vaintroub [ wlad ] Sergei Golubchik [ serg ]
          Status In Review [ 10002 ] Stalled [ 10000 ]

          But then it should be done in C/C, for all clients, shouldn't it?

          serg Sergei Golubchik added a comment - But then it should be done in C/C, for all clients, shouldn't it?
          serg Sergei Golubchik made changes -
          Labels need_feedback

          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?
          Maybe it can be done in common option parsing code for our clients, somewhere in mysys?

          wlad Vladislav Vaintroub added a comment - 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? Maybe it can be done in common option parsing code for our clients, somewhere in mysys?

          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

          serg Sergei Golubchik added a comment - 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

          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.

          wlad Vladislav Vaintroub added a comment - 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.

          This problem does not just affect Windows. It also affects binary tarball installations on Linux.

          GeoffMontee Geoff Montee (Inactive) added a comment - This problem does not just affect Windows. It also affects binary tarball installations on Linux.
          GeoffMontee Geoff Montee (Inactive) made changes -
          Labels need_feedback

          wlad,

          • what's the problem with arg[0] ?
          • environment variables were used before, I tried not to break the compatibility with existing scripts
          • ok, will use it in mysql client too
          serg Sergei Golubchik added a comment - wlad , what's the problem with arg[0] ? environment variables were used before, I tried not to break the compatibility with existing scripts ok, will use it in mysql client too
          serg Sergei Golubchik made changes -
          Labels need_feedback

          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.
          If you can do something without extra bit of information which is arg[0], I would prefer to do it without extra bit of information, GetFullPathName always works correctly.

          wlad Vladislav Vaintroub added a comment - 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. If you can do something without extra bit of information which is arg [0] , I would prefer to do it without extra bit of information, GetFullPathName always works correctly.
          serg Sergei Golubchik made changes -
          Labels need_feedback
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 73318 ] MariaDB v4 [ 143476 ]

          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.

          serg Sergei Golubchik added a comment - 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.
          serg Sergei Golubchik made changes -
          Fix Version/s N/A [ 14700 ]
          Fix Version/s 10.2 [ 14601 ]
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          Resolution Cannot Reproduce [ 5 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          mariadb-jira-automation Jira Automation (IT) made changes -
          Zendesk Related Tickets 128158

          People

            serg Sergei Golubchik
            wlad Vladislav Vaintroub
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.