service_security_context.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MYSQL_SERVICE_SECURITY_CONTEXT
  19. #define MYSQL_SERVICE_SECURITY_CONTEXT
  20. /**
  21. @file include/mysql/service_security_context.h
  22. This service provides functions for plugins and storage engines to
  23. manipulate the thread's security context.
  24. */
  25. #ifdef __cplusplus
  26. class Security_context;
  27. #define MYSQL_SECURITY_CONTEXT Security_context*
  28. #else
  29. #define MYSQL_SECURITY_CONTEXT void*
  30. #endif
  31. typedef char my_svc_bool;
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. extern struct security_context_service_st {
  36. my_svc_bool (*thd_get_security_context)(MYSQL_THD, MYSQL_SECURITY_CONTEXT *out_ctx);
  37. my_svc_bool (*thd_set_security_context)(MYSQL_THD, MYSQL_SECURITY_CONTEXT in_ctx);
  38. my_svc_bool (*security_context_create)(MYSQL_SECURITY_CONTEXT *out_ctx);
  39. my_svc_bool (*security_context_destroy)(MYSQL_SECURITY_CONTEXT);
  40. my_svc_bool (*security_context_copy)(MYSQL_SECURITY_CONTEXT in_ctx, MYSQL_SECURITY_CONTEXT *out_ctx);
  41. my_svc_bool (*security_context_lookup)(MYSQL_SECURITY_CONTEXT ctx,
  42. const char *user, const char *host,
  43. const char *ip, const char *db);
  44. my_svc_bool (*security_context_get_option)(MYSQL_SECURITY_CONTEXT, const char *name, void *inout_pvalue);
  45. my_svc_bool (*security_context_set_option)(MYSQL_SECURITY_CONTEXT, const char *name, void *pvalue);
  46. } *security_context_service;
  47. #ifdef MYSQL_DYNAMIC_PLUGIN
  48. #define thd_get_security_context(_THD, _CTX) \
  49. security_context_service->thd_get_security_context(_THD, _CTX)
  50. #define thd_set_security_context(_THD, _CTX) \
  51. security_context_service->thd_set_security_context(_THD, _CTX)
  52. #define security_context_create(_CTX) \
  53. security_context_service->security_context_create(_CTX)
  54. #define security_context_destroy(_CTX) \
  55. security_context_service->security_context_destroy(_CTX)
  56. #define security_context_copy(_CTX1, _CTX2) \
  57. security_context_service->security_context_copy(_CTX1,_CTX2)
  58. #define security_context_lookup(_CTX, _U, _H, _IP, _DB) \
  59. security_context_service->security_context_lookup(_CTX, _U, _H, _IP, _DB)
  60. #define security_context_get_option(_SEC_CTX, _NAME, _VALUE) \
  61. security_context_service->security_context_get_option(_SEC_CTX, _NAME, _VALUE)
  62. #define security_context_set_option(_SEC_CTX, _NAME, _VALUE) \
  63. security_context_service->security_context_set_option(_SEC_CTX, _NAME, _VALUE)
  64. #else
  65. my_svc_bool thd_get_security_context(MYSQL_THD, MYSQL_SECURITY_CONTEXT *out_ctx);
  66. my_svc_bool thd_set_security_context(MYSQL_THD, MYSQL_SECURITY_CONTEXT in_ctx);
  67. my_svc_bool security_context_create(MYSQL_SECURITY_CONTEXT *out_ctx);
  68. my_svc_bool security_context_destroy(MYSQL_SECURITY_CONTEXT ctx);
  69. my_svc_bool security_context_copy(MYSQL_SECURITY_CONTEXT in_ctx, MYSQL_SECURITY_CONTEXT *out_ctx);
  70. my_svc_bool security_context_lookup(MYSQL_SECURITY_CONTEXT ctx,
  71. const char *user, const char *host,
  72. const char *ip, const char *db);
  73. my_svc_bool security_context_get_option(MYSQL_SECURITY_CONTEXT, const char *name, void *inout_pvalue);
  74. my_svc_bool security_context_set_option(MYSQL_SECURITY_CONTEXT, const char *name, void *pvalue);
  75. #endif /* !MYSQL_DYNAMIC_PLUGIN */
  76. #ifdef __cplusplus
  77. }
  78. #endif /* _cplusplus */
  79. #endif /* !MYSQL_SERVICE_SECURITY_CONTEXT */