Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interposer-safe.cpp 2.5KB

9 years ago
9 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Carla Interposer for unsafe backend functions
  3. * Copyright (C) 2014-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaUtils.hpp"
  18. #include <cerrno>
  19. #include <dlfcn.h>
  20. #include <sched.h>
  21. #include <spawn.h>
  22. #define PREVENTED_FUNC_MSG carla_stderr2("Carla prevented a plugin from calling '%s', bad plugin!", __FUNCTION__)
  23. // -----------------------------------------------------------------------
  24. // Gtk stuff
  25. CARLA_EXPORT void gtk_init(int*, char***);
  26. CARLA_EXPORT int gtk_init_check(int*, char***);
  27. CARLA_EXPORT int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**);
  28. // -----------------------------------------------------------------------
  29. // Our custom functions
  30. CARLA_EXPORT
  31. pid_t fork()
  32. {
  33. PREVENTED_FUNC_MSG;
  34. errno = ENOSYS;
  35. return -1;
  36. }
  37. CARLA_EXPORT
  38. int clone(int (*)(void*), void*, int, void*, ...)
  39. {
  40. PREVENTED_FUNC_MSG;
  41. errno = ENOSYS;
  42. return -1;
  43. }
  44. CARLA_EXPORT
  45. int posix_spawn(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
  46. {
  47. PREVENTED_FUNC_MSG;
  48. return ENOSYS;
  49. }
  50. CARLA_EXPORT
  51. int posix_spawnp(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
  52. {
  53. PREVENTED_FUNC_MSG;
  54. return ENOSYS;
  55. }
  56. // -----------------------------------------------------------------------
  57. CARLA_EXPORT
  58. void exit(int status)
  59. {
  60. carla_stderr2("Carla prevented a plugin from calling 'exit', redirecting to '_exit' instead, bad plugin!");
  61. _exit(status);
  62. }
  63. // -----------------------------------------------------------------------
  64. CARLA_EXPORT
  65. void gtk_init(int*, char***)
  66. {
  67. PREVENTED_FUNC_MSG;
  68. }
  69. CARLA_EXPORT
  70. int gtk_init_check(int*, char***)
  71. {
  72. PREVENTED_FUNC_MSG;
  73. return 0;
  74. }
  75. CARLA_EXPORT
  76. int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**)
  77. {
  78. PREVENTED_FUNC_MSG;
  79. return 0;
  80. }
  81. // -----------------------------------------------------------------------