按源验证Python插件路径节边界
源依据:LinuxCNC src/emc/pythonplugin/python_plugin.cc 的 configure() 按调用方 section 查找 TOPLEVEL,但 PATH_APPEND 固定从 PYTHON section 逐项读取并在 tilde expansion 失败时返回 PLUGIN_EXCEPTION_DURING_PATH_APPEND。 结论:wasm-safe python_plugin standalone probe 增加 REMAP/PYTHON section 分离边界,确认禁用 Python 时仍保留 LinuxCNC 的 INI 查找顺序和失败状态,不引入浏览器端 Python 执行。 检查:./test-linuxcnc-wasm-python-plugin-link.sh;./test-native.sh;./test-linuxcnc-source-link.sh。
This commit is contained in:
@@ -198,6 +198,44 @@ int main() {
|
||||
setenv("HOME", saved_home_value.c_str(), 1);
|
||||
}
|
||||
std::remove(path_append_ini);
|
||||
const char *section_path_append_ini = "/tmp/cnc_sim_python_plugin_probe_section_path_append.ini";
|
||||
{
|
||||
FILE *file = std::fopen(section_path_append_ini, "w");
|
||||
if (!file) {
|
||||
std::remove(ini);
|
||||
return 50;
|
||||
}
|
||||
std::fputs("[REMAP]\n"
|
||||
"[PYTHON]\nTOPLEVEL = /tmp/cnc_sim_missing_python_section_toplevel.py\n"
|
||||
"PATH_APPEND = ~/linuxcnc-python\n",
|
||||
file);
|
||||
std::fclose(file);
|
||||
}
|
||||
unsetenv("HOME");
|
||||
// LinuxCNC source basis: python_plugin.cc configure() looks up TOPLEVEL in
|
||||
// the caller-provided section, but PATH_APPEND entries are read from the
|
||||
// fixed PYTHON section before initialize(); a PYTHON TOPLEVEL is ignored
|
||||
// when the caller configures a different section.
|
||||
if (plugin->configure(section_path_append_ini, "REMAP") != PLUGIN_EXCEPTION_DURING_PATH_APPEND) {
|
||||
if (saved_home) {
|
||||
setenv("HOME", saved_home_value.c_str(), 1);
|
||||
}
|
||||
std::remove(ini);
|
||||
std::remove(section_path_append_ini);
|
||||
return 51;
|
||||
}
|
||||
if (plugin->last_errmsg() != "bad path append") {
|
||||
if (saved_home) {
|
||||
setenv("HOME", saved_home_value.c_str(), 1);
|
||||
}
|
||||
std::remove(ini);
|
||||
std::remove(section_path_append_ini);
|
||||
return 52;
|
||||
}
|
||||
if (saved_home) {
|
||||
setenv("HOME", saved_home_value.c_str(), 1);
|
||||
}
|
||||
std::remove(section_path_append_ini);
|
||||
const char *plain_path_ini = "/tmp/cnc_sim_python_plugin_probe_plain_path.ini";
|
||||
{
|
||||
FILE *file = std::fopen(plain_path_ini, "w");
|
||||
|
||||
Reference in New Issue
Block a user