@@ -64,30 +64,49 @@ namespace linuxdeploy {
64
64
65
65
ldLog () << LD_DEBUG << " Searching for plugins in directory" << dir << std::endl;
66
66
67
+ bool extendedDebugLoggingEnabled = (getenv (" DEBUG_PLUGIN_DETECTION" ) != nullptr );
68
+
67
69
for (bf::directory_iterator i (dir); i != bf::directory_iterator (); ++i) {
70
+ // must be a file, and not a directory
71
+ if (bf::is_directory (bf::absolute (*i))) {
72
+ if (extendedDebugLoggingEnabled)
73
+ ldLog () << LD_DEBUG << " Entry is a directory, skipping:" << i->path () << std::endl;
74
+
75
+ continue ;
76
+ }
77
+
68
78
// file must be executable...
69
- if (bf::status (*i).permissions () & (bf::owner_exe | bf::group_exe | bf::others_exe)) {
70
- // ... and filename must match regular expression
71
- boost::cmatch res;
72
- if (boost::regex_match (i->path ().filename ().string ().c_str (), res, PLUGIN_EXPR)) {
73
- try {
74
- auto name = res[1 ].str ();
75
- auto * plugin = createPluginInstance (*i);
76
- if (plugin == nullptr ) {
77
- ldLog () << LD_DEBUG << " Failed to create instance for plugin" << i->path ();
78
- } else {
79
- ldLog () << LD_DEBUG << " Found plugin '" << LD_NO_SPACE << name << LD_NO_SPACE << " ':" << plugin->path () << std::endl;
80
-
81
- if (foundPlugins.find (name) != foundPlugins.end ()) {
82
- ldLog () << LD_DEBUG << " Already found" << name << " plugin in" << foundPlugins[name]->path () << std::endl;
83
- } else {
84
- foundPlugins[name] = plugin;
85
- }
86
- }
87
- } catch (const PluginError& e) {
88
- ldLog () << LD_WARNING << " Could not load plugin" << i->path () << LD_NO_SPACE << " : " << e.what ();
79
+ if (!(bf::status (*i).permissions () & (bf::owner_exe | bf::group_exe | bf::others_exe))) {
80
+ if (extendedDebugLoggingEnabled)
81
+ ldLog () << LD_DEBUG << " File/symlink is not executable, skipping:" << i->path () << std::endl;
82
+
83
+ continue ;
84
+ }
85
+
86
+ // entry name must match regular expression
87
+ boost::cmatch res;
88
+
89
+ if (!boost::regex_match (i->path ().filename ().string ().c_str (), res, PLUGIN_EXPR)) {
90
+ ldLog () << LD_DEBUG << " Doesn't match plugin regex, skipping:" << i->path () << std::endl;
91
+ continue ;
92
+ }
93
+
94
+ try {
95
+ auto name = res[1 ].str ();
96
+ auto * plugin = createPluginInstance (*i);
97
+ if (plugin == nullptr ) {
98
+ ldLog () << LD_DEBUG << " Failed to create instance for plugin" << i->path () << std::endl;;
99
+ } else {
100
+ ldLog () << LD_DEBUG << " Found plugin '" << LD_NO_SPACE << name << LD_NO_SPACE << " ':" << plugin->path () << std::endl;
101
+
102
+ if (foundPlugins.find (name) != foundPlugins.end ()) {
103
+ ldLog () << LD_DEBUG << " Already found" << name << " plugin in" << foundPlugins[name]->path () << std::endl;
104
+ } else {
105
+ foundPlugins[name] = plugin;
89
106
}
90
107
}
108
+ } catch (const PluginError& e) {
109
+ ldLog () << LD_WARNING << " Could not load plugin" << i->path () << LD_NO_SPACE << " : " << e.what ();
91
110
}
92
111
}
93
112
}
0 commit comments