|
1 | | -https://github.com/obsproject/obs-studio/issues/11029#issuecomment-2249747587 |
| 1 | +--- a/libobs/obs-module.c |
| 2 | ++++ b/libobs/obs-module.c |
| 3 | +@@ -22,6 +22,8 @@ |
| 4 | + #include "obs-internal.h" |
| 5 | + #include "obs-module.h" |
| 6 | + |
| 7 | ++#include <sys/stat.h> |
| 8 | ++ |
| 9 | + extern const char *get_module_extension(void); |
| 10 | + |
| 11 | + static inline int req_func_not_found(const char *name, const char *path) |
| 12 | +@@ -269,6 +271,34 @@ |
| 13 | + if (!obs || !bin || !data) |
| 14 | + return; |
| 15 | + |
| 16 | ++ char tmp_data[255] = {0}; // shouldn't hit paths 255 big? |
| 17 | ++ for (size_t i = 0; i < obs->module_paths.num; i++) { |
| 18 | ++ struct obs_module_path *old_omp = obs->module_paths.array + i; |
| 19 | ++ char *mod_loc = 0; |
| 20 | ++ struct stat old_bin, new_bin, old_data, new_data; |
| 21 | ++ size_t maxlen = strlen(old_omp->data); |
| 22 | ++ if (maxlen > 254) { |
| 23 | ++ maxlen = 254; |
| 24 | ++ blog(LOG_WARNING, "Max length of module path is over void-hackery 254 character length"); |
| 25 | ++ } |
| 26 | ++ memcpy(tmp_data, old_omp->data, maxlen); |
| 27 | ++ mod_loc = strstr(tmp_data, "%module%"); |
| 28 | ++ if (mod_loc) *mod_loc = 0; |
| 29 | ++ stat(old_omp->bin, &old_bin); |
| 30 | ++ stat(bin, &new_bin); |
| 31 | ++ stat(tmp_data, &old_data); |
| 32 | ++ stat(data, &new_data); |
| 33 | ++ if ((old_bin.st_dev == new_bin.st_dev |
| 34 | ++ && old_bin.st_ino == new_bin.st_ino) |
| 35 | ++ || (old_data.st_dev == new_data.st_dev |
| 36 | ++ && old_data.st_ino == new_data.st_ino) ) |
| 37 | ++ { |
| 38 | ++ blog(LOG_WARNING, "Skipping duplicate module path: bin: '%s', data: '%s'" |
| 39 | ++ ,bin, data); |
| 40 | ++ return; |
| 41 | ++ } |
| 42 | ++ } |
| 43 | ++ |
| 44 | + omp.bin = bstrdup(bin); |
| 45 | + omp.data = bstrdup(data); |
| 46 | + da_push_back(obs->module_paths, &omp); |
2 | 47 | --- a/libobs/obs-nix.c |
3 | 48 | +++ b/libobs/obs-nix.c |
4 | | -@@ -67,22 +67,6 @@ static const struct obs_nix_hotkeys_vtable *hotkeys_vtable = NULL; |
5 | | - |
6 | | - void add_default_module_paths(void) |
7 | | - { |
8 | | -- char *module_bin_path = os_get_executable_path_ptr("../" OBS_PLUGIN_PATH); |
9 | | -- char *module_data_path = os_get_executable_path_ptr("../" OBS_DATA_PATH "/obs-plugins/%module%"); |
10 | | -- |
11 | | -- if (module_bin_path && module_data_path) { |
12 | | -- char *abs_module_bin_path = os_get_abs_path_ptr(module_bin_path); |
13 | | -- |
14 | | -- if (abs_module_bin_path && |
15 | | -- strcmp(abs_module_bin_path, OBS_INSTALL_PREFIX "/" OBS_PLUGIN_DESTINATION) != 0) { |
16 | | -- obs_add_module_path(module_bin_path, module_data_path); |
17 | | -- } |
18 | | -- bfree(abs_module_bin_path); |
19 | | -- } |
20 | | -- |
21 | | -- bfree(module_bin_path); |
22 | | -- bfree(module_data_path); |
23 | | -- |
| 49 | +@@ -33,6 +33,7 @@ |
| 50 | + #include <stdlib.h> |
| 51 | + #include <stdio.h> |
| 52 | + #include <unistd.h> |
| 53 | ++#include <sys/stat.h> |
| 54 | + #if defined(__FreeBSD__) || defined(__OpenBSD__) |
| 55 | + #include <sys/sysctl.h> |
| 56 | + #endif |
| 57 | +@@ -83,7 +84,11 @@ |
| 58 | + bfree(module_bin_path); |
| 59 | + bfree(module_data_path); |
| 60 | + |
| 61 | ++ struct stat stat_info; |
| 62 | ++ |
24 | 63 | for (int i = 0; i < module_patterns_size; i++) { |
| 64 | ++ if ((stat(module_bin[i], &stat_info) == 0 && !!S_ISDIR(stat_info.st_mode) ) |
| 65 | ++ && (stat(module_data[i], &stat_info) == 0 && !!S_ISDIR(stat_info.st_mode) ) ) |
25 | 66 | obs_add_module_path(module_bin[i], module_data[i]); |
26 | 67 | } |
| 68 | + } |
0 commit comments