Skip to content

Commit

Permalink
Relaxed detection of datadir and core plugins to probably fix #112.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamharrison committed Jun 9, 2024
1 parent 5343f48 commit 259331a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
12 changes: 8 additions & 4 deletions src/lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ static int lpm_certs(lua_State* L) {
if (git_initialized)
git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, NULL, path);
strncpy(git_cert_path, path, MAX_PATH);
if (print_trace) {
fprintf(stderr, "[ssl] SSL directory set to %s.\n", git_cert_path);
fflush(stderr);
}
status = mbedtls_x509_crt_parse_path(&x509_certificate, path);
if (status < 0)
return luaL_mbedtls_error(L, status, "mbedtls_x509_crt_parse_path failed to parse all CA certificates in %s", path);
Expand All @@ -618,10 +622,6 @@ static int lpm_certs(lua_State* L) {
fflush(stderr);
}
mbedtls_ssl_conf_ca_chain(&ssl_config, &x509_certificate, NULL);
if (print_trace) {
fprintf(stderr, "[ssl] SSL directory set to %s.\n", git_cert_path);
fflush(stderr);
}
} else {
if (strcmp(type, "system") == 0) {
#if _WIN32
Expand Down Expand Up @@ -664,6 +664,10 @@ static int lpm_certs(lua_State* L) {
if (git_initialized)
git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, path, NULL);
strncpy(git_cert_path, path, MAX_PATH);
if (print_trace) {
fprintf(stderr, "[ssl] SSL file set to %s.\n", git_cert_path);
fflush(stderr);
}
status = mbedtls_x509_crt_parse_file(&x509_certificate, path);
if (status < 0)
return luaL_mbedtls_error(L, status, "mbedtls_x509_crt_parse_file failed to parse CA certificate %s", path);
Expand Down
26 changes: 12 additions & 14 deletions src/lpm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1603,20 +1603,18 @@ function Bottle:all_addons()
end
end
end
-- If we can't find the datadir, assume that we have the core plugins installed.
if not system.stat(self.lite_xl.datadir_path) then
for id, v in pairs(CORE_PLUGINS) do
if not hash[id] then
table.insert(t, Addon.new(nil, {
id = id,
type = "plugin",
location = "core",
organization = "singleton",
local_path = nil,
mod_version = self.lite_xl.mod_version,
path = "plugins" .. PATHSEP .. id .. ".lua"
}))
end
-- Ensure we have at least one instance of each core plugin.
for id, v in pairs(CORE_PLUGINS) do
if not hash[id] then
table.insert(t, Addon.new(nil, {
id = id,
type = "plugin",
location = "core",
organization = "singleton",
local_path = nil,
mod_version = self.lite_xl.mod_version,
path = "plugins" .. PATHSEP .. id .. ".lua"
}))
end
end
self.all_addons_cache = t
Expand Down

0 comments on commit 259331a

Please sign in to comment.