"Fossies" - the Fresh Open Source Software Archive

Member "mariadb-connector-c-3.0.8-src/include/mysql/plugin_auth.h" (18 Dec 2018, 3793 Bytes) of package /linux/misc/mariadb-connector-c-3.0.8-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
    2 /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
    3 
    4    This library is free software; you can redistribute it and/or
    5    modify it under the terms of the GNU Library General Public
    6    License as published by the Free Software Foundation; either
    7    version 2 of the License, or (at your option) any later version.
    8    
    9    This library is distributed in the hope that it will be useful,
   10    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12    Library General Public License for more details.
   13    
   14    You should have received a copy of the GNU Library General Public
   15    License along with this library; if not, write to the Free
   16    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   17    MA 02111-1301, USA */
   18 
   19 /**
   20   @file
   21 
   22   This file defines constants and data structures that are the same for
   23   both client- and server-side authentication plugins.
   24 */
   25 #define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
   26 
   27 /** the max allowed length for a user name */
   28 #define MYSQL_USERNAME_LENGTH 512
   29 
   30 /**
   31   return values of the plugin authenticate_user() method.
   32 */
   33 
   34 /**
   35   Authentication failed. Additionally, all other CR_xxx values
   36   (libmariadb error code) can be used too.
   37 
   38   The client plugin may set the error code and the error message directly
   39   in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error
   40   code was returned, an error message in the MYSQL structure will be
   41   overwritten. If CR_ERROR is returned without setting the error in MYSQL,
   42   CR_UNKNOWN_ERROR will be user.
   43 */
   44 #define CR_ERROR 0
   45 /**
   46   Authentication (client part) was successful. It does not mean that the
   47   authentication as a whole was successful, usually it only means
   48   that the client was able to send the user name and the password to the
   49   server. If CR_OK is returned, the libmariadb reads the next packet expecting
   50   it to be one of OK, ERROR, or CHANGE_PLUGIN packets.
   51 */
   52 #define CR_OK -1
   53 /**
   54   Authentication was successful.
   55   It means that the client has done its part successfully and also that
   56   a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN).
   57   In this case, libmariadb will not read a packet from the server,
   58   but it will use the data at mysql->net.read_pos.
   59 
   60   A plugin may return this value if the number of roundtrips in the
   61   authentication protocol is not known in advance, and the client plugin
   62   needs to read one packet more to determine if the authentication is finished
   63   or not.
   64 */
   65 #define CR_OK_HANDSHAKE_COMPLETE -2
   66 
   67 typedef struct st_plugin_vio_info
   68 {
   69   enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
   70          MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
   71   int socket;     /**< it's set, if the protocol is SOCKET or TCP */
   72 #ifdef _WIN32
   73   HANDLE handle;  /**< it's set, if the protocol is PIPE or MEMORY */
   74 #endif
   75 } MYSQL_PLUGIN_VIO_INFO;
   76 
   77 /**
   78   Provides plugin access to communication channel
   79 */
   80 typedef struct st_plugin_vio
   81 {
   82   /**
   83     Plugin provides a pointer reference and this function sets it to the
   84     contents of any incoming packet. Returns the packet length, or -1 if
   85     the plugin should terminate.
   86   */
   87   int (*read_packet)(struct st_plugin_vio *vio, 
   88                      unsigned char **buf);
   89   
   90   /**
   91     Plugin provides a buffer with data and the length and this
   92     function sends it as a packet. Returns 0 on success, 1 on failure.
   93   */
   94   int (*write_packet)(struct st_plugin_vio *vio, 
   95                       const unsigned char *packet, 
   96                       int packet_len);
   97 
   98   /**
   99     Fills in a st_plugin_vio_info structure, providing the information
  100     about the connection.
  101   */
  102   void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
  103 
  104 } MYSQL_PLUGIN_VIO;
  105 
  106 #endif
  107